Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

VAR PERSISTENT RETAIN and how to shud down RPI

mbruck
2017-08-07
2017-08-08
  • mbruck - 2017-08-07

    From here :
    l viewtopic.php?t=5722&start=30#p17138 l

    There is statement:

    Zitat:
    It works with a normal shutdown, but with a failure not.

    and

    Zitat:
    ...if you want to use the "VAR PERSISTENT RETAIN" with the Pi and a have reliable solution
    then a UPS is a must have!

    So, I have an UPS, but I'd like to shutdown my mashine and RPI after that. As I understund it is posible to retain persistent variables if normal shutdown is afected.
    My question is it possible to shutdown RPI from program ?

     
  • johan76swart - 2017-08-08

    Hi mbruck,

    Yes it is possible to shutdown the pi form the program. See my example below.

    First you will need to import the SysProcess library in the library manager.
    Second add these two variables in the variable editor.

    Result: RTS_IEC_RESULT;
    command1: STRING(1000);
    

    Then in the editor add these lines:

    You can replace the command1 variable with 'sudo reboot' for a reboot.

    You can even use it to run a python script in the background.
    Nice and simple

    Best Regards,

    Johan

    IMG: shutdown.png

     
  • teichhei - 2017-08-08

    That's cool. Is there any other cool stuff like setting up Raspi Ethernet IP and gateway?
    There is another good way to kind of deal with retains. When I have retains in the form of settings that don't change all the time, I write the retain file off to disk on change. And restore on a reboot. It's a problem though when the pi has to deal with frequently changing stuff like metering pulses.

    Sent from my SM-G935F using Tapatalk

     

Log in to post a comment.