Paolo
On fresh Unipi OpenSource OS, installing OpenPLC Runtime on Neuron give me this little error :
Collecting pip
  Downloading https://files.pythonhosted.org/packages/8a/6a/19e9fe04fca059ccf770861c7d5721ab4c2aebc539889e97c7977528a53b/pip-24.0-py3-none-any.whl (2.1MB)
Installing collected packages: pip
  Found existing installation: pip 18.1
    Uninstalling pip-18.1:
      Successfully uninstalled pip-18.1
Successfully installed pip-24.0
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
ERROR: Ignored the following versions that require a different python version: 2.3.0 Requires-Python >=3.8; 2.3.1 Requires-Python >=3.8; 2.3.2 Requires-Python >=3.8; 2.3.3 Requires-Python >=3.8; 3.0.0 Requires-Python >=3.8; 3.0.1 Requires-Python >=3.8; 3.0.2 Requires-Python >=3.8
ERROR: Could not find a version that satisfies the requirement flask==2.3.3 (from versions: 0.1, 0.2, 0.3, 0.3.1, 0.4, 0.5, 0.5.1, 0.5.2, 0.6, 0.6.1, 0.7, 0.7.1, 0.7.2, 0.8, 0.8.1, 0.9, 0.10, 0.10.1, 0.11, 0.11.1, 0.12, 0.12.1, 0.12.2, 0.12.3, 0.12.4, 0.12.5, 1.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 2.0.0rc1, 2.0.0rc2, 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.1.0, 2.1.1, 2.1.2, 2.1.3, 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.2.4, 2.2.5)
ERROR: No matching distribution found for flask==2.3.3
/usr/bin/python3: No module named pip
 
And Compilation finished successfully but openplc.service doesn't work :
* openplc.service - OpenPLC Service
   Loaded: loaded (/lib/systemd/system/openplc.service; enabled; vendor preset: enabled)
   Active: inactive (dead)
And sudo ./ start_openplc.sh return me :
Traceback (most recent call last):
  File "webserver.py", line 6, in <module>
    import serial.tools.list_ports
ModuleNotFoundError: No module named 'serial'
What can I try now ?
Reply 0 0
thiagoralves
It seems that the python version bundled with that is too old. You need to try to update it to at least python 3.8
Reply 1 0
Paolo
Thanks for all the help you've given me, I understand more and more what I'm doing and how Linux works thanks to you.
I managed to install Python 3.11 by following these steps:
https://stackoverflow.com/questions/64718274/how-to-update-python-in-raspberry-pi/64737929#64737929
 
The command python -V returns
Python 3.11.8
and command pip -V returns
-bash: pip: command not found
but python -m pip show pip returns
Name: pip
Version: 24.0
Summary: The PyPA recommended tool for installing Python packages.
Home-page: 
Author: 
Author-email: The pip developers <distutils-sig@python.org>
License: MIT
Location: /usr/local/lib/python3.11/site-packages
Requires: 
Required-by:


After removing OpenPLC_v3 folder and start again the installation I have the same problem but I saw that :
Installing OpenPLC on UniPi Neuron PLC

