In the past, I use a SD card with Rpi3B and a code to save persistents variables on files with a button and automatically restore persistents at boot.
fbDelete : FILE.Delete; (* bloc pour effacer le contenu du fichier *)
sFileName : STRING := 'data.ret';
pApp : POINTER TO APPLICATION;
Result : RTS_IEC_RESULT;
xInit : BOOL;
//CmpApp + CAA File + SysTypes Interfaces
IF NOT xInit THEN
pApp := AppGetCurrent(pResult:=ADR(Result));
xInit := TRUE;
IF SAUVEGARDER=TRUE AND NOT RESTORE THEN
(* En premier effacer le fichier.
car la fonction AppStoreRetainsInFile ajoute les données à la suite du fichier. *)
IF fbDelete.xDone OR (fbDelete.xError AND fbDelete.eError = File.Error.NOT_EXIST) THEN
(* enregister. *)
IF pApp <> 0 THEN
Result := AppStoreRetainsInFile(pApp,sFileName);
(* Restaurer les data depuis le fichier.*)
IF RESTORE THEN
Result := AppRestoreRetainsFromFile(pApp, sFileName);
RESTORE := FALSE;
It work fines and I use same code to make backup/restore on USB card.
Now, Rpi work on SSD , not yet on SD. I use other method for persistents on SSD : "persistence manager". How to here: https://forge.codesys.com/forum/en/4275/genmed-How%20to%20Setup%20the%20PersistenceManager%20from%20Scratch.pdf
This method work well, but I would like to make additionnal backup and restore to USB card, but with the old method, persistents aren't restore and I'm not sure backup files was good....
Persitents variables are still in "persistentVars". I add this before each variables:
Could you help me?
to me your code looks good. I think I didn't get the question. Your approach should work independently of the filesystem that is used, right!?
persistence manager is a special librairy to save persistance variables .
If I use this code to do a backup files on usb key(security) : creation work and I don't not if files containe good value and restore doesn't work.
The files is store on path /PlcLogic/ac_perstitence. I could make copy on usb key but how to restore it after ? If I write it on /PlcLogic/ac_perstitence it should be work ? Any command to activate to load this files on memory ?
Log in to post a comment.