SPIFFS... Have to close file to read after write operation..?

rahul.b.patel
Posts: 62
Joined: Wed Apr 19, 2017 6:35 am

SPIFFS... Have to close file to read after write operation..?

Postby rahul.b.patel » Wed May 24, 2017 6:23 am

Hello,

I have an issue of SPIFFS read-write operation. I open file in read-write mode to write data into file, then try to read data without closing the file, but read operation fails with return of -1. But when I follow same procedure with adding extra step of closing file after file write and then again open file in read-write mode and then file read operation works perfectly.
Does anybody have came across same problem..? Can anybody explain it..?

Thanks.

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

Re: SPIFFS... Have to close file to read after write operation..?

Postby loboris » Wed May 24, 2017 6:49 am

You have to use fseek() to position the file pointer. If you write to the empty file, the file pointer will be at EOF after fwrite.
https://www.tutorialspoint.com/c_standa ... _fseek.htm

rahul.b.patel
Posts: 62
Joined: Wed Apr 19, 2017 6:35 am

Re: SPIFFS... Have to close file to read after write operation..?

Postby rahul.b.patel » Wed May 24, 2017 7:05 am

Ohh yeah... Correct. Thanks for early reply.

Who is online

Users browsing this forum: burtrum and 92 guests