From 66cdc3ae2708ddd0b0b4f53cbbc60bf795e63526 Mon Sep 17 00:00:00 2001 From: Eduard Iten Date: Fri, 11 Jul 2025 08:53:16 +0200 Subject: [PATCH] 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 --- software/tools/modbus_tool/modbus_tool.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/software/tools/modbus_tool/modbus_tool.py b/software/tools/modbus_tool/modbus_tool.py index 8d4dfb9..a46251d 100755 --- a/software/tools/modbus_tool/modbus_tool.py +++ b/software/tools/modbus_tool/modbus_tool.py @@ -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)