Modbus
tcp
常用功能代码
说明 起始地址 参考地址
01
Read coils
读取多个线圈
00001
从 0 开始
02
Read Input Discretes
读取多个离散量输入
10001
从 0 开始
03
Read Multiple
Registers
读取多个保持寄存器
40001
从 0 开始
04
Read Input
Registers
读取多个输入寄存器
30001
从 0 开始
05
Write Singal Coil
写入单个线圈
00001
从 0 开始
06
Write Singal
Register
写入单个寄存器
40001
从 0 开始
15
Force Multiple Coils
强制多个线圈
00001
从 0 开始
16
Force Multiple
Registers
写入多个寄存器
40001
从 0 开始
Read coils (FC 1)
Request
Byte 0: FC = 01
Byte 1-2: Reference number
Byte 3-4: Bit count (1-2000)
Response
Byte 0: FC = 01
Byte 1: Byte count of response (B=(bit count+7)/8)
Byte 2-(B+1): Bit values (least significant bit is first coil!)
Exceptions
Byte 0: FC = 81 (hex)
Byte 1: exception code = 01 or 02
Example
Read 1 coil at reference 0 (00001 in Modicon 984) resulting in value 1
01 00 00 00 01 => 01 01 01
Note that the format of the return data is not consistent with a big-endian architecture. Note also
that this
request can be very computation-intensive on the slave if the request calls for multiple words and
they are