Modbus communication fails when using the library, even when debugging mode is disabled #35
Labels
conclusion: resolved
Issue was resolved
topic: code
Related to content of the project itself
type: imperfection
Perceived defect in any part of project
I wrote a sketch for my Opta that reads periodically from the register of a device connected via Modbus, then writes the value in a text file stored on a USB device. Unfortunately, I noticed that when using this library I am no longer able to read from the device using the Modbus channel, as
ModbusRTUClient.read()
returns-1
which corresponds to an error.I suspect this happens because on the Opta the
Arduino_UnifiedStorage
library uses serialRS485
for debug purposes. I setdebuggingModeEnabled
to false in my code, but nothing changed.The only workaround I was able to find is to move the
RS485
and Modbus initialization at the end of mysetup()
code, however it is error prone and I find it odd that theArduino_UnifiedStorage
would change my serial configuration when debugging is disabled. Furthermore, I could not find any documentation on this.I managed to reproduce the issue multiple times, so I will attach the
setup()
code below so you can see how moving the serial and Modbus init code changes the behavior of theModbusRTUClient.read()
:For completeness, I will also attach the full code of the sketch so you can take a look and try to reproduce the issue if you want:
Click to expand
For the record, I tried patching the library by changing
Boards.h
at line 24 like this:but the library would still change my serial configuration. If I can provide further details or assistance just let me know!
The text was updated successfully, but these errors were encountered: