Saving Data

Hi all,
How can I store some data on flash? And how can I read?
Thanks.

Use EWR (Extended weak references).

There is an example that comes with .NET MF.

On my machine it is located at C:\Users\mike\Documents\Microsoft .NET Micro Framework 4.2\Samples\ExtendedWeakReferences

This assumes that you want to be able to write it from your program and then read it back.

Otherwise, consider using resources. http://wiki.tinyclr.com/index.php?title=Loading_Resources for read only.

Thanks a lot. I’m checking.

Note that EWR is not available on Cerb family http://wiki.tinyclr.com/index.php?title=FEZ_Cerberus_Developer#Why_EWR_is_not_available_on_cerb-family.3F

Sorry for late reply.
I tried EWR sample. It works for reboot, but not for power down. Do I miss something? I want to save some data permanently.
Thanks a lot.

there is a parameter that determines whether the object survives power down.

check out this discussion http://www.microframework.nl/2008/12/23/extended-weak-references/

Thanks a lot Mike. Sample works fine.
But when I combine it with my application, I have trouble. I think my problem is shutting device down. My code doesn’t reach the end of Main because I unplug.
Application.Current.Shutdown() gives an error. Any suggestions?

No sure what you mean? With Gadgeteer, main should never exit. Gadgeteer is event driven.

Also, an embedded application should never “shutdown”. What are you trying to achieve?

There is a delay before your EWR object is actually written to flash. I have not used it, but I believe there was a flush function added to the EWR functionality in MF 4.2 to write any pending EWR objects to flash.

I copied the code from sample to my application. It works if I reboot from Debug, but it fails if I unplug or reset. As I see, only difference between Sample and mine app is Sample finishes Main, but mine doesn’t. Thats why I asked. I will keep trying. Thanks.

hi a quick search in code share gave many examples:
here is one:

http://www.tinyclr.com/codeshare/entry/196

please do a search and study those examples.

Good luck.

and here is a post that talks about the flush function that mikes mentioned:
http://www.tinyclr.com/forum/topic?id=3833

Thanks a lot.

Of course I did. I think I didn’t choose correct keywords :S
Thanks again.

Yah i know; the search on CodeShare is a bit funky and has it’s own mind…so you might want to start using bing to search Codeshare:

type this in the bing search:


flash site:www.tinyclr.com/codeshare

and here is what i got when using the search:
http://www.bing.com/search?q=flash+site%3Ahttp%3A%2F%2Fwww.tinyclr.com%2Fcodeshare&go=&qs=ds&form=QBLH&filt=all

Cheers.