Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Basic4ppc Wishlist
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Basic4ppc Wishlist Missing any feature?

Unbuffered Write / Buffer Flush

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-05-2007, 10:52 PM
Newbie
 
Join Date: Jul 2007
Posts: 9
Default Unbuffered Write / Buffer Flush

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.
Reply With Quote
  #2 (permalink)  
Old 07-06-2007, 04:10 AM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

The only way to 100% flush data to a storage card is to close the file stream.
The OS has an internal cache that can't be flushed otherwise.
Reply With Quote
  #3 (permalink)  
Old 07-06-2007, 07:53 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

I wouldn't worry about it - just close the file each time, particularly as you seem to be intending to write with a frequency in the high seconds or low minutes. Some/most devices nowadays employ some form of flash management in their low level drivers to even out wear on the memory.

Flash is so cheap anyway that if it is a critical application then tell the user to change the memory every six months or so like we used to change lead-acid batteries on float charge backing up critical industrial logging systems.
Reply With Quote
  #4 (permalink)  
Old 07-06-2007, 02:21 PM
Newbie
 
Join Date: Jul 2007
Posts: 9
Default

Erel and agraham,

Many thanks. My application came together in three days with your great product and support. I'm off to buy Basic4ppc. Then to add charting ...
Reply With Quote
  #5 (permalink)  
Old 07-06-2007, 03:05 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,689
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

As we are looking for quotes I ask your permission to use this one
Reply With Quote
  #6 (permalink)  
Old 07-07-2007, 10:26 PM
Newbie
 
Join Date: Jul 2007
Posts: 9
Default

Erel,

Yes that would be fine since it is already on the forum. I may be able to give you more detail and links later but I'd like more experience with the product first.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
TX buffer micro Questions (Windows Mobile) 4 09-15-2008 04:44 PM
Collect pieces of string in a buffer schimanski Questions (Windows Mobile) 1 08-17-2008 01:09 PM
Write IF error GallyHC Questions (Windows Mobile) 4 06-02-2008 05:42 PM
code to write out combinations e.g. (10 choose 3) Stellaferox Questions (Windows Mobile) 4 02-04-2008 05:51 AM
Tip on how not to write speedy code kolbe Code Samples & Tips 1 01-30-2008 08:20 AM


All times are GMT. The time now is 01:56 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0