ModbusClient.requestFrom() crashes Finder Opta if id > 247 #151
Labels
topic: code
Related to content of the project itself
type: imperfection
Perceived defect in any part of project
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 :
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 therequestFrom()
method doesn't, this leads to a crash. In other words, the error raised bymodbus-rtu.cpp
is not propagated to therequestFrom()
method.This could be easily fixed by making a simple check.
The text was updated successfully, but these errors were encountered: