CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Wed Feb 19, 2020 9:20 am

All times are UTC+01:00

Post new topic  Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Jul 10, 2019 3:55 pm 

Joined: Thu Jan 24, 2019 10:15 am
Posts: 8
Hi everyone,

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

PostPosted: Fri Jan 03, 2020 8:27 am 

Joined: Fri Sep 20, 2019 12:47 pm
Posts: 9
I ran into similar problem, and according to what the codesys guy told me, the remain vars are written to retain file ON SHUTTING DOWN. This means that if your application crashes or on power cut it will not be able to store them. More importantly, it may lead to corrupted retain file (open in RW), similar like what happens with config file.

We decided to proceed with our own implementation of retain file, however we got no answer yet if it is possible to alter codesys's implementation of retain file.

Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 2 posts ] 

All times are UTC+01:00

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited