<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Execute external Phyton script with GPIO pin, PLC function ?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/89f30635f9/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Runtime/thread/89f30635f9/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Runtime/thread/89f30635f9/</id><updated>2020-02-27T17:05:46.158000Z</updated><subtitle>Recent posts to Execute external Phyton script with GPIO pin, PLC function ?</subtitle><entry><title>Execute external Phyton script with GPIO pin, PLC function ?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/89f30635f9/?limit=25#7eab" rel="alternate"/><published>2020-02-27T17:05:46.158000Z</published><updated>2020-02-27T17:05:46.158000Z</updated><author><name>jinx</name><uri>https://forge.codesys.com/u/jinx/</uri></author><id>https://forge.codesys.com285bdc8b91433f1190ee066939cd4e31e1a92a19</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi Edwin,&lt;br/&gt;
I finnaly got it working!&lt;br/&gt;
I had to give the full path to run scripts!&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;xRisingTrigger&lt;/span&gt;.&lt;span class="nv"&gt;Q&lt;/span&gt;  &lt;span class="k"&gt;THEN&lt;/span&gt; 
   &lt;span class="nv"&gt;_&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;python /usr/bin/GPIO27_ON.py&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;,&lt;span class="nv"&gt;ADR&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Result&lt;/span&gt;&lt;span class="ss"&gt;))&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;END_IF&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Thank you!&lt;br/&gt;
BR, Gregor&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Execute external Phyton script with GPIO pin, PLC function ?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/89f30635f9/?limit=25#b19b" rel="alternate"/><published>2020-02-27T17:05:45.103000Z</published><updated>2020-02-27T17:05:45.103000Z</updated><author><name>eschwellinger</name><uri>https://forge.codesys.com/u/eschwellinger/</uri></author><id>https://forge.codesys.com781c735747e691dcc5114719c734732af474fdb6</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Change the config file to:&lt;/p&gt;
&lt;p&gt;&lt;span&gt;[SysProcess]&lt;/span&gt;&lt;br/&gt;
Command.0=shutdown&lt;br/&gt;
Command.1=python&lt;/p&gt;
&lt;p&gt;(after doing this a restart of the runtime is needed)&lt;/p&gt;
&lt;p&gt;and then call in CODESYS&lt;br/&gt;
Sys..Process...ExecuteC..('python GPIO27_ON.py',ADR(Result));&lt;br/&gt;
BR&lt;br/&gt;
Edwin&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: executepython.jpg" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=1112"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Execute external Phyton script with GPIO pin, PLC function ?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/89f30635f9/?limit=25#e8f8" rel="alternate"/><published>2020-02-27T17:05:43.910000Z</published><updated>2020-02-27T17:05:43.910000Z</updated><author><name>jinx</name><uri>https://forge.codesys.com/u/jinx/</uri></author><id>https://forge.codesys.com068c7eb263b6494391cfff48a81883ca898c210e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Running script...&lt;/p&gt;
&lt;p&gt;BR,&lt;br/&gt;
 Gregor&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: trying to run script.jpg" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=1111"/&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Execute external Phyton script with GPIO pin, PLC function ?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/89f30635f9/?limit=25#0a27" rel="alternate"/><published>2020-02-27T17:05:41.034000Z</published><updated>2020-02-27T17:05:41.034000Z</updated><author><name>jinx</name><uri>https://forge.codesys.com/u/jinx/</uri></author><id>https://forge.codesys.com0060482ad473054659aa5b30a334889fcc336915</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi Edwin,&lt;br/&gt;
