Hi,
I browsed through the forum but I couldn't find a sollution for this.
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).
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 viewtopic.php?f=21&t=5714 (forum.codesys.com) l )
Hope someone can help.
Best regards,
Gregor
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
could not really se the problem at the moment
could you please upload the CODESYSControl.cfg .. (check if there is a dublicate entry of the SysProcess section)
Error 25 means:
define ERR_NO_ACCESS_RIGHTS 0x0019 /* No access rights for this operation */
BR
Edwin
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I browsed through the forum but I couldn't find a sollution for this.
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).
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 viewtopic.php?f=21&t=5714 (forum.codesys.com) l )
Hope someone can help.
Best regards,
Gregor
Hi,
BR
Edwin
PiFaceIoDrv_LadderExample_andSysProcess.project [104.28 KiB] (forum.codesys.com)
Hi Edwin,
thank you for your answer.
I managed to install libraries: "SysProcess 3.5.5.0" and "SysTypes2 Interfaces".
I am a bit confused, what and how I should write into CODESYScontrol.cfg
I have a working script (only an example) which I can run with this command:
What should I write into .cfg file for this command to be used from within PLC program?
I prepared this in .cfg:
I moved file to \usr\bin\ folder. I made it executable.
In Programm I define xGumb as virtual button.
This is my code:
I get Result value 25 when I trigger xGumb. Script is not executed.
Gregor
Hi,
could not really se the problem at the moment
could you please upload the CODESYSControl.cfg .. (check if there is a dublicate entry of the SysProcess section)
Error 25 means:
define ERR_NO_ACCESS_RIGHTS 0x0019 /* No access rights for this operation */
BR
Edwin
Hi Edwin,
attached is CODESYSControl.cfg (I had to rename it to .txt because forum doesn't allow .cfg files to be uploaded).
There is no duplicate.
Could this be a problem with ROOT privilege to run python scripts?
BR,
Gregor
CODESYSControl.txt [1.04 KiB] (forum.codesys.com)
Running script...
BR,
Gregor
Hi,
Change the config file to:
[SysProcess]
Command.0=shutdown
Command.1=python
(after doing this a restart of the runtime is needed)
and then call in CODESYS
Sys..Process...ExecuteC..('python GPIO27_ON.py',ADR(Result));
BR
Edwin
Hi Edwin,
I finnaly got it working!
I had to give the full path to run scripts!
Thank you!
BR, Gregor