From 140d2baa24528862de5ba5caeaa21214b50e1e09 Mon Sep 17 00:00:00 2001 From: Eduard Iten Date: Wed, 2 Jul 2025 21:05:40 +0200 Subject: [PATCH] Fix: modbus_tool.py - replace is_connected() with is_socket_open() and fix UnboundLocalError --- software/tools/modbus_tool/modbus_tool.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/software/tools/modbus_tool/modbus_tool.py b/software/tools/modbus_tool/modbus_tool.py index fce2423..97e2dff 100755 --- a/software/tools/modbus_tool/modbus_tool.py +++ b/software/tools/modbus_tool/modbus_tool.py @@ -65,7 +65,7 @@ def poll_status(slave_id, interval): new_data = {} try: - if not client.is_connected(): + if not client.is_socket_open(): reconnect_attempts += 1 if reconnect_attempts >= max_reconnect_attempts: new_data["error"] = f"Failed to reconnect after {max_reconnect_attempts} attempts. Exiting." @@ -286,9 +286,9 @@ def main_menu(stdscr, slave_id): stdscr.addstr(h // 2 + 1, w // 2 - 25, msg.ljust(50)) else: with status_lock: current_data = status_data.copy() + bold, normal = curses.color_pair(1) | curses.A_BOLD, curses.color_pair(1) if current_data.get("error"): stdscr.addstr(0, 0, current_data["error"], curses.color_pair(3) | curses.A_BOLD) else: - bold, normal = curses.color_pair(1) | curses.A_BOLD, curses.color_pair(1) col1, col2, col3, col4 = 2, 30, 58, 88 stdscr.addstr(1, col1, "State:", bold); stdscr.addstr(1, col1 + 18, str(current_data.get('state', 'N/A')), normal) stdscr.addstr(2, col1, "Movement:", bold); stdscr.addstr(2, col1 + 18, str(current_data.get('movement', 'N/A')), normal)