MAX_MESSAGE_LENGTH and MAX_REGISTERS deviate from Modbus standard
Bug #341702 reported by
n1ywb
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
libmodbus |
Fix Released
|
Medium
|
Stéphane Raimbault |
Bug Description
"#define MAX_MESSAGE_LENGTH 256" is incorrect for Modbus TCP.
Modbus_
RS232 / RS485 ADU = 253 bytes + Server address (1 byte) + CRC (2 bytes) = 256 bytes.
TCP MODBUS ADU = 253 bytes + MBAP (7 bytes) = 260 bytes.
"#define MAX_REGISTERS 100" is incorrect for Modbus.
Modbus_
Quantity of Registers: 2 Bytes: 1 to 125 (0x7D)
Changed in libmodbus: | |
assignee: | nobody → sra |
importance: | Undecided → Medium |
milestone: | none → 2.2.0 |
status: | New → Fix Committed |
Changed in libmodbus: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
This patch against 2.0.2 changes MAX_REGISTERS to 125. It also adds a MAX_MESSAGE_ LENGTH_ RTU and _TCP #defs and a "max_message_ length" field to modbus_params_t which is initialized to the appropriate limit in the init functions. I replaced all references to MAX_MESSAGE_LENGTH with a reference to mb_params- >max_message_ length. It passes unit testing.