Skip to content

Communication driver

Models the communication with the gateway in order to connect to different software.

Mandatory children

Setup data

The setup data is a JSON string that must contain two mandatory items:

Parameters

These values exposes the configuration or context used by the drivers to connect to other platforms. All the drivers share three common parameters (rpi, force_write and auto_reset). Except for these, each driver has its own specific parameters, which can be found on their pages here in the user manual.

The parameters are defined by a dict that may include several items following the next format {parameter_name: parameter_value}, i.e:

{
    "rpi": 35,
    "force_write": 0.5,
    "auto_reset": 5.0
}

Common parameters

  • rpi: How often vars are read and write in ms. Default: 50
  • force_write: Used to periodically (in s) re-write variables. Default: 1.0
  • auto_reset: Used to define the time (in sec) to try reset the driver when the state is ERROR. Default: 5.0

Variables

These are the variables to be accessed in the controller, read and written through the driver. They are defined by a dict that may include several definitions following the next format {address: {'datatype':str, 'size':int, 'operation':str}:

  • address (str): It can be used as name, tag, id, or simply to identify the variable.
  • datatype (str): It is used to define the variable data type (bool, byte, int, word, dword, qword, float, str).
  • size (int): It defines if the variable is an array. If not defined it is asumed is not an array or dimension 1.
  • operation (str): It defines if the variable should be written or read by the driver in the controller (read, write).

An example of two variables input and output definition:

{
    "input": {
        "datatype": "byte", 
        "size": 1, 
        "operation": "write"
    },
    "output": {
        "datatype": "byte", 
        "size": 2, "operation": "read"
    }
}

Result

Now, combining these two blocks together, a complete SETUP msg would look like the following example:

{
    "parameters": {
        "rpi": 35,
        "force_write": 0.5,
        "ip": "192.168.0.1",
        "port": 1234
    },
    "variables": {
        "input": {
            "datatype": "byte", 
            "size": 1,
            "operation": "write"
        },
        "output": {
            "datatype": "byte", 
            "size": 2, 
            "operation": "read"
        }
    }
}

Tip

You will find specific examples of the setup_data, update_input and update_output in the different drivers documentation