Skip to main content

Modbus RTU Driver

Overview​

Modbus RTU — a Modbus variant that runs over RS-485 / RS-232 serial. Native rewrite in 2026-07 — the old Apache PLC4j modbus-rtu delegation has been removed. It now uses a native RTU-over-TCP implementation (ModbusRtuOverTcp) from plantpulse-plc-protocol. Serial RTU devices are exposed via a serial-to-TCP converter and registered using host:port — the driver handles TCP sockets only.

ItemValue
opc_typeMODBUS_RTU
Implementation classplantpulse.driver.protocol.modbus.ModbusRTUDriver
LibraryCustom native (plantpulse-plc-protocol of ModbusRtuOverTcp)
InheritanceAbstractNativeModbusDriver (not PLC4j)
read✅
write✅ (coil / holding-register)
SecurityNone (inherent to the Modbus standard)
Not Direct Serial — Requires a Serial-TCP Converter

The native driver only handles TCP sockets. Expose RS-485/232 devices through a serial↔TCP converter (e.g., USR-TCP232, Moxa NPort), and register the converter's IP:port as opc_agent_ip / opc_agent_port. Serial parameters such as baud-rate / parity / stop-bit are configured on the converter side; the driver does not use them.


Class Structure​

AbstractNativeModbusDriver (주소 파싱 · 디코드 · read/write 공통)
└── ModbusRTUDriver — createClient() = new ModbusRtuOverTcp(unitId, host, port)
└── ModbusTCPDriver — createClient() = new ModbusTcp(unitId, host, port)

RTU framing (slave address + PDU + CRC-16 LE) is handled by ModbusRtuOverTcp over the TCP stream.


OPC Registration Options​

FieldMeaningDefault
opc_agent_ipSerial-TCP converter IP192.168.0.60
opc_agent_portConverter TCP portConverter setting (e.g., 502 / 4001)
options.unit-id (alias unit-identifier)Modbus slave ID (1..247)1
options.request-timeoutResponse timeout (ms)5000

Serial parameters such as baud-rate / parity / stop-bits are configured on the converter side — the driver does not receive them.


Tag plc_address Format​

Identical to Modbus TCP — <area>:<address>[:<datatype>][[<count>]] (preserving PLC4X modbus4x syntax, 1-based):

NotationMeaning
coil:1FC 01 — Read Coils
discrete-input:1FC 02 — Read Discrete Inputs
holding-register:1FC 03 — Read Holding Registers (signed 16)
holding-register:1:UINTunsigned 16
holding-register:1:DINTsigned 32 (2 register, MSWord-first)
holding-register:1:REAL32-bit float (2 register)
holding-register:100:STRING[10]10-word ASCII
input-register:1FC 04 — Read Input Registers

For detailed notation rules / data_type · format mapping, see the Modbus TCP Driver page.


Write (Native)​

  • coil:N → single coil write (Boolean).
  • holding-register:N[:TYPE] → register write based on datatype (REAL / DINT = MSWord-first 2 registers; otherwise a single 16-bit).
  • discrete-input / input-register are read-only.

Unsupported Areas​

  • Direct serial port (/dev/ttyUSB0) — not supported. A serial-to-TCP converter is required.
  • Multi-master / token-passing — single master only.
  • Modbus ASCII (colon-delimited, LRC checksum) — RTU framing only.

References​

  • Modbus over Serial Line (V1.02) — Modbus-IDA.
  • Code: plantpulse-edge-driver/src/plantpulse/driver/protocol/modbus/ModbusRTUDriver.java + plantpulse-plc-protocol package in modbus.
  • Operation: Use a serial-to-TCP converter instead of a USB ↔ RS-485 adapter, and verify 120 Ω termination resistors. If unit-id / baud is wrong, you'll only get timeouts.