Page 1 of 1

Is reading and writing a Littlefs logfile at the same time allowed?

Posted: Wed Aug 14, 2024 10:40 am
by arjen1
Dear forum

I do not seem to get the correct search phrases for this question:

I read sensor input. Every 5 minutes I write 7 values with a time stamp to a logfile in LittleFS.
Now and then I want to read (some) values of this file and show it in a chart.

Can I do that? Can you open a file for writing and a the same time and in another function open the same file for reading without conflict?

Thanks

Re: Is reading and writing a Littlefs logfile at the same time allowed?

Posted: Wed Aug 14, 2024 12:27 pm
by AgentSmithers
Are you using Arduino's LittleFS or some other variation? If so can you provide the link to confirm the implementation.

Re: Is reading and writing a Littlefs logfile at the same time allowed?

Posted: Wed Aug 14, 2024 5:18 pm
by arjen1
I am using the built in LittleFS, I did not install any other library for LittleFS.

Re: Is reading and writing a Littlefs logfile at the same time allowed?

Posted: Wed Aug 14, 2024 7:21 pm
by AgentSmithers
arjen1 wrote:
Wed Aug 14, 2024 5:18 pm
I am using the built in LittleFS, I did not install any other library for LittleFS.
Is this an Arduino project? I am unsure what you mean by "Built-in".

Re: Is reading and writing a Littlefs logfile at the same time allowed?

Posted: Thu Aug 15, 2024 9:36 am
by arjen1
Using the arduino IDE for an ESP8266 project. I am using the LittleFS library that comes with the Arduino IDE, or maybe when you install the ESP8266 stuff. I did not install any 3rd party LittleFS library.

Re: Is reading and writing a Littlefs logfile at the same time allowed?

Posted: Sat Aug 17, 2024 10:03 pm
by AgentSmithers
This question is specific to LittleFS, not so much Arduino as an interrupt may be triggered to write the data while reading is in progress, however, if LittleFS creates a variable to hold if the data is locked then that will be an issue.

Have you implemented an interrupt/protothreads to handle triggering either reading or writing while the opposite is occurring, or what method are you attempting to use to kick off the read/writing while the other is taking place?