I'm trying to use the filename node to find a file on a USB drive and use this to tell the File Write node where to write to. However, this is not working unless the Pi is logged in and I'm getting a "File could not be Accessed" in the debug.
Any ideas how I can get this working? I need to keep the pi signed out so that it keeps the console etc secure.
The easiest way is to fire up a terminal on the Pi - personally I always use SSH - I never run the desktop on the Pi as it is too resource hungry.
Then:
ls -lah /mnt/usb
or whatever your usb drive is mounted as.
Actually, that could be the other issue. Possibly it is the desktop that is mounting the usb drive rather than the OS itself? Well, you will soon find out I guess.
Thanks for that, I'll look into setting that up justnow.
One quick question about this, does this allow me to remove a USB and add another USB drive in its place or would I need to set up the auto-mount again for the new USB drive?
These Pi's are going to be used in remote locations with datalogging saved on the USB, and once in a while someone will go to site and swap the USB drives to allow us to get the information.
I think so. I think that I've used it in the past but I can't totally remember I'm afraid. I expect the docs will tell you.
Allowing dynamic USB use is something of a security issue so you should read up on that possibly depending on the criticality of the devices and their data.
I assume that the devices don't have network access otherwise that would, of course, be a much better option.
You should also remember that USB pen drives do fail with depressing regularity, especially if you are writing to them regularly. You should allow for regular replacement of the drives themselves and not leave it too long between swaps.
Thanks for getting back to me. I've followed your instructions but it still isn't allowing Node-Red to read the file until I log into the Pi.
Is there another step (other than the sudo apt-get install usbmount and the sudo nano /lib/systemd/system/systemd-udevd.service and reboot) that I've missed?
I think I've managed to get it to mount without signing in as a sudo cat /proc/mounts shows /dev/sda1 /media/usb0 vfat rw, sync, nodev, noexec, noatime, nodiratime, fmask=0022, dmask=0022, codepage=437, iocharset=ascii, shortname=mixed, errors=remount-ro 0 0
I don't quite understand what this means but the fact it can see my drive seems promising.
However, I still am unable to write to it with node-red until I sign in.
Is there possibly a way to use Node-Red to mount the drives using the Exec function?
I'm out of my depth here so just grasping at straws.
Tested it with my flow and it appears that the file lister node can now see the files, however I can no longer edit/delete/append the files - even when logged in. It doesn't allow me to edit the files even when using the GUI. I'm not sure how I've managed to do this.
total 52K
drwxr-xr-x 4 root root 16K Jan 1 1970 .
drwxr-xr-x 13 root root 4.0K Jun 25 10:33 ..
drwxr-xr-x 4 root root 16K Jun 12 15:55 logs
drwxr-xr-x 2 root root 16K Jun 11 10:34 System Volume Information
-rwxr-xr-x 1 root root 0 Jun 5 13:57 WriteFanData.txt
I notice that everything is set to "root root", as I sign in through the "pi" user how would I edit these permissions so that node-red can access these files?