CIRCUITSTATE / CSE_ModbusRTU

Arduino library for implementing Modbus RTU communication protocols using hardware/software serial ports.
MIT License
6 stars 1 forks source link

Wrong forming response packet for Holding registers !!! #4

Closed jkedesign closed 7 months ago

jkedesign commented 8 months ago

You forgot to send data in the response packet about the length of the bytes being transferred!!! For Holding Registers in Modbus Server (Slave) mode

Wrong: Tx:01 03 00 00 00 04 44 09 Rx:01 03 00 00 00 00 00 00 00 00 35 32 True: Tx:01 03 00 00 00 04 44 09 Rx:01 03 08 00 00 00 00 00 00 00 00 95 D7

*) Add in source code in CSE_ModbusRTU.cpp (I checked it works): response.add(byteCount); // Set the byte count of the response

vishnumaiea commented 7 months ago

You are right @jkedesign. I forgot to add the byteCount when responding to read requests of the Holding Registers as well as the Input Registers. I have applied the fix and it will be available in the next release.

Thanks 😊