Shop OBEX P1 Docs P2 Docs Learn Events
FSRW and closing files — Parallax Forums

FSRW and closing files

HughHugh Posts: 362
edited 2010-09-13 09:59 in Propeller 1
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

Comments

  • localrogerlocalroger Posts: 3,452
    edited 2010-09-11 13:06
    Hugh, fsrw has two buffers, one for file data and one for "metadata" which generally caches the FAT while you're writing a file. Somewhere in FSRW there is a routine (a PRI IIRC) which flushes the metadata buffer. All you need to do is make that routine PUB and call it once in awhile to make sure the metadata is actually written to the SD.

    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.
  • HughHugh Posts: 362
    edited 2010-09-13 09:59
    Thanks Localroger, that's the one...

    Cheers
    Hugh
Sign In or Register to comment.