One of our customers have return back his product due to troubles when reading xml on SDCard.
The product is based on EMX module. When I have connected the sdcard on Microsoft Vista, my compueter say that the device was dammaged and will try to repair sector. I have choose “no” and have seen files inside SD. One of them was supposed to be 133kB and this what was printed by windows. When I tried to open it with notepad++, files was empty. When I tried with vim, this last was returning “file corrupted”.
I decided to let vista repairing errors and after correction the file was just 127kB and the file was now readable but the last part of file disappear.
My feeling was that power supply of EMX has been switch off before the file was properly writing.
Yesterday I have try to redo experiment: switching off the power just after (between 0 and 5second) flushing closing and disposing the filestream. Each time I succeed to reproduce the error. On the contrary each time that I have wait 30 seconds before switching off the power supply files were proeprly written.
After investigating the forum, some posts advice to call unmount() and mount after writing to ensure data integrity, others advice to call Flushall().
Is there any difference?
How to be sure that power can be switch off safely?