Post your best Lua script examples here

User avatar
By ThomasW
#3050 Hi,

some remarks/questions about the file - functions:

- It already happened twice that I suddenly couldn't write to a file anymore - module restarted on every file.open("test.lua","w+"). Seems to happen after many writes to the same(?) file (I uploaded very often..). Re-flashing firmware solved the problem but I would like to know if this is hardware-related or maybe a bug in the internal 'fileystem'?

- It would be great to have a file.exists(filename) function (or maybe file.open() returning a boolean instead of throwing an error on failure).

- Is it possible/planned to be able to open more than 1 file at once?

- (minor) I think file.list() should not print the listing by default, just return the table. Maybe file.list(bool printit)?

- (very minor) The example for file.list() in the docs should be "for k,v in pairs(l) do" not "for k,v in l do" ;)

Again - many thanks for your work!
Thomas
User avatar
By cendev
#3112 Had the same problem, but mine was a bit tricky :) it was also the init.lua :D

Whenever i tried to file.open it or file.remove it i had a restart, but module was able to boot and work as if everything is fine.

Also sometimes, i had 4 files with the exact same name :)

Ow, btw, to fix (to remove) the init.lua file, i had to reflash the firmware :/
User avatar
By zeroday
#3123
ThomasW wrote:Hi,

some remarks/questions about the file - functions:

- It already happened twice that I suddenly couldn't write to a file anymore - module restarted on every file.open("test.lua","w+"). Seems to happen after many writes to the same(?) file (I uploaded very often..). Re-flashing firmware solved the problem but I would like to know if this is hardware-related or maybe a bug in the internal 'fileystem'?

- It would be great to have a file.exists(filename) function (or maybe file.open() returning a boolean instead of throwing an error on failure).

- Is it possible/planned to be able to open more than 1 file at once?

- (minor) I think file.list() should not print the listing by default, just return the table. Maybe file.list(bool printit)?

- (very minor) The example for file.list() in the docs should be "for k,v in pairs(l) do" not "for k,v in l do" ;)

Again - many thanks for your work!
Thomas


I will give more test to file api. one of guy I know report a same name files too... It's definitely a bug.
currently file.open will close the file opened before if user forget to close it.
only one file supported now. it's getting complicated if multiple files opened, like the lua io module.
file.list() print to serial will be removed in next build.
doc fixed.
User avatar
By yes8s
#4534 Just reporting that I also have had this issue many times. A file open or file remove of any file will then crash the system. Only way to fix has been to reflash.