Python Script PLCnext Integration
The challenge is that an I/O master controller needs to have values written to an I/O device that it is using and checked for correctness from a PLCnext.
The script (Python):
- Read value from PLC front end values for I/O master controller:
- Index
- Subindex
- Command/write value
- From PLC, OPCUA read value from I/O master controller.
- Do hexadecimal and binary conversion to check for the correct length of values form OPCUA read.
- Do hexadecimal and binary conversion for OPCUA write and adjust length for write.
- From PLC, OPCUA write new value value to I/O master.
- From PLC, OPCUA read from I/O master the new value.
- Do hexadecimal and binary conversion from new read value.
- From PLC OS to PLC front end-write value for user to read.
- From PLC OS to PLC front end-reset execute button.
The script has been written and is fully function on two computers om running a Windows OS and the other a Debian OS. The trouble is getting it to run on the PLCnext.
PLCnext is:
AXC F 2152 2404267
HW: 02 FW: 2022.0.4 LTS
Work done to get script onto the PLCnext and functional.
PyPlcnextRsc library installed successfully.
opcua library will not install successfully.
- Direct pip install of opcua failed.
- Installed libxml2 Python library.
- Installed libxslt Python library.
- Installed lxml Python library, this library would show as installed in pip and never showed as installed when trying to install the opcua library. There appears to be a a fix that requires additional packages that I need apt, yum, or a standard package manager to get.
- python setup.py egg_info did not run successfully.
- │ exit code: 1
- ╰─> [3 lines of output]
- Building lxml version 4.9.1.
- Building without Cython.
- Error: Please make sure the libxml2 and libxslt development packages are installed.
- [end of output]
- Tried installing Python3 with pip updates.
- Pip update all: pip3 list --outdated --format=freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U
- Pip update pip directly.
- Pip update libxslt, libxml2, and lxml directly.
- Phoenix Contact solution, use IPKG package manager.
- Install Cython.
- Install GCC.
- Tried to install other packages as directed to fix the error from the opcua on Stack Overflow. The package manager did not have the needed packages.
- Installed the most uptodate IPKG Python version.
- Phoenix Contact solution from Github-install apt.
- Lots of broken links in the apt install file that would not allow it to be installed on the PLCnext.
- Tired multiple times with reboot to install apt.
- Tried to download and install apt from original apt binary on Github, this would not work as the decompression programs to do so are not present on the operating system, and the decompression programs cannot be installed without a package manager.
- Tried to install OPKG package manager as recommended on Stack Overflow using binary install the PLCnext did not have the decompression programs installed to do so, like with the apt package manager.
- Phoenix Contact solution, use Docker.
- Learned how to use docker and build image for the script with correct Python and library versions. It works perfect on my computer.
- Tried to install Docker using Phoenix Contact docker Github directions and Phoenix Contact file. The install would not work and had many internal broken links.
- Ways to install Docker tried:
- Docker with Docker engine.
- Belena with Docker engine.
- Belena without Docker engine.
- Tried to install Docker from binary on Docker website the PLCnext did not have the decompression programs installed to do so, like with the apt package manager.
- Redid step 1 in Python virtual environment.
- Contacted Phoenix Contact and was recommended to Podman which was preinstalled.
- Edited /etc/containers/registries.conf file to include docker.io registries.
- Downloaded Docker image for Python script and could not use it.
- Tried to build docker image in arm/v7 architecture using buildx and cannot figure out how to get it to work.
Summery:
- I cannot get script to work on PLCnext directly due to inability to install opcua library.
- I cannot get docker to build the script using the arm/v7 architecture (perhaps this is my error).
Comments
The recommendation in this case would be to use Balena Engine using the procedure described here:
https://github.com/PLCnext/Docker_GettingStarted
If you can give us details of the step in the installation procedure that is failing, we can try to help.
Contacted Phoenix Contact and was recommended to Podman which was preinstalled.
I don't know who recommended this, but Podman is currently only supported for use with PLCnext Store applications, so Podman is not the recommended solution in this case.
Thank you Martin, I have explained that the installation of Belena would not install in point nine. Nothing from the Docker_GettingStarted Github page would install. There where missing folders or files being called when the bash script is being ran.
Hmm, that should work, so hopefully we can find the problem.
There are two main steps for Balena Engine installation:
Which of these steps (Download the Project, or Execute Setup) gave errors?
Can you post a copy of the error messages?