attached is CODESYSControl.cfg (I had to rename it to .txt because forum doesn't allow .cfg files to be uploaded).&lt;br/&gt;
There is no duplicate.&lt;/p&gt;
&lt;p&gt;Could this be a problem with ROOT privilege to run python scripts?&lt;/p&gt;
&lt;p&gt;BR,&lt;br/&gt;
Gregor&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="https://forum.codesys.com//download/file.php?id=1110" rel="nofollow"&gt;CODESYSControl.txt &lt;span&gt;&lt;span&gt;[1.04 KiB]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Execute external Phyton script with GPIO pin, PLC function ?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/89f30635f9/?limit=25#ef3d" rel="alternate"/><published>2020-02-27T17:05:40.053000Z</published><updated>2020-02-27T17:05:40.053000Z</updated><author><name>eschwellinger</name><uri>https://forge.codesys.com/u/eschwellinger/</uri></author><id>https://forge.codesys.com7baee45be260358ec38e74adf873836a6a2bc8f3</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;br/&gt;
could not really se the problem at the moment&lt;br/&gt;
could you please upload the CODESYSControl.cfg .. (check if there is a dublicate entry of the SysProcess section)&lt;/p&gt;
&lt;p&gt;Error 25 means: &lt;br/&gt;
define ERR_NO_ACCESS_RIGHTS 0x0019  /&lt;em&gt; No access rights for this operation &lt;/em&gt;/&lt;/p&gt;
&lt;p&gt;BR&lt;br/&gt;
Edwin&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Execute external Phyton script with GPIO pin, PLC function ?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/89f30635f9/?limit=25#8469" rel="alternate"/><published>2020-02-27T17:05:37.363000Z</published><updated>2020-02-27T17:05:37.363000Z</updated><author><name>jinx</name><uri>https://forge.codesys.com/u/jinx/</uri></author><id>https://forge.codesys.com36719cf47b20af908c6e6714798ba01258a435a6</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi Edwin,&lt;br/&gt;
thank you for your answer.&lt;/p&gt;
&lt;p&gt;I managed to install libraries: "SysProcess 3.5.5.0" and "SysTypes2 Interfaces".&lt;/p&gt;
&lt;p&gt;I am a bit confused, what and how I should write into CODESYScontrol.cfg&lt;/p&gt;
&lt;p&gt;I have a working script (only an example) which I can run with this command:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="n"&gt;sudo&lt;/span&gt; &lt;span class="n"&gt;python&lt;/span&gt; &lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="n"&gt;home&lt;/span&gt;&lt;span class="err"&gt;\&lt;/span&gt;&lt;span class="n"&gt;GPIO27_ON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;py&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;What should I write into .cfg file for this command to be used from within PLC program?&lt;/p&gt;
&lt;p&gt;I prepared this in .cfg:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="k"&gt;[SysProcess]&lt;/span&gt;
&lt;span class="na"&gt;Command.0&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;shutdown&lt;/span&gt;
&lt;span class="na"&gt;Command.1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;GPIO27_ON.py&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;I moved file to \usr\bin\ folder. I made it executable.&lt;/p&gt;
&lt;p&gt;In Programm I define xGumb as virtual button.&lt;br/&gt;
This is my code:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nv"&gt;xRisingTrigger&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;CLK&lt;/span&gt;:&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="nv"&gt;xGumb&lt;/span&gt;&lt;span class="ss"&gt;)&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;IF&lt;/span&gt; &lt;span class="nv"&gt;xRisingTrigger&lt;/span&gt;.&lt;span class="nv"&gt;Q&lt;/span&gt;  &lt;span class="k"&gt;THEN&lt;/span&gt; 
   &lt;span class="nv"&gt;_&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;GPIO27_ON.py&lt;/span&gt;&lt;span class="s1"&gt;'&lt;/span&gt;,&lt;span class="nv"&gt;ADR&lt;/span&gt;&lt;span class="ss"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Result&lt;/span&gt;&lt;span class="ss"&gt;))&lt;/span&gt;&lt;span class="c1"&gt;;&lt;/span&gt;
&lt;span class="nv"&gt;END_IF&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;I get Result value 25 when I trigger xGumb. Script is not executed.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Gregor&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Execute external Phyton script with GPIO pin, PLC function ?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/89f30635f9/?limit=25#2fa7" rel="alternate"/><published>2020-02-27T17:05:36.389000Z</published><updated>2020-02-27T17:05:36.389000Z</updated><author><name>eschwellinger</name><uri>https://forge.codesys.com/u/eschwellinger/</uri></author><id>https://forge.codesys.com4ead2477fb5e78f9b222c83e795b3a9ec482af97</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;br/&gt;
1. for adding syslibs you need to switch to professional (this is obsolete for 3.5SP7 ).&lt;br/&gt;
2. then you need to add sysprocess library and Systypes Interfaces2 library (just type part of the name into the search field see screenshot)&lt;br/&gt;
3. check my example (add the command to /etc/CODESYSControl.cfg)&lt;br/&gt;
BR&lt;br/&gt;
Edwin&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Add_the_Command_CODESYSControl.cfg.jpg" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=1109"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: addSysprocess.jpg" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=1108"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: GPIO21Mapping.jpg" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=1107"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;img alt="IMG: Professional.jpg" rel="nofollow" src="https://forum.codesys.com//download/file.php?id=1105"/&gt;&lt;/p&gt;
&lt;p&gt;&lt;a class="" href="https://forum.codesys.com//download/file.php?id=1106" rel="nofollow"&gt;PiFaceIoDrv_LadderExample_andSysProcess.project &lt;span&gt;&lt;span&gt;[104.28 KiB]&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Execute external Phyton script with GPIO pin, PLC function ?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/89f30635f9/?limit=25#4270" rel="alternate"/><published>2020-02-27T17:05:35.410000Z</published><updated>2020-02-27T17:05:35.410000Z</updated><author><name>jinx</name><uri>https://forge.codesys.com/u/jinx/</uri></author><id>https://forge.codesys.com28e68ab5600c6afaf844b0f5500c0f495f92e559</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;br/&gt;
I browsed through the forum but I couldn't find a sollution for this. &lt;br/&gt;
I would like to run a Phyton script (or bash script) based on a condition within PLC programm (ie. If GPIO pin 27 is high, I want to run a Phyton script).&lt;/p&gt;
&lt;p&gt;I found some suggestions using Sysprocess.library and SysTypes.library, and use "Sys Process Execute Command", but I can not find these two libraries at all ( l &lt;a class="" href="http://forum.codesys.com/viewtopic.php?f=21&amp;amp;t=5714" rel="nofollow"&gt;viewtopic.php?f=21&amp;amp;t=5714&lt;/a&gt; l )&lt;/p&gt;
&lt;p&gt;Hope someone can help.&lt;br/&gt;
Best regards,&lt;br/&gt;
Gregor&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>