eModbus: Invalid CRC (RTU Modbus) - RTU06Example
Describe the bug
When using the RTU06Example with an ESP32-WROOM (NodeMCU) Development Board and Modsim64 as a server. The CRC validation fails when reading registers. It is however able to write to registers without issue.
The connection is made via UART (CP2102) to a Windows host.
Expected behavior
It is expected that CRC validation would succeed in both contexts.
To Reproduce
Install Modsim64 (demo or equivalent) Run Example
Example code
RTU06Example (accessed 29/12/2020) https://github.com/eModbus/eModbus/blob/d0e5329e93290076d271f374ed13c654fbf00ef7/examples/RTU06example/main.cpp
I have also attempted to add CRC to a Modbus Message manually with no difference in the outcome:
ModbusMessage msg = ModbusMessage(1, READ_HOLD_REGISTER, 10, 1);
RTUutils::addCRC(msg);
err = MB.addRequest(msg, Token++);
if (err != SUCCESS)
{
ModbusError e(err);
Serial.printf("Error creating request: %02X - %s\n", (int)e, (const char *)e);
}
Additional context
I have tried using alternative serial configurations (SERIAL8E1, SERIAL8N2, etc.) to no success.
Modbus Messages recorded via Modsim64 (over UART):
CRC Counters:
Register written to successfully:
MCU Output:
Response: serverID=1, FC=6, Token=00000457, length=6:
01 06 00 0A 12 34
Error response: E0 - Timeout
Response: serverID=1, FC=6, Token=00000459, length=6:
01 06 00 0A BE EF
Error response: E0 - Timeout
EDIT: UPDATED incorrect modscan references to modsim.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 54 (29 by maintainers)
Thanks, @Ebrahim1604!
I will leave this open as a question - maybe someone else is having a similar issue and can add some information.
Thank you for your report and kind words. 👍
Initiated by your issue I already did what you are proposing, the advice to change the core code now is part of the Requirements section of the docs.