Main Site Documentation

ExtendedWeakReference on FEZ Spider


#1

I just tried to use ExtendedWeakReference on a FEZ Spider (MF 4.2, Firmware 4.2.9) with the code given in the MF sample or I read in the forum. Unfortunately it doesn’t save anything. The target of ExtendedWeakReference.RecoverOrCreate(…) is always null. Is there anything to enable it?

Code - writing
var ewr = ExtendedWeakReference.RecoverOrCreate(typeof(TypeUniqueToOurApp), 0, ExtendedWeakReference.c_SurvivePowerdown);
ewr.Priority = (Int32)ExtendedWeakReference.PriorityLevel.Critical;
var numBoots = ewr.Target as NumBoots;
if (numBoots == null)
numBoots = new NumBoots(1);
else
numBoots.BootCount += 1;
ewr.Target = numBoots;

Code - reading
var ewr = ExtendedWeakReference.RecoverOrCreate(typeof(TypeUniqueToOurApp), 0, ExtendedWeakReference.c_SurvivePowerdown);
var numBoots = ewr.Target as NumBoots;
numBoots is always null!

Thanks for helping.


#2

@ HBe - You need to use fully qualified type name as the type selector (name that includes namespaces).

See this thread:

http://www.tinyclr.com/forum/topic?id=10601


#3

Fully qualified type names help a littel bit, e.g. data will be kept as long the machine is running. But the data didn’t survive rebooting even I set the flag

ExtendedWeakReference.c_SurvivePowerdown

I also was playing ouround with

ewr.PushBackIntoRecoverList();

Nothing helped. After rebooting (and deploying) the same code, the call

ExtendedWeakReference.RecoverOrCreate(...)

couldn’t recover the data. The code seems to be too easy to make any mistakes!

@ andre - thanks for the “101010” icon - I didn’t see it before…


#4

No, this sample doesn’t work either. First I had to change the sample and use the fully qualified type. I could

RecoverOrCreate 

the data until I rebooted the FEZ. Then everything was gone.
Thanks for your answer. I probably won’t use the flash memory, even if it would work, because as I understood the manual, it’s not guaranteed that the data would survive anyway. Probably it’s better to store data on a sd card.


#5

@ HBe - as an alternative to using an SD card, you could use the Flash module.

http://www.ghielectronics.com/catalog/product/389

If the raw access to this module does not suite you, there is also a file system driver available on code share

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


#6

Hi HBe,

Have you been able to fix your problem with the writing of data on the Spider internal Flash memory ?

I do face the same problem. I used the code you talk about here and now with the latest version of the SDKs, nothing is stored in the Flash Memory, and the call to RecoverOrCreate always returns NULL.

Thanks for the feedback,

Stephan.


#7

@ andre.m : Can’t remember where it comes from, it was last year when I started the project on NETMF 4.1. It was part of exchanges on the forum…

Could you point me to the code you use that works ?

Thanks Andre.


#8

Got it. Thanks, Let me test that code, and verify mine. Stay tune :slight_smile:


#9

Hi,

OK. The demo code works also fine on my spider. So that means that it’s my code that does not work.

A couple of questions to figure out what’s going wrong :

  • How big can be the object that you put in Flash ? I actually put in a single classe all the configuration I need for my project. It’s more than a hundred parameters, mostly short strings

  • What exactly can be serialized and what cannot ? For example, can a DateTime object be serialized ?

Stephan.


#10

The object that can be serialized for extended weak reference have the serializable attribute.

As an example, check the attribute for array list and hashtable int the system collection namespace.

How big can be the object… this is a real problem nobody can say how to compute the size of data that we can pass to EWR. However you can reduce size using [serializationhint].