-
-
Notifications
You must be signed in to change notification settings - Fork 35
Disconnecting or closing a link #18
Description
Hi bertmelis
Thanks for your efforts with the original ESP32ModbusTCP library.
My setup is a Sunny Boy and Sunny Island. Using your original library (not v1) I am able to read the holdingregisters I need using an ESP32 by creating two Modbus server instances. In the development environment I need to tweak code and upload, which on occasion causes Modbus comms errors to occur. If I kill the ESP32 and wait 3 minutes I get the Modbus back up and running correctly without errors. The .onerror function is reporting the errors but the link rarely recovers on its own. I’m polling 4 registers on the SI and one register on the SB every 1s.
To regain a ModbusTCP connection to the SMA without errors I either need to timeout the link (brute force) or use a library function to close the link and reopen it after a short delay(preferable as it’s more elegant).
I have scanned the ESP32ModbusTCP and AsyncTCP libraries for relevant .close() or similar .disconnect() commands, but can’t find any that seem to work they way I would have thought they worked. For example I want to close and reinstate the link ESP32ModbusTCP sunnyisland(3,{IP},502) by issuing a sunnyisland.close() on an error and then reinstate the link with another ESP32ModbusTCP sunnyisland(3,{IP},502) after a short delay.
Did you implement a TCP link disconnection in your original library? If so could you please share the syntax?
Many thanks
Carl