近日犯了一个低级错误:老是以为0x0F 功能码的register 对应的是16bit.
|
Description
|
Size
(Byte)
|
Definition
|
Header
|
Transaction Identifier
|
2
|
Sequence number/ 顺序号
|
Protocol Identifier
|
2
|
0x0000
|
Length
|
2
|
XX
|
Unit Identifier
|
1
|
0xFF
|
Modbus Data
|
Function Code
|
1
|
0x0F
|
Starting Address
|
2
|
The start address the Master wants to write 写起始地址
|
Quality of outputs
|
2
|
Quality of outputs 输出数量
|
Byte Count
|
1
|
N=Quality of outputs/ 8,如果余数不等于0,则N =Quality of outputs/ 8+1
|
Data
|
N
|
Outputs Value
|
其中:
Starting Address 对应的是bit -------register
Quality of outputs 是bit个数
得记住了, 这个常常被搞混!