This component is installed on the Revolution Pi Core.
- Starts and monitors your Python3 control program, written with RevPiModIO
- Serves the process image to RevPiNetIO
- Serves the interface for the graphic configuration tool. You can configure this service upload and start / stop your control program
- Publish IO values by MQTT
By installing via dpkg or apt-get, the daemon is automatically integrated into the init/systemd system of Linux and starts automatically with the system start.
The default configuration attempts to start a Python3 program called “program.py” in the /var/lib/revpipyload directory. The XML-RPC server is disabled (NOTICE AT THE END OF THE PAGE !!!).
Daemon restart / Stop / Load configuration
If changes (as described below) are made, they must be applied by RevPiPyLoad. This can be easily done via the shell:
# start daemon pi@RevPi ~ $ sudo service revpipyload start # stop daemon pi@RevPi ~ $ sudo service revpipyload stop # reload settings pi@RevPi ~ $ sudo service revpipyload reload # restart daemon pi@RevPi ~ $ sudo service revpipyload restart
Change Settings
All settings are made in /etc/revpipyload/revpipyload.conf. To edit, you can simply open it in an editor, eg:
pi@RevPi ~ $ sudo nano /etc/revpipyload/revpipyload.conf
NOTE: If an IP address attempts to access without authorization (no matter if read only or read / write), the connection will be rejected immediately! NOTE: If an IP address attempts to access without authorization (no matter if read only or read / write), the connection will be rejected immediately!
autoreload=1
Automatically restarts the Python program when it is finished, whether by crash or because it has gone through. NOTE: Python programs should run continuously and do not complete a task, exit and then being restarted by RevPiPyLoad!autoreloaddelay=5
Delay to restart the Python programautostart=1
Starts the Python program automatically when the RevPi core system startsplcworkdir=/var/lib/revpipyload
Base directory for the Python program. The program, all related files and subfolders must be stored here.plcworkdir_set_uid=0
If =1 the System will set write access to the plcwordir for the plcuid. So the control programm can write into that directory!plcprogram=program.py
This program is being started through RevPiPyLoad.plcprogram_watchdog=0
You can activate the software watchdog for RevPiPyLoad. The value is the timeout in seconds, in which the watchdog bit have to toggle .core.wd_toggle()
. If there is no toggling bit, the plc program will restart.plcarguments=
Arguments to pass to the Python Program at startupplcuid=1000
User ID for Python program authorization. The user pi has the UID 1000 and usually enough privileges to run the program. If root permissions are required, the value 0 can be specified here.plcgid=1000
Group ID for authorization of the Python program. The user pi has the GID 1000. If root permissions are required, the value 0 can be specified here.pythonversion=3
Python version to start your python program.replace_ios=/etc/revpipyload/replace_ios.conf
This is the file path to the configuration of replaced IOs. If your control program replaces IOs, you can export the configuration and set this value to “/var/lib/revpipyload/replace_ios.conf”, to dynamically load it. You have to set plcworkdir_set_uid=1
, too.reset_driver_action=2
If value is “2”, your plc program will restart, if the user is pressing “Reset Driver” in piCtory configuration. On “1” your program will restart, if there was changes in piCtory configuration, only.
“0” will disable this function.zeroonerror=0
If 1, the process image is overwritten with \ x00 bytes at Python program crash to set all outputs to NULL. NOTE: We recommend setting this parameter to 1!zeroonexit=0
If 1, the process image is overwritten with \ x00 bytes when the python program is terminated (exitcode = 0) to set all outputs to NULL
plcserver=0
This parameter determines whether the process image server for RevPiModIO (RevPiNetIO(...)
, RevPiNetIOSelected(...)
, RevPiNetIODriver(...)
) is activated. By setting to 1 a connection from other computers via RevPiModIO is possible (note aclplcserver.conf
file!)aclfile=/etc/revpipyload/aclplcserver.conf
Specifies the file name from which to read the permissions for IP addresses.
These authorizations control access to the process image.
ONE access definition PER LINE: IPADDRESS,RIGHT
IPADDRESS
Single IP address or groups defined with wildcards:
192.168.178.10 -> Only one computer
192.168.178. * -> All computers where the IP starts with 192.168.178.RIGHT
0 = read only
1 = read and write# PLC-SERVER Access Control List (acl)
# One entry per Line IPADRESS,LEVEL
#
# All computers in the 192.168.178.0/24 net can read the IOs
192.168.178.*,0
# The computer 192.168.178.10 can read and write the IOs
192.168.1.20,1
bindip=*
Specifies the IP to which the process image server is to be bound. This can be useful if the RevPi has several IPs and the process image should only to be reached from one network.
If you want to bind the process image server to all IPs, enter *
.port=55234
Specifies the port on which the process image server listenwatchdog=1
The system will monitor the transmission of the process image. If there is an error on the network, it will request a reconnect of the client. Value 0 will disable the monitoring.
xmlrpc=0
Enables 1 or disables 0 the XML-RPC server. This is required if RevPiPyLoad should be controlled via the graphical tool RevPiPyControl
(note aclxmlrpc.conf
file!)aclfile=/etc/revpipyload/aclxmlrpc.conf
Specifies the file name from which to read the permissions for IP addresses.
These authorizations control access to the RevPiPyLoad via RevPiPyControl.
ONE access definition PER LINE: IPADDRESS,RIGHT
IPADDRESS
Single IP address or groups defined with wildcards:
192.168.178.10 -> Only one computer
192.168.178. * -> All computers where the IP starts with 192.168.178.RIGHT
0: Start/Stop PLC program and read logs
1: all from 0 + read IOs in watch modus
2: all from 1 + read properties and download PLC program
3: all from 2 + upload PLC program an write IOs in watch modus
4: all from 3 + set properties of RevPiPyLoad# XML-RPC Access Control List (acl)
# One entry per Line IPADRESS,LEVEL
#
# All computers in the 192.168.178.0/24 net can read log files and start/stop the plc program
192.168.178.*,0
# The computer 192.168.178.20 has access to all features and settings
192.168.178.10,4
bindip=*
Specifies the IP to which the XML-RPC server is to be bound. This can be useful if the RevPi has several IPs and RevPiPyLoad should only to be reached from one network.
If you want to bind the process image server to all IPs, enter *
.
mqtt = 0
If you want to use MQTT, you have to set this parameter to 1. This enables the general MQTT functions.basetopic = revpi0000
The basetopic is the first part of the topic for all MQTT messages. If the basetopic is e.g. set to myrevpis/revpi3444, than the topic of a cyclic transmission is myrevpis/revpi3444/io/pictory_ionamesendinterval = 15
Time interval in seconds in which all values will be published to the MQTT broker. The messages will be published with the topic basetopic/io/pictory_ioname and contain the IO value as payload.
You can disable this function when setting this value to 0. Than send_on_events
schould be set to 1, otherwise no messages will be published.send_on_event = 0
Send values immediately if the IO value changes. The message will be published with the topic basetopic/event/pictory_ioname and contains the new IO value as payload.write_outputs = 0
RevPiPyLoad can write transferred values to the outputs of the Revolution Pi. If another MQTT client sends a message to the broker, the Revolution Pi can receive it and read the new value from the payload.
Values to be set must be sent with the topic basetopic/set/pictory_outputname and the new value in the payload.broker_address = localhost
This is the host name or IP address of the broker to which the Revolution Pi is to connect. If a broker is installed on the Revolution Pi (for example, mosquitto), localhost is used.
Simply install Mosquitto via: sudo apt-get install mosquitto
port = 1883
Port to connect to the MQTT broker. Use 1883 for unencrypted connections. If the broker is setup for encrypted transmission, than you MUST set the parameter tls_set
to 1. The default port for encrypted connections is 8883.tls_set = 0
If set to 1, an encrypted connection is used to connect to the broker. For this connection, the port should be set to 8883 (secure MQTT) by default!username =
Username for logging in to the MQTT broker.password =
Password for logging in to the MQTT broker.client_id =
Revolution Pi MQTT client id for the connection to the broker (must be unique). If this value is left blank, a unique client id will be generated automatically.
Logging
In addition to the log file for the Python program, RevPiPyLoad creates its own. It can monitor output from the daemon. The level of logging can be changed via the file /etc/default/revpipyload.
pi@RevPi ~ $ sudo nano /etc/default/revpipyload
By adding -v, the log output can be increased:
DAEMON_ARGS="" # change to DAEMON_ARGS="-v"
NOTE: The XML-RPC interface is only for the local network! It may NEVER be used over the Internet because the transmission is not encrypted. There are also no authentication options yet, except access managed by IP address.
The primary focus of the system is monitoring the actual Python program. Log its outputs, log errors, and make sure the Python program is running! But (still) not to do everything from anywhere over the network.
Depending on the feedback from the community, we will include such functions 😀