Documentation – RevPiModIO 2

The main class, which is instantiated and provides all access to the IOs of the Revolution Pi.

revpimodio2.RevPiModIO([autorefresh=False, monitoring=False, syncoutputs=True])

Further specialized instantiations

Use only specific devices
revpimodio2.RevPiModIOSelected(deviceselection, [autorefresh=False, monitoring=False, syncoutputs=True])
  • deviceselection = Single or list of Devices of the RevPi Core to be managed.
    You can use the name <class ‘str’>, the position number <class ‘int’> or a list <class ‘list’> of names or position numbers.
Use virtual device to write data to inputs (driver)
revpimodio2.RevPiModIODriver(virtdev, [autorefresh=False, syncoutputs=True])
  • virtdev = Name or position number of a virtual device as <class ‘str’> or <class ‘int’> or a list name / position number <class ‘list’>. In these virtual devices data can be written to inputs and just read outputs. This means that other applications can access this data via the process image.

NOTE: Parameter ‘monitoring’ and ‘simulator’ are not available here because they are set automatically.

Instantiating Parameters

  • autorefreshUpdate process Image automatically
    This Parameter should ALWAYS be set to True. The module automatically synchronizes the IOs in the Background. The Default value for the cycle time is 50 milliseconds and can be changed via .cycletime. The use of .cycleloop(...) or .mainloop(...)is only possible if AutoRefresh is activated!

  • monitoring = If True: Read IOs only, never write them
    If this parameter is set to True, the IOs are read, but never written. This serves e.g. for Monitoring when another software controls the process image.

  • syncoutputsRead outputvalues, while instantiating
    In Standard this parameter is set to True  and reads the current output values for instantiation.

Further Parameters for simulations

  • procimg = Alternative path for Processimage
    This Parameter can be used to specify an alternative path for the process Image. This is for simulation applications. If not specified, “/dev/piControl0” is used, which contains the process image on the RevPi.

  • configrsc = Alternative path for piCtory configuration
    An alternative piCtory configuration can be transferred via this parameter. This is for simulation applications. If not specified, the piCtory configuration is automatically used on the RevPi core.

  • simulatorIf True, inputs and outputs are swapped
    By transferring True, the inputs and outputs are swapped. This makes it possible to write the inputs and to only read the outputs. This is for simulation applications!

  • .app
    Access to piCtory configurationdata
  • .core
    Direct access on the RevPi Core (LEDs and status values)
  • .device
    This object includes all devices
  • .io
    This object includes all IOs
  • .summary
    Summary from piCtory


  • .cycletime
    Sets or returns the current cycle time in milliseconds at autorefresh=True for process image updating.

  • .ioerrors
    Returns the number of read / write Errors that occurred. A reset of the value can be executed through .resetioerrors() .

  • .length
    Returns the number of bytes occupied by IOs in the process Image.

  • .maxioerrors
    If this value is 0 (Default value), read / write errors are only counted. If a value greater than 0 is specified here, an exception is triggered in the Python program.

Further attributes for simulation purpose

  • .configrsc
    Returns path of the used piCtory configuration data

  • .monitoring
    Returns value True, if the module was instantiated with monitoring=True , otherwise the value is False

  • .procimg
    Returns the used process Image path.

  • .simulator
    Returns true, if the module was instantiated with simulator=True , otherwise the value is False



Sets all devices in to the AutoRefresh-mode, if this wasn’t done while instantiating with  autorefresh=True or after the call of .exit() without parameter full=False.


Cleans the whole module, closes the Loops, AutoRefresh and all FileHandler. This function can be used in the interactive Pythonshell. With a Python program, the “Garbage Collector” does this automatically.

.cycleloop(func, [cycletime=50])

The current program thread is “caught” until .exit() is called. It executes the function “func” after each update of the process image and processes it. The process image is not updated during execution of the function. The inputs are keeping the current value until the end. Set Outputs are written into the process Image after the end of the function run.
The cycleloop is left, if the called function does not return a value of  None  (e.g. return 1), or by calling .exit().
NOTE: The time for the process Image synchronization and the running time of the function must not exceed the set .cycletime time or transferred cycletime !

  • cyclefunction
    This passed function is executed cyclically after reading the inputs. The outputs are written after execution.
    The function is passed an instance of  Cycletools() , which must accept:         def zyklusfunktion(cycletools):
  • cycletime
    The update rate for the process image can be set via the optional parameter (same function as setting .cycletime).


This function terminates the .cycleloop() or .mainloop() function and returns the sequence to the part of the Python program, where a Loop function was called.

  • full=True
    If the Parameter full is True (default value), all devices are removed from AutoRefresh. The process image is then no longer updated.


If this function is called, RevPiModIO takes over the signal handlers for SIGINT and SIGTERM. These are received when the operating system or the user wants to terminate the control program cleanly. After receiving one of the signals and terminating the RevPiModIO threads / functions, the signal handlers are released again.

  • cleanupfunc
    The optional transferable function is executed last, after the last reading of the inputs. Outputs set there, are written one last time after the function has finished. This is entended for cleanup operations, e.g. turning off the LEDs on the RevPi core.

.mainloop([freeze=False, blocking=True])

The current program thread is “trapped” (unless blocking=False) until  .exit()is called. It passes the Event monitoring and checks changes to the IOs registered with an event. If a change is detected, the program executes the corresponding functions in sequence.

  • freeze=False
    If this parameter is set to True, the process Image synchronization is paused until all event functions have been executed. Inputs retain their current value for the entire duration, and outputs are written to the process image only after all functions have been completed.
  • blocking=True
    If this parameter is specified with False, this activates the event monitoring and does NOT block the program at the location of the call. Good for GUI programming, if events are required by the RevPi, but the program should be continued.


Read in all inputs of all devices from the process image.

Note: Devices with activated autorefresh are excluded!

  • The returned value is True, if work on all devices was successful.


Resets the counted read / write errors of the process image to 0. The .ioerros attribute then begins the count at 0 again.


All outputs are set to ethe piCtory default values.

Note: If autorefresh is not active, all output values must be written to the process Image via .writeprocimg().


Read all current output values from the process Image. Can be used for initial synchronization, if it was  syncoutputs=False at instantiation.

Note: Devices with activated autorefresh are excluded!

  • The returned value is True, if the work on all devices were successful


Write of all output values in to the process Image.

Note: Devices with activated autorefresh are excluded!

  • The returned value is True, if the work on all devices were successful