How to use persistent data in c++

In my c++ application, I have some data (array of uint8) that I need to store in the retain memory (NVRAM). This data is updated every program cycle (every 5..10 ms).

On power-off and restart of the ctrlX, the data should be read from the retain memory.

Currently, I'm not sure how to do this properly. I assume that I have to use the data layer for this. But do I just create a node for it as a data layer client or do I have to use RT access to the data layer? None of this worked yet in my test program.

Is there a code example somewhere?

Best reply by nickH

Hi BennyF 

I was able to reproduce your error and can confirm that this is a bug in the Data Layer. This bug occurs when using a real nvram from a seperate process (outside of the automationcore). We will fix this bug in the ctrlX Data Layer. I will let you know when I have news on the bugfix. 

In the meanwhile you can use a workaround. Its possible to also use the emulated nvram on the hardware ctrlX CORE. This setting can be changed in the Data Layer at "datalayer/server/settings". And will be active after a reboot of the control. 

 

Best regards, 

Nick

View original
14 replies