Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
I am using the FatFileSystem and SDFileSystem packages to log data to files on an SD card.
I would like to keep a file open for a relatively long period (hours), but to also protect against data loss should the mbed lose power or reset before fclose is called.
I have tried using fflush after every write and I also tried using setvbuf(f, 0, _IONBF, 0) to force all writes to be immediate, but neither method seemed to do anything.
Is there no alternative to opening and closing the file periodically? Could frequent open/close calls corrupt the file or SD FS?
Thanks!