I'm working on a data logging feature that will be writing a few bytes at a time to a file. The file will likely be on a removable CF / SD card. The writes will happen every 10 seconds or as slow as every 30 minutes.
The write buffer associated with the FileWrite command is large enough to hide a significant number of records and a large amount of recording time. Yes if the form is closed or app is terminated the program will close the file and the buffer will be correctly flushed to the file as a result.
But if a user removes the memory card without first doing something that will cause the file to close - much data will be lost.
Maybe I should be opening and closing the file for each write. But it would also be nice to have an unbuffered write or flush command available.
In terms of the expected lifespan of SD and CF memory - doing larger buffered writes might be the best for the memory card. But if that isn't a good option, would lots of small unbuffered writes to the end of an open file cause less wear than opening, appending, and closing the file each time?
It would seem like the file open / close technique would be causing frequent updates to the FAT or directory and that could result in more than a single file being damaged.
The write buffer associated with the FileWrite command is large enough to hide a significant number of records and a large amount of recording time. Yes if the form is closed or app is terminated the program will close the file and the buffer will be correctly flushed to the file as a result.
But if a user removes the memory card without first doing something that will cause the file to close - much data will be lost.
Maybe I should be opening and closing the file for each write. But it would also be nice to have an unbuffered write or flush command available.
In terms of the expected lifespan of SD and CF memory - doing larger buffered writes might be the best for the memory card. But if that isn't a good option, would lots of small unbuffered writes to the end of an open file cause less wear than opening, appending, and closing the file each time?
It would seem like the file open / close technique would be causing frequent updates to the FAT or directory and that could result in more than a single file being damaged.