Documentation – RevPiPyLoad

This component is installed on the Revolution Pi Core.

  • Starts and monitors the Python3 program to control IOs, 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

Parameters in DEFAULT section:

  • 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 program
  • autostart=1
    Starts the Python program automatically when the RevPi core system starts
  • plcworkdir=/var/lib/revpipyload
    Base directory for the Python program. The program, all related files and subfolders must be stored here.
  • plcprogram=program.py
    This program is being started through RevPiPyLoad.
  • plcarguments=
    Arguments to pass to the Python Program at startup
  • plcuid=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
  • 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


Parameters in PLCSLAVE section:

  • plcslave=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 aclplcslave.conf file!)
  • aclfile=/etc/revpipyload/aclplcslave.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-SLAVE 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

NOTE: If an IP address attempts to access without authorization (no matter if read only or read / write), the connection will be rejected immediately!

  • 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 listen
Parameters in XMLRPC section:

  • 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

NOTE: If an IP address attempts to access without authorization (no matter if read only or read / write), the connection will be rejected immediately!

  • 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 *.
Parameters in MQTT section:

  • 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_ioname
  • sendinterval = 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=""
# ändern in
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 😀