Execute executable program

elsabz
2020-08-09
2020-08-17
  • elsabz - 2020-08-09

    Hello,

    on raspberrypi 4 I would like to run a program written in C by launching it from the codesys runtime project.
    The compiled program launched from the terminal works correctly.
    I use the command:

    sudo /home/pi/Documents/c-plain/shm/shm
    

    I add at the bottom in the file /etc/CODESYSControl.cfg and /etc/CODESYSControl_User.cfg

    [SysProcess]
    Command=AllowAll
    

    Then i program this code

    PROGRAM SysCom
    VAR
        command1 : STRING := 'sudo /home/pi/Documents/c-plain/shm/shm';
        stdout : STRING(1000) := '';    
        Result : RTS_IEC_RESULT;
        xExecuteSysP: BOOL;
    
    END_VAR
    
    IF xExecuteSysP THEN
        SysProcess.SysProcessExecuteCommand2(pszCommand:=command1, pszStdOut:=stdout, udiStdOutLen:= SIZEOF(stdout),pResult := ADR(Result));
        xExecuteSysP := FALSE;
    END_IF
    

    The SysCom program is called cyclically.
    When it works in runtime, setting TRUE the

    xExecuteSysP
    

    var, nothing happens, the program is not executed.

    Why doesn't it work?

     

    Last edit: elsabz 2020-08-09
  • eschwellinger

    eschwellinger - 2020-08-11

    try to call without sudo..

     
  • elsabz - 2020-08-17

    yes it works, thanks.

     

Log in to post a comment.