Left for archival purposes.

User avatar
By ThomasW
#3939 ... would be nice to have, ideally working together with file.seek() and auto-advancing the pointer on every read. Would return requested number of bytes or fewer(at the last read)
Use cases could be:
Code: Select allfile.open("test.jpg","r")
chunk=file.read(50)
while chunk
    sk:send(chunk)
    chunk=file.read(50)
end

Code: Select allfile.open("some.file","rw")
file.seek("set",10)
chunk=file.read(20)
file.seek("set",10)
file.write(analyze_and_modify(chunk))

Thomas
P.S.: BTW, many thanks for the latest firmware updates!
User avatar
By Markus Gritsch
#6550 From reading the current NodeMcu source code I see that this has already been implemented:

// Lua: read()
// file.read() will read all byte in file
// file.read(10) will read 10 byte from file, or EOF is reached.
// file.read('q') will read until 'q' or EOF is reached.

Thanks a lot!
User avatar
By yes8s
#6556
Markus Gritsch wrote:From reading the current NodeMcu source code I see that this has already been implemented:

// Lua: read()
// file.read() will read all byte in file
// file.read(10) will read 10 byte from file, or EOF is reached.
// file.read('q') will read until 'q' or EOF is reached.

Thanks a lot!


Can this feature be used as a good workaround for the other issue where the conn:on('sent'..) callbacks are called too early?