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

Screenshot with "Sys Process Execute Command"

m4d0c
2016-08-15
2016-08-17
  • m4d0c - 2016-08-15

    Hello together,

    I am having a problem with starting a script via CODESYS. My goal is to create a screenshot via a button click or via an input. For doing this I am using the
    "Sys Process Execute Command" command (no spaces of course, but it screws up the layout somehow). I altered the CODESYSControl.cfg to

    [SysProcess]
    Command=AllowAll
    

    and I created a script named takeScreenshot which looks like:

    \#!/bin/sh
    DISPLAY=:0 scrot -d 1 'screenshot.png'
    

    I made it executable with

    sudo chmod +x /usr/bin/takeScreenshot
    

    Finally I tested the script with typing ```

    takeScreenshot

    ``` in the terminal and it works like a charm.

    So I started to implement the command in Codesys like this:

    IF take_Screenshot AND NOT take_Screenshot_old THEN
    Β  Β sCommand := 'takeScreenshot';
    Β  Β SysProcess.Sys Process Execute Command(sCommand, ADR(Result));
    END_IF
    take_Screenshot_old:=take_Screenshot;
    

    Now the problem: It does not work
    As a result I get "0" and no screenshot. But if I am trying another command like "reboot" or "ifdown" it works without any problems. I dont have a clue. Can someone help?

    Thanks and Greetings
    Andy

     
  • rickj - 2016-08-16

    You could pipe the console output to a file and see what turns up. Perhaps something like this

    IF take_Screenshot AND NOT take_Screenshot_old THEN
    Β  Β sCommand := 'takeScreenshot >> log.txt';
    Β  Β SysProcess.Sys Process Execute Command(sCommand, ADR(Result));
    END_IF
    
     
  • m4d0c - 2016-08-17

    Hi Rick,

    thank you for your reply.
    Unfortunatly the command is not executed by the Raspberry Pi (unlike a reboot command or similar). So no log is being created. Although it works when I am typing the exact same command in the Raspi terminal.

    Greetings
    Andreas

    IMG: ScreenshotCommand.JPG

     
  • m4d0c - 2016-08-17

    In the Codesys Log (cat /tmp/codesyscontrol.log) I get the following message

    I tried to use "" as sCommand as well with the same result.

    IMG: CODESYS Log.JPG

     

Log in to post a comment.