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

Webvisu inkl. Rasp-PI herunterfahren

akneer
2016-03-29
2016-03-31
  • akneer - 2016-03-29

    Hallo,

    Ich möchte gerne aus einer Webvisualisierung den Raspberry ausschalten (herrunterfahren).

    1. Ist dies möglich ?

    2. Funktioniert dann dieser Befehlssatz auch bei Windowssystemen ???

    Gruß

     
  • eschwellinger

    eschwellinger - 2016-03-30

    Hi,

    1) hier in der FAQ Section dieses Beispiel abändern und einen 'shutdown -h now' aufrufen:
    http://forum.codesys.com/viewtopic.php? ... 699#p12711
    2) ja das würde auch unter Windows gehen.
    Grüße
    Edwin

     
  • akneer - 2016-03-31

    Hallo,

    Habe es geschafft....

    Das einzige was ich noch nicht ganz weiss ist der Wert 'pszStdOut' und 'udiStdOutLen'

    PROGRAM ShutDown
    VAR
       xStartProc      : BOOL;
       stdout       : STRING(1000) := '';   
       udiError      : UDINT;
    END_VAR
    
    (* start an external process on target *)
    // Important entry in LINUX:    '/etc/CODESYSControl.cfg'
    //          
    //         [SysProcess]                              
    //         Command=AllowAll
    IF xStartProc THEN
       xStartProc := FALSE;
       SysProcess ExecuteCommand2 (pszCommand:='/home/pi/ShutDown.sh',
                                  pszStdOut:=stdout,
                                  udiStdOutLen:= SIZEOF(stdout),
                                  pResult := ADR(udiError));
    END_IF
    
    (*
    ShutDown.sh:
    \#!/bin/bash
    sudo shutdown -h now
    *)
    
     
  • Anonymous - 2016-03-31

    Originally created by: PI-Beginner

    Hallo,
    auch ein Interessanter Weg.
    Hab es mir etwas einfacher gemacht und den Linuxbefehl direkt in eine Variable gepackt.:

    command1:='shutdown -h 0';
    IF xExecuteSysP THEN
       xExecuteSysP := FALSE;
       SysProcess._(pszCommand:=command1, pszStdOut:=stdout, udiStdOutLen:= SIZEOF(stdout),pResult := ADR(Result));
    END_IF
    

    Die Rückgabe von 'pszStdOut' und 'udiStdOutLen' ist bei einem shutdown nicht wichtig. Ausser natürlich bei anderen Skripten die einen Wert zurückliefern.

    Gruß
    Jan

     
  • akneer - 2016-03-31

    Perfekt.

    Hab es auf dein smartes Programm abgeändert. TOP Danke.

    Funktioniert "shutdown -h 0" auch bei Windows ???

     

Log in to post a comment.