Modbus Adaptor
Introduction
Modbus is a master/slave protocol, the device requesting the information is called the Modbus master and the devices supplying information are Modbus slaves. In a standard Modbus network, there is one master and up to 247 slaves, each with a unique slave address from 1 to 247. The master can also write information to the slaves.
Modbus adaptor implements the goburrow/modbus to support both TCP and RTU protocols, it acting as the controller(master) node and connects to or manipulating the Modbus worker(slave) devices on the edge side.
Modbus Registers Operation
Coil Registers: readable and writable, 1 bit (off/on)
Discrete Input Registers: readable, 1 bit (off/on)
Input Registers: readable, 16 bits (0 to 65,535), essentially measurements and statuses
Holding Registers: readable and writable, 16 bits (0 to 65,535), essentially configuration values
Registration Information
| Versions | Register Name | Endpoint Socket | Available |
|---|---|---|---|
v1alpha1 | adaptors.edge.cattle.io/modbus | modbus.sock | * |
Support Model
| Kind | Group | Version | Available |
|---|---|---|---|
ModbusDevice | devices.edge.cattle.io | v1alpha1 | * |
Support Platform
| OS | Arch |
|---|---|
linux | amd64 |
linux | arm |
linux | arm64 |
Usage
Authority
Grant permissions to Octopus as below:
Example
Specifies a
ModbusDevicedevice link to connect a serial port thermometer.apiVersion: edge.cattle.io/v1alpha1kind: DeviceLinkmetadata:name: modbus-rtuspec:adaptor:node: edge-workername: adaptors.edge.cattle.io/modbusmodel:apiVersion: "devices.edge.cattle.io/v1alpha1"kind: "ModbusDevice"template:metadata:labels:device: modbus-rtuspec:parameters:syncInterval: 10stimeout: 10sprotocol:rtu:endpoint: /dev/tty.usbserial-1410workerID: 1parity: "N"stopBits: 2dataBits: 8baudRate: 9600properties:- name: temperaturedescription: data collection of temperature sensorreadOnly: truevisitor:register: HoldingRegisteroffset: 0quantity: 1orderOfOperations:- type: Dividevalue: "10"type: float
For more ModbusDevice device link examples, please refer to the deploy/e2e directory and make a quick experience with deploy/e2e/simulator.yaml.
ModbusDevice
| Parameter | Description | Schema | Required |
|---|---|---|---|
| metadata | metav1.ObjectMeta | false | |
| spec | Defines the desired state of ModbusDevice. | ModbusDeviceSpec | true |
| status | Defines the observed state of ModbusDevice. | ModbusDeviceStatus | false |
ModbusDeviceSpec
| Parameter | Description | Schema | Required |
|---|---|---|---|
| extension | Specifies the extension of device. | *ModbusDeviceExtension | false |
| parameters | Specifies the parameters of device. | *ModbusDeviceParameters | false |
| protocol | Specifies the protocol for accessing the device. | *ModbusDeviceProtocol | true |
| properties | Specifies the properties of device. | []ModbusDeviceProperty | false |
ModbusDeviceStatus
| Parameter | Description | Schema | Required |
|---|---|---|---|
| properties | Reports the properties of device. | []ModbusDeviceStatusProperty | false |
ModbusDeviceParameters
| Parameter | Description | Schema | Required |
|---|---|---|---|
| syncInterval | Specifies the amount of interval that synchronized to limb, default to 15s. | string | false |
| timeout | Specifies the amount of timeout, default to 10s. | string | false |
ModbusDeviceProtocol
| Parameter | Description | Schema | Required |
|---|---|---|---|
| rtu | Specifies the connection protocol as RTU. | *ModbusDeviceProtocolRTU | false |
| tcp | Specifies the connection protocol as TCP. | *ModbusDeviceProtocolTCP | false |
ModbusDeviceProtocolRTU
| Parameter | Description | Schema | Required |
|---|---|---|---|
| endpoint | Specifies the serial port of device, which is in form of "/dev/ttyS0". | string | true |
| workerID | Specifies the worker ID of device. | int | true |
| baudRate | Specifies the baud rate of connection, a measurement of transmission speed, default to 19200. | int | false |
| dataBits | Specifies the data bit of connection, selected from [5, 6, 7, 8], default to 8. | int | false |
| parity | Specifies the parity of connection, selected from [N - None, E - Even, O - Odd], the use of N(None) parity requires 2 stop bits, default to E. | string | false |
| stopBits | Specifies the stop bit of connection, selected from [1, 2],the use of N(None) parity requires 2 stop bits, default to 1. | int | false |
ModbusDeviceProtocolTCP
| Parameter | Description | Schema | Required |
|---|---|---|---|
| endpoint | Specifies the IP address of device, which is in form of "ip:port". | string | true |
| workerID | Specifies the worker ID of device. | int | true |
ModbusDeviceProperty
| Parameter | Description | Schema | Required |
|---|---|---|---|
| name | Specifies the name of property. | string | true |
| description | Specifies the description of property. | string | false |
| type | Specifies the type of property. | ModbusDevicePropertyType | true |
| visitor | Specifies the visitor of property. | *ModbusDevicePropertyVisitor | true |
| readOnly | Specifies if the property is readonly., default to false. | boolean | false |
| value | Specifies the value of property, only available in the writable property. | string | false |
ModbusDeviceStatusProperty
| Parameter | Description | Schema | Required |
|---|---|---|---|
| name | Reports the name of property. | string | false |
| type | Reports the type of property. | ModbusDevicePropertyType | false |
| value | Reports the value of property. | string | false |
| updatedAt | Reports the updated timestamp of property. | *metav1.Time | false |
ModbusDevicePropertyType
| Parameter | Description | Schema |
|---|---|---|
| string | Property data type is string. | string |
| int | Property data type is int. | string |
| float | Property data type is float. | string |
| boolean | Property data type is boolean. | string |
ModbusDevicePropertyVisitor
| Parameter | Description | Schema | Required |
|---|---|---|---|
| register | Specifies the register to visit. | ModbusDeviceRegisterType | true |
| offset | Specifies the starting offset of register for read/write data. | int | true |
| quantity | Specifies the quantity of register. | int | true |
| orderOfOperations | Specifies the operations in order if needed. | []ModbusDeviceArithmeticOperation | false |
ModbusDeviceRegisterType
| Parameter | Description | Schema |
|---|---|---|
| CoilRegister | Readable and writable, 1 bit (off/on). | string |
| DiscreteInputRegister | Readonly, 1 bit (off/on). | string |
| InputRegister | Readonly, 16 bits (0 to 65,535), essentially measurements and statuses. | string |
| HoldingRegister | Readable and writable, 16 bits (0 to 65,535), essentially configuration values. | string |
ModbusDeviceArithmeticOperation
| Parameter | Description | Schema | Required |
|---|---|---|---|
| type | Specifies the type of arithmetic operation. | ModbusDeviceArithmeticOperationType | false |
| value | Specifies the value for arithmetic operation, which is in form of float string. | string | false |
ModbusDeviceArithmeticOperationType
| Parameter | Description | Schema |
|---|---|---|
| Add | Arithmetic operation of add. | string |
| Subtract | Arithmetic operation of subtract. | string |
| Multiply | Arithmetic operation of multiply. | string |
| Divide | Arithmetic operation of divide. | string |
ModbusDeviceExtension
| Parameter | Description | Schema | Required |
|---|---|---|---|
| mqtt | Specifies the MQTT settings. | *v1alpha1.MQTTOptionsSpec | false |