[DISABLING UNIPI SERVICES]
Failed to stop neuronhost.service: Unit neuronhost.service not loaded.
Failed to disable unit: Unit file neuronhost.service does not exist.
Failed to stop neurontcp.service: Unit neurontcp.service not loaded.
Failed to disable unit: Unit file neurontcp.service does not exist.
Hit:1 http://deb.debian.org/debian buster InRelease
Hit:2 http://deb.debian.org/debian-security buster/updates InRelease
Hit:3 http://deb.debian.org/debian buster-updates InRelease
Hit:4 http://archive.raspberrypi.org/debian buster InRelease
Hit:5 https://repo.unipi.technology/debian buster InRelease
Reading package lists...
Reading package lists...
Building dependency tree...
Reading state information...
autoconf is already the newest version (2.69-11).
automake is already the newest version (1:1.16.1-4).
bison is already the newest version (2:3.3.2.dfsg-1).
build-essential is already the newest version (12.6).
flex is already the newest version (2.6.4-6.2).
libtool is already the newest version (2.4.6-9).
make is already the newest version (4.2.1-1.2).
pkg-config is already the newest version (0.29-6).
python3 is already the newest version (3.7.3-1).
python3-venv is already the newest version (3.7.3-1).
curl is already the newest version (7.64.0-4+deb10u9).
git is already the newest version (1:2.20.1-2+deb10u8).
sqlite3 is already the newest version (3.27.2-3+deb10u2).
cmake is already the newest version (3.16.3-3~bpo10+1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pip
  Using cached https://files.pythonhosted.org/packages/8a/6a/19e9fe04fca059ccf770861c7d5721ab4c2aebc539889e97c7977528a53b/pip-24.0-py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 18.1
    Uninstalling pip-18.1:
      Successfully uninstalled pip-18.1
Successfully installed pip-24.0
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
ERROR: Ignored the following versions that require a different python version: 2.3.0 Requires-Python >=3.8; 2.3.1 Requires-Python >=3.8; 2.3.2 Requires-Python >=3.8; 2.3.3 Requires-Python >=3.8; 3.0.0 Requires-Python >=3.8; 3.0.1 Requires-Python >=3.8; 3.0.2 Requires-Python >=3.8
ERROR: Could not find a version that satisfies the requirement flask==2.3.3 (from versions: 0.1, 0.2, 0.3, 0.3.1, 0.4, 0.5, 0.5.1, 0.5.2, 0.6, 0.6.1, 0.7, 0.7.1, 0.7.2, 0.8, 0.8.1, 0.9, 0.10, 0.10.1, 0.11, 0.11.1, 0.12, 0.12.1, 0.12.2, 0.12.3, 0.12.4, 0.12.5, 1.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.1.0, 1.1.1, 1.1.2, 1.1.3, 1.1.4, 2.0.0rc1, 2.0.0rc2, 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.1.0, 2.1.1, 2.1.2, 2.1.3, 2.2.0, 2.2.1, 2.2.2, 2.2.3, 2.2.4, 2.2.5)
ERROR: No matching distribution found for flask==2.3.3
/usr/bin/python3: No module named pip
 
python3 is already the newest version (3.7.3-1), why ?
Reply 0 0
thiagoralves
Hmm, maybe the issue is somewhere else. I believe that the problem could be that there aren’t any prebuilt binaries for flask for buster (your OS version, which is also quite old). You can try editing the background_installer script to change flask version to 2.2.5 which is the latest version available for your system. This may or may not work, as older versions of flask had a slightly different API for some things
Reply 1 0
Paolo
Wow !
After editing background_installer.sh with flask==2.2.5 and werkzeug==2.2.2, openplc service start and seem to be functionnal :
OpenPLC Runtime starting...
Neuron: Searching for I/O...
Interactive Server: Listening on port 43628
Neuron: Done!

Neuron Digital Inputs
/sys/devices/platform/unipi_plc/io_group1/di_1_01/di_value  =>  %IX0.0
/sys/devices/platform/unipi_plc/io_group1/di_1_02/di_value  =>  %IX0.1
/sys/devices/platform/unipi_plc/io_group1/di_1_03/di_value  =>  %IX0.2
/sys/devices/platform/unipi_plc/io_group1/di_1_04/di_value  =>  %IX0.3
/sys/devices/platform/unipi_plc/io_group2/di_2_01/di_value  =>  %IX0.4
/sys/devices/platform/unipi_plc/io_group2/di_2_02/di_value  =>  %IX0.5
/sys/devices/platform/unipi_plc/io_group2/di_2_03/di_value  =>  %IX0.6
/sys/devices/platform/unipi_plc/io_group2/di_2_04/di_value  =>  %IX0.7
/sys/devices/platform/unipi_plc/io_group2/di_2_05/di_value  =>  %IX1.0
/sys/devices/platform/unipi_plc/io_group2/di_2_06/di_value  =>  %IX1.1
/sys/devices/platform/unipi_plc/io_group2/di_2_07/di_value  =>  %IX1.2
/sys/devices/platform/unipi_plc/io_group2/di_2_08/di_value  =>  %IX1.3
/sys/devices/platform/unipi_plc/io_group2/di_2_09/di_value  =>  %IX1.4
/sys/devices/platform/unipi_plc/io_group3/di_3_01/di_value  =>  %IX1.5
/sys/devices/platform/unipi_plc/io_group3/di_3_02/di_value  =>  %IX1.6
/sys/devices/platform/unipi_plc/io_group3/di_3_03/di_value  =>  %IX1.7
/sys/devices/platform/unipi_plc/io_group3/di_3_04/di_value  =>  %IX2.0
/sys/devices/platform/unipi_plc/io_group3/di_3_05/di_value  =>  %IX2.1
/sys/devices/platform/unipi_plc/io_group3/di_3_06/di_value  =>  %IX2.2
/sys/devices/platform/unipi_plc/io_group3/di_3_07/di_value  =>  %IX2.3
/sys/devices/platform/unipi_plc/io_group3/di_3_08/di_value  =>  %IX2.4
/sys/devices/platform/unipi_plc/io_group3/di_3_09/di_value  =>  %IX2.5

Neuron Digital Outputs
/sys/devices/platform/unipi_plc/io_group1/do_1_01/do_value  =>  %QX0.0
/sys/devices/platform/unipi_plc/io_group1/do_1_02/do_value  =>  %QX0.1
/sys/devices/platform/unipi_plc/io_group1/do_1_03/do_value  =>  %QX0.2
/sys/devices/platform/unipi_plc/io_group1/do_1_04/do_value  =>  %QX0.3
/sys/devices/platform/unipi_plc/io_group2/ro_2_01/ro_value  =>  %QX0.4
/sys/devices/platform/unipi_plc/io_group2/ro_2_02/ro_value  =>  %QX0.5
/sys/devices/platform/unipi_plc/io_group2/ro_2_03/ro_value  =>  %QX0.6
/sys/devices/platform/unipi_plc/io_group2/ro_2_04/ro_value  =>  %QX0.7
/sys/devices/platform/unipi_plc/io_group2/ro_2_05/ro_value  =>  %QX1.0
/sys/devices/platform/unipi_plc/io_group2/ro_2_06/ro_value  =>  %QX1.1
/sys/devices/platform/unipi_plc/io_group2/ro_2_07/ro_value  =>  %QX1.2
/sys/devices/platform/unipi_plc/io_group2/ro_2_08/ro_value  =>  %QX1.3
/sys/devices/platform/unipi_plc/io_group2/ro_2_09/ro_value  =>  %QX1.4
/sys/devices/platform/unipi_plc/io_group3/ro_3_01/ro_value  =>  %QX1.5
/sys/devices/platform/unipi_plc/io_group3/ro_3_02/ro_value  =>  %QX1.6
/sys/devices/platform/unipi_plc/io_group3/ro_3_03/ro_value  =>  %QX1.7
/sys/devices/platform/unipi_plc/io_group3/ro_3_04/ro_value  =>  %QX2.0
/sys/devices/platform/unipi_plc/io_group3/ro_3_05/ro_value  =>  %QX2.1
/sys/devices/platform/unipi_plc/io_group3/ro_3_06/ro_value  =>  %QX2.2
/sys/devices/platform/unipi_plc/io_group3/ro_3_07/ro_value  =>  %QX2.3
/sys/devices/platform/unipi_plc/io_group3/ro_3_08/ro_value  =>  %QX2.4
/sys/devices/platform/unipi_plc/io_group3/ro_3_09/ro_value  =>  %QX2.5

Neuron Analog Inputs
/sys/devices/platform/unipi_plc/io_group1/ai_1_1/in_voltage0_raw  =>  %IW0

Neuron Analog Outputs
/sys/devices/platform/unipi_plc/io_group1/ao_1_1/out_voltage0_raw  =>  %QW0

Skipping configuration of Slave Devices (mbconfig.cfg file not found)
Warning: Persistent Storage file not found
Issued start_modbus() command to start on port: 502
Server: error binding socket => Address already in use
Server: waiting for new client...
Issued start_dnp3() command to start on port: 20000
DNP3 ID manager: Starting thread (0)
DNP3 ID DNP3_Server: Listening on: 0.0.0.0:20000
Issued start_enip() command to start on port: 44818
Server: Listening on port 44818
Server: waiting for new client...
Issued stop_pstorage() command
 
but these lines scare me
Issued start_modbus() command to start on port: 502
Server: error binding socket => Address already in use
Server: waiting for new client...
 
Reply 0 0
thiagoralves
This error about port 502 still in use might have to do with this:
Failed to stop neuronhost.service: Unit neuronhost.service not loaded.
Failed to disable unit: Unit file neuronhost.service does not exist.
Failed to stop neurontcp.service: Unit neurontcp.service not loaded.
Failed to disable unit: Unit file neurontcp.service does not exist.
 
It seems that the neuron services have changed places since the OpenPLC driver was built, hence OpenPLC cannot stop them and therefore conflicts with them. For now, if you simply move the OpenPLC modbus server to another port (say 503, or 1502, or anything else that is available) you will be able to run both at the same time, although in different ports.
Reply 1 0
Paolo
Wow, I'm always surprised that these lines speak to you so easily.
Yes, if I change the Modbus listening port it works, but that means I also have to inform the slaves of the change, doesn't it?

With a bit of research I found the service in question which I stopped:
* unipitcp.service - Unipi Neuron/Axon/Patron/Gate Modbus/Tcp Server
   Loaded: loaded (/lib/systemd/system/unipitcp.service; enabled; vendor preset: enabled)
   Active: active (running) since Tue 2024-03-19 17:42:21 CET; 4h 8min ago
 Main PID: 714 (unipi_tcp_serve)
    Tasks: 1 (limit: 2048)
   CGroup: /system.slice/unipitcp.service
           `-714 /opt/unipi/tools/unipi_tcp_server -l 127.0.0.1 -p 502
And that's it:
Issued start_modbus() command to start on port: 502
Server: Listening on port 502
Server: waiting for new client...
 
 
Reply 0 0
thiagoralves
The slaves open their own ports. The masters (hmi for example) that need to be adjusted if you want them to talk to OpenPLC on a different port. Anyway, I’m glad you were able to find the service and stop it.
Reply 0 0
Reply