fix: Force UI redraw on successful Modbus reconnection
Implemented a mechanism to force a full UI redraw in the Modbus tool upon successful reconnection to the serial port. The function now sets a flag in the shared status data, which is then detected by the function. Upon detection, clears the screen and removes the flag, ensuring that any stale error messages are cleared and the UI is fully refreshed. Signed-off-by: Eduard Iten <eduard@iten.pro>
This commit is contained in:
parent
32bb77926f
commit
66cdc3ae27
|
|
@ -79,7 +79,9 @@ def poll_status(slave_id, interval):
|
|||
# Attempt to connect
|
||||
if client.connect():
|
||||
reconnect_attempts = 0
|
||||
new_data["error"] = None # Clear error on successful reconnect
|
||||
with status_lock:
|
||||
status_data["error"] = None # Clear error in status_data immediately
|
||||
time.sleep(0.1) # Allow UI to refresh with cleared error
|
||||
else:
|
||||
new_data["error"] = f"Connection lost. Attempting to reconnect ({reconnect_attempts}/{max_reconnect_attempts})..."
|
||||
time.sleep(reconnect_delay)
|
||||
|
|
|
|||
Loading…
Reference in New Issue