ModBus
ModBus
Implementation of the library j2mod to give an access to devices connected through modbus. This is the hardware module that give support to Modbus Datastreams.
To access source code click here.
Dependencies
This module requires the following modules:
- Commons: Provide the ModBus APIs, exceptions and types and the basic APIs to register the service.
Configuration
To configure ModBus Hardware module, a file named es.amplia.oda.hardware.modbus.cfg must be created with the next parameters:
- type: Required data. Type of modbus connection. Allowed modbus types are TCP, UDP, Serial.
- connections: Required data for UDP and TCP. Indicates the devices and the data needed to connect with them alongside other needed info like the manufacturer. Allows multiple devices from different manufacturers with the format : deviceId1,ipAddress1,port1,manufacturer1;deviceId2,ipAddress2,port2,manufacturer2;etc
- timeout: Required data for UDP and TCP. Time in seconds that the modbus hardware will wait until do a timeout if the master slave doesn’t respond.
- reconnect: Required data for TCP. If reconnect = true, every time we request a value from a device, a new conenction is created. If reconnect = false it will mantain the same connection for all the session. If connection is lost, the next time we request a value it will create a new connection.
- ports: Required data for serial. Indicates the name of the serial port (tty) and the deviceId and manufacturer associated. Allows multiple devices with the format : portName1,deviceId1,manufacturer1;portName2,deviceId2,manufacturer2;etc
- baudRate: Required data for serial. Baud Rate of the connection. 9600, 38400 or 115200.
- flowControlIn: Required data for serial. Flow Control of the input of connection.
- flowControlOut: Required data for serial. Flow Control of the output of connection.
- databits: Required data for serial. Data bits of the connection. 5, 6, 7 or 8.
- stopbits: Required data for serial. Stop bits of the connection. 1 or 2.
- parity: Required data for serial. Parity type of the connection. 0 is NONE parity, 1 is ODD parity, 2 is EVEN parity, 3 is mark parity and 4 is SPACE parity.
- encoding: Required data for serial. Encoding of the serial connection communication. E.g. ascii or rtu.
- echo: Required data for serial. Enable echo on the connection (show send data from local to the slave).
es.amplia.oda.hardware.modbus.cfg will have a similar format to:
type=UDP
timeout=30
connections=deviceId,localhost,30,manufacturer
type=TCP
timeout=30
reconnect=true
connections=deviceId,localhost,30,manufacturer
type=Serial
ports=ttyUSB0,deviceId1,manufacturer1
baudRate=115200
flowControlIn=1
flowControlOut=1
databits=8
stopbits=1
parity=0
encoding=ascii
echo=true