|CODESYS - the IEC 61131-3 automation software
|Persistent Retain Not Saved After Crash
|Page 1 of 1|
|Author:||Simon61131 [ Wed Jul 10, 2019 3:55 pm ]|
|Post subject:||Persistent Retain Not Saved After Crash|
When my application crashes, a previously written variable will not be saved persistently.
I am currently implementing a checkpoint variable. It is supposed to show which checkpoint/section has been reached after a crash. With this I intend to find sections with code errors, which lead to crashes.
The variable is defined as global retain persistent. The first thing that happens when the program starts, is that this variable will be evaluated once and sent by CAN.
By now I have a method with which I can let my program crash. I used the method to test my checkpoint variable, if it is written properly after a crash.
Unfortunately, this is not the case. The last written and transmitted value is 5 segments old. So, the variable is written multiple times, in different segments, then is written a last time and then the program is being let crashed.
If I think about C/C++, what comes to my mind is the keyword 'volatile'.
There is only one task, so it will most likely not be a problem of multiprocessing.
I also added a loop with 1000 iterations for a test. It probably also doesn't have anything to do with code ordering/ optimization. (Notable is, this code is running on an operative system and is intended for diagnosis. So, it is not reasonable to wait 5ms after writing a checkpoint variable.)
Is it possible, that this variable is being written to a cache before it is being put into the flash?
Is it possible to make a variable 'volatile'? ('volatile' in the meaning like in C, being written to the RAM/Flash without cache optimization)
Is there another possible reason for my problem?
Is there a flush-method to actively write to the flash, without any cache?
Is there a bread crumb register to write to, which is more reasonable for my purpose?
Best regards and thanks in advance
|Page 1 of 1||All times are UTC+01:00|
|Powered by phpBB® Forum Software © phpBB Limited