Fix: modbus_tool.py - replace is_connected() with is_socket_open() and fix UnboundLocalError
This commit is contained in:
parent
711341f362
commit
140d2baa24
|
|
@ -65,7 +65,7 @@ def poll_status(slave_id, interval):
|
||||||
|
|
||||||
new_data = {}
|
new_data = {}
|
||||||
try:
|
try:
|
||||||
if not client.is_connected():
|
if not client.is_socket_open():
|
||||||
reconnect_attempts += 1
|
reconnect_attempts += 1
|
||||||
if reconnect_attempts >= max_reconnect_attempts:
|
if reconnect_attempts >= max_reconnect_attempts:
|
||||||
new_data["error"] = f"Failed to reconnect after {max_reconnect_attempts} attempts. Exiting."
|
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))
|
stdscr.addstr(h // 2 + 1, w // 2 - 25, msg.ljust(50))
|
||||||
else:
|
else:
|
||||||
with status_lock: current_data = status_data.copy()
|
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)
|
if current_data.get("error"): stdscr.addstr(0, 0, current_data["error"], curses.color_pair(3) | curses.A_BOLD)
|
||||||
else:
|
else:
|
||||||
bold, normal = curses.color_pair(1) | curses.A_BOLD, curses.color_pair(1)
|
|
||||||
col1, col2, col3, col4 = 2, 30, 58, 88
|
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(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)
|
stdscr.addstr(2, col1, "Movement:", bold); stdscr.addstr(2, col1 + 18, str(current_data.get('movement', 'N/A')), normal)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue