<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Codesys runtime on Rpi and using a python script</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/44bee4d8ad/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Engineering/thread/44bee4d8ad/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Engineering/thread/44bee4d8ad/</id><updated>2022-02-18T12:10:17.551000Z</updated><subtitle>Recent posts to Codesys runtime on Rpi and using a python script</subtitle><entry><title>Codesys runtime on Rpi and using a python script</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/44bee4d8ad/?limit=25#8771/3203" rel="alternate"/><published>2022-02-18T12:10:17.551000Z</published><updated>2022-02-18T12:10:17.551000Z</updated><author><name>ramas</name><uri>https://forge.codesys.com/u/ramas/</uri></author><id>https://forge.codesys.com9ead36e523d9bb25e5ce43b3b2f9ad1ab4876352</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Yes thank you hapeter that was the problem, I am relatively new to codesys hence the rather amateur questions.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Codesys runtime on Rpi and using a python script</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/44bee4d8ad/?limit=25#8e54/c0d6" rel="alternate"/><published>2022-02-18T12:09:03.842000Z</published><updated>2022-02-18T12:09:03.842000Z</updated><author><name>ramas</name><uri>https://forge.codesys.com/u/ramas/</uri></author><id>https://forge.codesys.come7a5b8cf888c6392729a0d90a5e2c20130d48a5f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thank you but that did not work. SysFile.SysFileCopy is being called as a function, i can see it in the Call tree but the file is not being copied into the directory. I wonder why&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Codesys runtime on Rpi and using a python script</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/44bee4d8ad/?limit=25#8771" rel="alternate"/><published>2022-02-18T11:03:13.572000Z</published><updated>2022-02-18T11:03:13.572000Z</updated><author><name>hapeter</name><uri>https://forge.codesys.com/u/hapeter/</uri></author><id>https://forge.codesys.coma85304c136caa6fd0f246292b514ce7ecc57b5c0</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;sometimes we have to clean our glasses ;-) In the CODESYS Development System there are two Windows, one for declaring the variables, one for the programcode. The later is minimized in your screenshot below the line 48, I can only see one line with the red "1". Move your programcode in this window and the red underlining should disapear.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Codesys runtime on Rpi and using a python script</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/44bee4d8ad/?limit=25#8e54/7b22" rel="alternate"/><published>2022-02-18T09:33:03.205000Z</published><updated>2022-02-18T09:33:03.205000Z</updated><author><name>ramas</name><uri>https://forge.codesys.com/u/ramas/</uri></author><id>https://forge.codesys.com83352834fe1468960a3ddf116a4b948421e2f6e0</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thank you for the feedback i will try it without sudo!, But i think there is something wrong with the code in itself. Which would explain why there are red lines as you can see in the attachment "POU.png".&lt;br/&gt;
&lt;img src="./attachment/attachment.png" width="50%"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Codesys runtime on Rpi and using a python script</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/44bee4d8ad/?limit=25#8e54/a2fd" rel="alternate"/><published>2022-02-18T09:32:59.933000Z</published><updated>2022-02-18T09:32:59.933000Z</updated><author><name>ramas</name><uri>https://forge.codesys.com/u/ramas/</uri></author><id>https://forge.codesys.comed29ca413cd62d13f64bc577eed066a5b181e07e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thank you for the feedback i will try it without sudo!, But i think there is something wrong with the code in itself. Which would explain why there are red lines as you can see in the attachment "POU.png".&lt;br/&gt;
&lt;img src="./attachment/attachment.png" width="50%"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Codesys runtime on Rpi and using a python script</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/44bee4d8ad/?limit=25#8e54" rel="alternate"/><published>2022-02-17T18:00:08.712000Z</published><updated>2022-02-17T18:00:08.712000Z</updated><author><name>eschwellinger</name><uri>https://forge.codesys.com/u/eschwellinger/</uri></author><id>https://forge.codesys.comf59aa43f07dc790110e952e0aee218742ec63e3a</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;call it witout sudo!&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Codesys runtime on Rpi and using a python script</title><link href="https://forge.codesys.com/forge/talk/Engineering/thread/44bee4d8ad/?limit=25#8fc3" rel="alternate"/><published>2022-02-17T12:55:57.645000Z</published><updated>2022-02-17T12:55:57.645000Z</updated><author><name>ramas</name><uri>https://forge.codesys.com/u/ramas/</uri></author><id>https://forge.codesys.com5f7ce32d8fb73862549c2a0d9d1f8f734ce4bdc4</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hey guys so I am trying to run a python script during codesys runtime but i am getting a lot of errors in the POU, there are red underlines, I do not understand what i am doing wrong here.&lt;br/&gt;
I have added the necessary libraries to run python while codesys runtime and followed the necessary steps, The python file should be copied into &lt;em&gt;/var/opt/codesys&lt;/em&gt; and there is a log file that will also be created to log in the current time. However there seems to be a problem with my POU or the libraries are not syncing or something.&lt;/p&gt;
&lt;p&gt;If i could get some help form you guys that would be much appreciated:&lt;br/&gt;
Here is the code:&lt;/p&gt;
&lt;p&gt;PROGRAM _PythonExecute&lt;br/&gt;
VAR&lt;br/&gt;
    dwCopySize: DWORD;&lt;br/&gt;
    dutResult : RTS_IEC_RESULT;&lt;br/&gt;
    szCommand : STRING(200);&lt;br/&gt;
    fbTimer : TON;&lt;br/&gt;
    szStdOout : STRING(1000);&lt;br/&gt;
    fbTimer1 : TON;&lt;br/&gt;
    Command : STRING(200);&lt;br/&gt;
END_VAR&lt;/p&gt;
&lt;p&gt;(&lt;em&gt;&lt;br/&gt;
   /etc/CODESYSControl.cfg:&lt;br/&gt;
&lt;span&gt;&lt;span&gt;[SysProcess]&lt;/span&gt;&lt;/span&gt;&lt;br/&gt;
   Command=AllowAll &lt;br/&gt;
&lt;/em&gt;)&lt;/p&gt;
&lt;p&gt;IF NOT GVL.init THEN&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nt"&gt;Copy&lt;/span&gt; &lt;span class="nt"&gt;the&lt;/span&gt; &lt;span class="nt"&gt;scripts&lt;/span&gt; &lt;span class="nt"&gt;to&lt;/span&gt; &lt;span class="nt"&gt;local&lt;/span&gt;
&lt;span class="nt"&gt;SysFile&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SysFileCopy&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/var/opt/codesys/hallo.py'&lt;/span&gt;
                    &lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="s1"&gt;'/var/opt/codesys/PlcLogic/Application/hallo.py'&lt;/span&gt;
                    &lt;span class="o"&gt;,&lt;/span&gt;&lt;span class="nt"&gt;ADR&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;dwCopySize&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;


&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nt"&gt;Change&lt;/span&gt; &lt;span class="nt"&gt;the&lt;/span&gt; &lt;span class="nt"&gt;permission&lt;/span&gt; &lt;span class="nt"&gt;that&lt;/span&gt; &lt;span class="nt"&gt;can&lt;/span&gt; &lt;span class="nt"&gt;execute&lt;/span&gt;
&lt;span class="nt"&gt;SysProcess_Implementation&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;SysProcessExecuteCommand2&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;pszCommand&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="s1"&gt;'chmod +x *.py'&lt;/span&gt;
                                                    &lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;pszStdOut&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;szStdOout&lt;/span&gt;
                                                    &lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;udiStdOutLen&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;SIZEOF&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;szStdOout&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                                                    &lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;pResult&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;ADR&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;dutResult&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;

&lt;span class="o"&gt;//&lt;/span&gt;&lt;span class="nt"&gt;Init&lt;/span&gt; &lt;span class="nt"&gt;is&lt;/span&gt; &lt;span class="nt"&gt;finished&lt;/span&gt;
&lt;span class="nt"&gt;GVL&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;init&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt;&lt;span class="nt"&gt;TRUE&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;END_IF&lt;/p&gt;
&lt;p&gt;//Flash Timer&lt;br/&gt;
fbTimer1(IN:= TRUE, PT:=T#1S); &lt;/p&gt;
&lt;p&gt;//Command &lt;br/&gt;
Command:= 'sudo python hallo.py';&lt;/p&gt;
&lt;p&gt;//Timer is ON&lt;br/&gt;
IF fbTimer1.Q  THEN&lt;br/&gt;
        //Reset it and flash again&lt;br/&gt;
        fbTimer1(IN:= FALSE);&lt;br/&gt;
        //Execute&lt;br/&gt;
        SysProcess.SysProcessExecuteCommand2(pszCommand:=Command&lt;br/&gt;
                                            , pszStdOut:=szStdOout&lt;br/&gt;
                                            , udiStdOutLen:= SIZEOF(szStdOout)&lt;br/&gt;
                                            , pResult := ADR(dutResult));&lt;br/&gt;
END_IF&lt;/p&gt;
&lt;p&gt;Could someone please tell me what I am doing wrong here.&lt;br/&gt;
&lt;img src="./attachment/POU.png" width="50%"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>