Description
When implementing Modbus RTU on an Opta Finder, with the classical Arduino IDE, in order to read coils on a remote slave (server), we must use the following method :
ArduinoModbus/src/ModbusClient.h
Line 172 in cdae56d
However, the device crashes if the id is greater than 247 as in the following piece of code :
ModbusRTUClient.requestFrom(248, COILS, 0x00, 10)
the RESET LED blinks red and no code is executed. Moreover, we can't upload a sketch anymore onto the device. The RESET button has to be pressed twice in order to make the Opta Finder be recognized again.
The only place in the requestFrom()
method where the id is used here :
ArduinoModbus/src/ModbusClient.cpp
Line 335 in cdae56d
Calling this function:
ArduinoModbus/src/libmodbus/modbus-rtu.cpp
Lines 131 to 144 in cdae56d
Hence, here, a test is performed in order to verify the id of the targeted slave. But as the line modbus_set_slave(_mb, id);
in the requestFrom()
method doesn't, this leads to a crash. In other words, the error raised by modbus-rtu.cpp
is not propagated to the requestFrom()
method.
This could be easily fixed by making a simple check.