For the generic Linux SL products, there are different possibilities to support retain/persistent variables or persistent storage of information/variables.
"Classic" Retains:
1) Store Retains in File
2) Store Retains in special memory (e.g. SRAM / NVRAM...)
3) Store Retains in shared memory
Besides this, it is also possible to use other features of CODESYS to better fulfill your needs, as they provide a higher level of persistence that we highly recommend:
- Recipe Management
https://help.codesys.com/webapp/_cds_using_recipes;product=codesys;version=3.5.17.0 - Persistence Manager
https://help.codesys.com/webapp/f_application_composer_persistence_manager;product=core_Application_Composer;version=3.5.17.0
1) Store Retains in File
The runtime requires either a proper shutdown to stop the application and then stores the retain variables in a file, or you can also trigger the storage manually inside the IEC application via the IEC library "CmpApp" → "AppStoreRetainsInFile"
Pro:
- Easy to configure (is default)
- No special memory/HW required
- Single data consistency: ok (if finished properly/graceful shutdown) or perfect if manually triggered inside your IEC application
Con:
- Processing time might be long
- No "logical" consistency possible, except you trigger the "storage" by yourself: see "CmpApp" → AppStoreRetainsInFile() library function!
Configuration:
Nothing to do, as this is the default!
2) Store Retains in special memory
You can configure the runtime via the cfg File (CODESYSControl.cfg) so that it directly uses a given memory (e.g. physically mapped).
Pro:
- Easy to configure
- Processing time fast
IEC Code directly accesses the retain variables inside the special memory - Single data consistency (for standard datatypes smaller or equal the architecture size (e.g. 32 bits)) ok
- no further "glue code" required for storage
Con:
- Single data consistency (for data bigger than architecture size (e.g. 32 bits)): no guarantee possible
- Special memory/HW required (Kerneldriver etc.)
- No "logical" consistency possible
Configuration:
[CmpApp] RetainType.Application=InSRAM [CmpRetain] Retain.SRAM.Size=0x.... Retain.SRAM.AddressMapped= -> in case you have a mapped address or: Retain.SRAM.Address= -> in case you have a physical address
3) Store Retains in shared memory
You can configure the runtime via the cfg File (CODESYSControl.cfg) so that it uses a shared memory memory. Then you can easily adapt to whatever "real" retain storage you have.
See also the following help page:
Pro:
- Easy to configure
- Processing time fast
- No special memory/HW required, but is possible
Con:
- Single data consistency: no guarantee possible
- A bit of "glue code" is required to put the retains from shared memory to whatever real retain storage you have.
Configuration:
[CmpApp] RetainType.Application=InSHM [CmpRetain] Retain.SHM.Size=0x.... Retain.SHM.Name= -> Filename of the shared memory to use
See also....
- Our Codesys Online Help (OLH) Website
- Basic information to the Codesys Development System (Codesys Homepage)
- OLH:General details about 'Data Persistence' and Preserving Data with Persistent Variables
- OLH: The Online-help introduction for the Codesys Development System (IDE)
- OLH: For the CODESYS Control for Linux SL Add-on