-->
Page 1 of 2

file.read(bytes)

PostPosted: Wed Dec 03, 2014 12:57 pm
by ThomasW
... 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!

Re: file.read(bytes)

PostPosted: Sat Dec 27, 2014 3:09 pm
by Markus Gritsch
+1 :)

Re: file.read(bytes)

PostPosted: Wed Jan 07, 2015 9:25 am
by Markus Gritsch
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!

Re: file.read(bytes)

PostPosted: Wed Jan 07, 2015 9:34 am
by yes8s
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?