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

Turn off raspberry

bisquit
2018-05-18
2022-07-05
  • bisquit - 2018-05-18

    Good morning,

    I'm pretty new to codesys and the programming side of raspberry.

    I'm trying to power off my raspberry using my HMI.
    I've found some other examples, but I couldnt get them to work:

    l viewtopic.php?t=8638 l - Keep getting syntax errors
    l viewtopic.php?f=21&t=5714 l - No errors, it just doesnt power off

    I'm using ladder logic to program the raspberry.

    Can somebody explain how to do it?

     
  • pawel3410 - 2018-05-20

    http://forum.codesys.com/viewtopic.php?f=23&t=6247&p=12699#p12699

    I use this:

    PROGRAM power
    VAR
       Result: UDINT;
    END_VAR
    IF GlobalVariables.resetFromVISU THEN
       GlobalVariables.power_led := FALSE;
       _ (pszComand:='sudo reboot' , pResult:= ADR(Result));
    END_IF
    IF GlobalVariables.poweroffFromVISU THEN
       GlobalVariables.power_led := FALSE;
       _ (pszComand:='sudo poweroff' , pResult:= ADR(Result));
    END_IF
    

    and

    [SysProcess]
    Command=AllowAll
    

    in CODESYSControl_User.cfg file
    I hope this will help.

    When I write in code syntax SysProcess_Execute_Command after submit I see only "_" why?

    IMG: Bez tytułu.jpg

     
  • bisquit - 2018-05-22

    pawel3410 hat geschrieben:
    http://forum.codesys.com/viewtopic.php?f=23&t=6247&p=12699#p12699
    I use this:

    PROGRAM power
    VAR
       Result: UDINT;
    END_VAR
    IF GlobalVariables.resetFromVISU THEN
       GlobalVariables.power_led := FALSE;
       _ (pszComand:='sudo reboot' , pResult:= ADR(Result));
    END_IF
    IF GlobalVariables.poweroffFromVISU THEN
       GlobalVariables.power_led := FALSE;
       _ (pszComand:='sudo poweroff' , pResult:= ADR(Result));
    END_IF
    

    and

    [SysProcess]
    Command=AllowAll
    

    in CODESYSControl_User.cfg file
    I hope this will help.
    When I write in code syntax SysProcess_Execute_Command after submit I see only "_" why?

    I've got it all working now.

    Thank you for your help!

     
  • kleeswi - 2022-07-05

    For me this does not work. I think my Raspberry Pi does restart, but not Codesys. I even cannot access the Pi via ssh or other remote communication protocols! I have to reconfigure the SD card of the Pi that it works again.

    I use this command and SysProcess is as above:

    SysProcess.SysProcessExecuteCommand2(pszCommand:='sudo reboot', pszStdOut:=stdout, udiStdOutLen:=31 , pResult:=0 );
    
     

    Last edit: kleeswi 2022-07-05
  • eschwellinger

    eschwellinger - 2022-07-05

    remove the sudo!

     

Log in to post a comment.