This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Read/write file to LM5 connected USB
#9
First, reboot your LM. Since you have tried different scripts your mount table is probably messed up. Second, make sure your flash drive is formatted as FAT or FAT32 (but not exFAT). Run this script once, then go to System Config > Status > System Status. In Partitions tab you should see that /dev/sda1 or similar is mounted under /mnt. Then you can use io.writefile('/mnt/myfile.txt', 'test') to write something onto USB drive.

Code:
1234567891011121314151617181920212223
devs = io.ls('/sys/class/block/') table.sort(devs) for _, dev in ipairs(devs) do   if dev:match('^sd%a%d$') then     part = dev     break   elseif not devn and dev:match('^sd%a$') then     devn = dev   end end part = part or devn if part then   os.execute('umount -f /mnt 2>&-')   res, stat = io.readproc('mount /dev/' .. part .. ' /mnt 2>&1')   if stat == 0 then     alert('USB mount OK')   else     alert('USB mount failed: ' .. tostring(res))   end else   alert('No valid USB devices found') end
Reply


Messages In This Thread
RE: Read/write file to LM5 connected USB - by admin - 11.04.2017, 07:38

Forum Jump: