A Modbus slave GPIO board is connected via Ethernet cable.
I want the system to reconnect if the cable is disconnected and connected back.
After a certain number of R/W errors or timeouts, I call handler.Close() and the connection is re-initialised as above.
After reconnecting the cable, handler.Connect() does not produce errors, connection is thus established, but at the first R/W operation I get the following error:
I have a Raspberry Pi running this amazing library. A reduced version of the connecting code is:
A Modbus slave GPIO board is connected via Ethernet cable.
I want the system to reconnect if the cable is disconnected and connected back. After a certain number of R/W errors or timeouts, I call
handler.Close()
and the connection is re-initialised as above.After reconnecting the cable,
handler.Connect()
does not produce errors, connection is thus established, but at the first R/W operation I get the following error:dial tcp 192.168.2.80:10001: connect: connection refused
And the cycle repeats endlessly... Unless I restart my application.
Is there a way to re-connect automatically? What am I missing?