Decompose requests¶
Modbus requests and responses contain an Application Data Unit (ADU) which contains a Protocol Data Unit (PDU). The ADU is an envelope containing a message, the PDU is the message itself. Modbus requests can be sent via two communication layers, RTU or TCP/IP. The ADU for these layers differs. But the PDU, the message, always has the same strcuture, regardless of the way it’s transported.
PDU¶
Note
This section is based on MODBUS Application Protocol Specification V1.1b3
The Protocol Data Unit (PDU) is the request or response message and is indepedent of the underlying communication layer. This module only implements requests PDU’s.
A request PDU contains two parts: a function code and request data. A response PDU contains the function code from the request and response data. The general structure is listed in table below:
Field | Size (bytes) |
Function code | 1 |
data | N |
Below you see the request PDU with function code 1, requesting status of 3 coils, starting from coil 100.
>>> req_pdu = b'\x01