![]() |
Communication with Usb - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Communication with Usb (/showthread.php?tid=690) |
Communication with Usb - Shalltear - 21.03.2017 Good morning, I have a problem, use this code, but even without the usb it appears that it is connected. My question is how do I place the USB location? I'm working it this way... path = 'mnt/PalominoSyT' if io.exists(path) then os.execute('mount' .. path .. ' /mnt') alert('USB mont') else alert('USB not found') end path = '/mnt' status = io.exists(path) io.writefile(path .. 'new.txt', 'This is a test') result = io.readfile(path .. 'new.txt') lea = io.readfile('TestLMUsb.txt') log(status, result, lea) RE: Communication with Usb - admin - 22.03.2017 Use this function to mount USB properly, in alerts you will get either ok or an error message. By default it mounts the first partition from USB drive to /mnt so you don't have to change anything unless you don't want it to work ![]() Code: function mountusb(part, mnt) Then, to read/write files you need to supply full path like /mnt/myfile.txt. Because in your case path .. 'new.txt' becomes /mntnew.txt which will be written to the main file system instead of USB drive. RE: Communication with Usb - Shalltear - 22.03.2017 I get the following error, should I create any directory? Thank you. RE: Communication with Usb - admin - 23.03.2017 The script was incorrect, I've updated it. RE: Communication with Usb - Shalltear - 23.03.2017 Thanks, but I still get the same error. ![]() RE: Communication with Usb - admin - 24.03.2017 Go to system config -> status -> system log. When you connect your USB drive it will show the list of partitions. Some incorrectly formatted drives might use the whole drive without partitions, then you should try mountusb('/dev/sda') RE: Communication with Usb - Shalltear - 24.03.2017 I already changed it, but I still get the error, when I put mountusb ('/ mnt') the status is USB ok but it is not taking the USB. With this code I also get error, I do not know what else to try. <code> function mountusb(part, mnt) part = part or '/dev/sda1' mnt = mnt or '/mnt' local cmd = string.format('mount %q %q 2>&1', part, mnt) local res, stat = io.readproc(cmd) return stat == 0 and true or nil, res end res, err = mountusb('/dev/sda') if res then alert('USB OK') else alert('USB error: ' .. tostring(err)) end </code> RE: Communication with Usb - Erwin van der Zwart - 24.03.2017 Hi, Can you make a screenshot of your syslog direct after placing usb? Also from ports and from partitions screen? Have you tried another stick? BR, Erwin RE: Communication with Usb - Shalltear - 24.03.2017 (24.03.2017, 17:12)Erwin van der Zwart Wrote: Hi, RE: Communication with Usb - Erwin van der Zwart - 24.03.2017 Hi, I don't see any USB stick showed in your sys log .. Have you tried another stick? Are you using a USB hub? This is what i see when inserting a USB drive (notice the new usb found @ 22:32:54 as SDA) BR, Erwin RE: Communication with Usb - Shalltear - 28.03.2017 Hi, I was able to get the USB connection, thanks for your help. ![]() |