ModBus协议-功能码-0x03



03 (0x03) Read Holding Registers
This function code is used to read the contents of a contiguous block of holding registers in a remote device. The Request PDU specifies the starting register address and the number of registers. In the PDU Registers are addressed starting at zero. Therefore registers numbered 1-16 are addressed as 0-15.
The register data in the response message are packed as two bytes per register, with the binary contents right justified within each byte. For each register, the first byte contains the high order bits and the second contains the low order bits.


ModBus协议-功能码-0x03_第1张图片


The contents of register 108 are shown as the two byte values of 02 2B hex, or 555 decimal. The contents of registers 109–110 are 00 00 and 00 64 hex, or 0 and 100 decimal,respectively.



0x6B = 107
[108,110]

108 02 2B
109 00 00
110 00 64


Tx:01 03 00 6B 00 03
Rx:01 03 06 02 2B 00 00 00 64

发送分析

01 从站

03 功能码

00 6B 起始地址

00 03 读取个数

返回分析

01 从站 

03 功能码

06 读取的字节个数

02 2B 寄存器数值

00 00  寄存器数值

00 64 寄存器数值


异常返回分析

01 83 02

01 从站

83 命令吗 80+03

02 错误号 参看第0节 ModBus Exception codes

注意:当判断返回功能码83的时候同样需要做CRC校验,如果校验通过,则证明是从站返回来的错误提示码,如果不通过则可能是返回命令的时候受到了干扰,很有可能是将03干扰成了83.





ModBus协议-功能码-0x03_第2张图片








你可能感兴趣的:(ModBus协议)