smarmengol / Modbus-Master-Slave-for-Arduino

Modbus Master-Slave library for Arduino
GNU Lesser General Public License v2.1
473 stars 328 forks source link

Register offset and Modbus Error Code bug #71

Open aliihsancengiz opened 2 years ago

aliihsancengiz commented 2 years ago

Hello , recently found a bug about register offset and modbus error codes. Register Offset(u8regsize) is a uint8_t variable, you cannot exceed address range 255.

When ever you try to read a address(uint16_t) out of the this range , address is down casted to uint8_t and compared to table size in order to decide whether read address is exceeded this range. image

Example case:

Register Table size 250. Intended register read adress is 2000. In that case we expect an EXC_ADDR_RANGE error code but we got successfull reading.

image

Modbus Frames decomposition

image

image

But if we want to read register at offset 509.

image

Modbus Frames decomposition

image

image