I am using a Digi Connect Wi-EM and i wondered how i could save a history of events (they are bytes of a state or an event, and date and time).
For example, something like that :
(date) (time) (byte) or some characters
2005/01/09 12:52 00010000
2005/01/09 12:53 00000000
2005/01/09 12:52 door opened
2005/01/09 12:53 door closed
I wondered if it was possible to save it as a text file or something else that would allow me easily to see what happened.
I’d better save it in the Flash memory isn’t it ?
I would need any help, please, in order to update this file each time that an event happened, and i have to modify my programm to make sure it is ok.
Could you tell me how to easily write and read this file in flash memory please ?
I tried naflash directory but it seems too detailed for what i need …
You have a couple of method for doing this available to you.
- You could write directly to flash.
- You could enable the flash file system and write your log file out in the form of a text file.
Keep in mind that the flash device used on the Wi-EM has a 100,000 write/erase cycle guarantee.
My suggestion would be to use teh second option, as the file system implements a wear leveling algorithm, which will help in extending the life of the flash.
Thank you very much for your reply.
Is there any example of enabling the flash file system and writing a log file out in the form of a text file ?
Please let me know.
Enabling the flash file system (FFS) can be accomplished in two manners.
- Based on the nafilesys example, have the application call all of the necessary file system API functions to create the file system.
- Within src/bsp/platforms/$(PLATFORM)/bsp.h there is a #define, entitled BSP_INCLUDE_FILESYSTEM_FOR_CLIBRARY. If you set this define to TRUE and rebuild the BSP, the a FFS will be built, based on the configuration as defined in startfilesystem.c.
As for reading and writing to/from the FFS, this would be accomplished using the standard IO functions, such as fread, fwrite, read, write, etc. I do not have an specific examples of such.