Unable to get retain variables to work in a specific Raspberry Pi project

brentkk
2019-11-24
2019-12-03
  • brentkk - 2019-11-24

    Hi,
    I have a Raspberry Pi Project which I am trying to test - however the retain variables do not seem to be working. I have read through the whole topic l viewtopic.php?f=21&t=5722&start=30#p20093 l , and according to the post below - If i run "sudo reboot now" - the variables set as RETAIN, should be retained after restart and I should see a file called Application.ret in the folder: /var/opt/codesys/PlcLogic/Application. The .ret file is not created and my variables set for RETAIN are reset to 0. If I create a new blank project with just one RETAIN variable - the file described above is created and the variable value is retained after performing the same sudo reboot.
    One point to note is that my Codesys runtime is not yet licensed, as I am still testing to see if this is what I will use - could this be the issue?
    Is anybody able to help with this? If necessary I can post a copy of the project (It is a modified copy of ths: https://github.com/MichielVanwelsenaere ... n.CoDeSys3).

    Edwin Schwellinger hat geschrieben:
    Hi,
    beside the bootproject
    runtime Directory
    /PlcLogic/Application/
    for the the Pi this:
    /var/opt/codesys/PlcLogic/Application
    Application.app
    Application.crc

     
  • eschwellinger

    eschwellinger - 2019-11-25

    Hi,
    which versions are involved? ( runtime and CODESYS)
    Could you check if there is any exception while shutdown - caused by this application?
    Check the logger either by
    tail -f /tmp/codesyscontrol.log

    BR
    Edwin

     
  • brentkk - 2019-11-25

    I am running CODESYS 3.5 SP15 Patch 1 and the "Target version" (shown when I connect) is 3.5.15.10.
    Below is the output of the log:

    2019-11-25T21:24:48Z, 0x00000002, 2, 1288, 49, !!!! Warning: Retain data are initialized now of [<app>HomeAutomation</app>]
    2019-11-25T21:24:48Z, 0x00000002, 1, 0, 2, Application [<app>HomeAutomation</app>] loaded via [Bootproject]
    2019-11-25T21:24:48Z, 0x00000126, 1, 0, 0, Valid license found for OPC UA IecVarAccess provider.
    2019-11-25T21:24:48Z, 0x00000002, 1, 0, 7, Retains matched to bootproject of application [<app>HomeAutomation</app>]
    2019-11-25T21:24:48Z, 0x00000002, 1, 0, 6, Bootproject of application [<app>HomeAutomation</app>] loaded
    2019-11-25T21:24:48Z, 0x00000018, 1, 0, 1, Setting router <instance>0</instance> address to <address>(006b)</address>
    2019-11-25T21:24:48Z, 0x00000018, 1, 0, 1, Setting router <instance>1</instance> address to <address>(2ddc:c0a8:156b)</address>
    2019-11-25T21:24:48Z, 0x00000002, 1, 0, 10, Application [<app>HomeAutomation</app>] started
    2019-11-25T21:24:48Z, 0x00000001, 1, 0, 34, CODESYS Control ready
    2019-11-25T21:27:00Z, 0x00000001, 2, 0, 0, !!!! Warning: no runtime license - running in demo mode(~119 minutes)
    

    Thanks

     
  • eschwellinger

    eschwellinger - 2019-11-26

    Hi,
    we need your log while you are stoping/quit the runtime.... this snippet is the the restart of it.
    I expect that there will be an application related exception which prevents the save of the retains.
    BR
    Edwin

     
  • brentkk - 2019-11-27

    Hi Edwin,

    There is no error in the log when I stop the service or when I restart the service manually:
    I tried starting and stopping the service several times - there are no additional lines to the log after stopping the service.

    pi@CodesysPi:~ $ sudo service codesyscontrol start
    pi@CodesysPi:~ $ tail -f /tmp/codesyscontrol.log
    2019-11-27T04:18:56Z, 0x00000002, 2, 1288, 49, !!!! Warning: Retain data are initialized now of [<app>HomeAutomation</app>]
    2019-11-27T04:18:56Z, 0x00000002, 1, 0, 2, Application [<app>HomeAutomation</app>] loaded via [Bootproject]
    2019-11-27T04:18:56Z, 0x00000126, 1, 0, 0, Valid license found for OPC UA IecVarAccess provider.
    2019-11-27T04:18:56Z, 0x00000002, 1, 0, 7, Retains matched to bootproject of application [<app>HomeAutomation</app>]
    2019-11-27T04:18:56Z, 0x00000002, 1, 0, 6, Bootproject of application [<app>HomeAutomation</app>] loaded
    2019-11-27T04:18:56Z, 0x00000018, 1, 0, 1, Setting router <instance>0</instance> address to <address>(006b)</address>
    2019-11-27T04:18:56Z, 0x00000018, 1, 0, 1, Setting router <instance>1</instance> address to <address>(2ddc:c0a8:156b)</address>
    2019-11-27T04:18:56Z, 0x00000002, 1, 0, 10, Application [<app>HomeAutomation</app>] started
    2019-11-27T04:18:56Z, 0x00000001, 1, 0, 34, CODESYS Control ready
    2019-11-27T04:19:58Z, 0x00000001, 2, 0, 0, !!!! Warning: no runtime license - running in demo mode(~119 minutes)
    ^C
    pi@CodesysPi:~ $ sudo service codesyscontrol stop
    pi@CodesysP
    pi@CodesysPi:~ $ tail -f /tmp/codesyscontrol.log
    2019-11-27T04:18:56Z, 0x00000002, 2, 1288, 49, !!!! Warning: Retain data are initialized now of [<app>HomeAutomation</app>]
    2019-11-27T04:18:56Z, 0x00000002, 1, 0, 2, Application [<app>HomeAutomation</app>] loaded via [Bootproject]
    2019-11-27T04:18:56Z, 0x00000126, 1, 0, 0, Valid license found for OPC UA IecVarAccess provider.
    2019-11-27T04:18:56Z, 0x00000002, 1, 0, 7, Retains matched to bootproject of application [<app>HomeAutomation</app>]
    2019-11-27T04:18:56Z, 0x00000002, 1, 0, 6, Bootproject of application [<app>HomeAutomation</app>] loaded
    2019-11-27T04:18:56Z, 0x00000018, 1, 0, 1, Setting router <instance>0</instance> address to <address>(006b)</address>
    2019-11-27T04:18:56Z, 0x00000018, 1, 0, 1, Setting router <instance>1</instance> address to <address>(2ddc:c0a8:156b)</address>
    2019-11-27T04:18:56Z, 0x00000002, 1, 0, 10, Application [<app>HomeAutomation</app>] started
    2019-11-27T04:18:56Z, 0x00000001, 1, 0, 34, CODESYS Control ready
    2019-11-27T04:19:58Z, 0x00000001, 2, 0, 0, !!!! Warning: no runtime license - running in demo mode(~119 minutes)
    

    Only an error regarding retain restore when rebooting the pi:

    pi@CodesysPi:~ $ sudo reboot now
    pi@CodesysPi:~ $ tail -f /tmp/codesyscontrol.log
    2019-11-27T04:23:31Z, 0x00000002, 4, 16, 40, **** ERROR: Retain restore from file failed: [<app>HomeAutomation</app>], area=<area>2</area>, size=<size>4096</size>, type=<type>0x0120</t
    2019-11-27T04:23:31Z, 0x00000002, 2, 1288, 49, !!!! Warning: Retain data are initialized now of [<app>HomeAutomation</app>]
    2019-11-27T04:23:32Z, 0x00000002, 1, 0, 2, Application [<app>HomeAutomation</app>] loaded via [Bootproject]
    2019-11-27T04:23:32Z, 0x00000126, 1, 0, 0, Valid license found for OPC UA IecVarAccess provider.
    2019-11-27T04:23:32Z, 0x00000002, 1, 0, 7, Retains matched to bootproject of application [<app>HomeAutomation</app>]
    2019-11-27T04:23:32Z, 0x00000002, 1, 0, 6, Bootproject of application [<app>HomeAutomation</app>] loaded
    2019-11-27T04:23:32Z, 0x00000018, 1, 0, 1, Setting router <instance>0</instance> address to <address>(006b)</address>
    2019-11-27T04:23:32Z, 0x00000018, 1, 0, 1, Setting router <instance>1</instance> address to <address>(2ddc:c0a8:156b)</address>
    2019-11-27T04:23:32Z, 0x00000002, 1, 0, 10, Application [<app>HomeAutomation</app>] started
    2019-11-27T04:23:32Z, 0x00000001, 1, 0, 34, CODESYS Control ready
    

    Here is a link to an archive of the project in case that helps:
    https://1drv.ms/u/s!AuoLjdHk1C3_hJxObMynRYwrdtMxgA?e=fBXAuI

     
  • brentkk - 2019-11-27

    Just did a bit more testing:
    If I run the command "saveretains" (with PLC in stop) in the PLC Shell / Device tab, the retain file /var/opt/codesys/PlcLogic/HomeAutomation/HomeAutomation.ret is created successfully. If I reboot the Pi or stop / start the CODESYS service, the values from this snapshot are reloaded.
    If I change any of the retain values and then reboot the Pi - a new version of the retain file is not created or updated, and the previous / old values are restored. No errors appear in the log regarding writing retain values.

    Still no closer to a solution ...

     
  • brentkk - 2019-12-03

    Hi Edwin - do you have any idea why this isn't working or any further steps I can take to troubleshoot it?

     
  • eschwellinger

    eschwellinger - 2019-12-03

    Hi,
    we see an exception caused by this retain vairiables declared in an fb.
    It is still under investigation, no solution at the moment.
    The workaround would be to use persistence manager instead of retains variables.

    BR
    Edwin

     

Log in to post a comment.