I have built a medical data logger which uses SDFat to write a CSV file. The device is powered on with a hardware button but has a touch sensitive screen with a button to start and stop recording. The stop recording button closes the file nicely.
However, I also want to guard against the patient powering off with the hardware button. Some data loss is inevitable but we cannot afford to lose the entire record just because a patient fails to follow the prescribed process.
Up until now I have been using FATFS and it is very robust in this case. SDFat is much faster but the file is zero length if the power button is used. I tried a synch command at 1 Hz intervals but this also resulted in a zero length file.
Any advice would be appreciated.
How large is the buffer in SDFat?
I note that the binary to csv routine in the fast data logger example performs a synch based on a cluster counter but I am yet to work out exactly how that works.