FSRW and closing files
Hugh
Posts: 362
Hi,
I am using FSRW v2.6 to write data to a log file. At the end of the recording, I press a button and the 'pclose' method closes the file and everything is tickety-boo.
However, sometimes power is lost during the recording and the file is either empty or incomplete (I guess because the file allocation tables hasn't been updated, etc.,)
One option would be to periodically 'pclose' the file an then 'popen' it in append mode immediately afterwards, but I am a bit worried that this might cause a few samples of the log to be missed whilst this happens (there are about 30 samples per second).
Is there a better way? I couldn't work out what the 'pflush' method did - does this force an update, or dispose of the current contents of the buffer (under the influence of a couple of gallons of water)?
Thanks
Hugh
I am using FSRW v2.6 to write data to a log file. At the end of the recording, I press a button and the 'pclose' method closes the file and everything is tickety-boo.
However, sometimes power is lost during the recording and the file is either empty or incomplete (I guess because the file allocation tables hasn't been updated, etc.,)
One option would be to periodically 'pclose' the file an then 'popen' it in append mode immediately afterwards, but I am a bit worried that this might cause a few samples of the log to be missed whilst this happens (there are about 30 samples per second).
Is there a better way? I couldn't work out what the 'pflush' method did - does this force an update, or dispose of the current contents of the buffer (under the influence of a couple of gallons of water)?
Thanks
Hugh
Comments
Even close/open append shouldn't lose data on you; that's what cogs are for. There's no reason for the cog collecting the data to miss something because the cog writing it hiccupped.
Cheers
Hugh