fix: handle connection loss and re-establish in modbus_tool.py

This commit is contained in:
Eduard Iten 2025-07-02 10:03:23 +02:00
parent 2418d4e218
commit b54c73edb1
1 changed files with 5 additions and 5 deletions

View File

@ -225,11 +225,11 @@ def main_menu(stdscr, slave_id):
elif selected_option == "Set Watchdog": elif selected_option == "Set Watchdog":
input_mode, input_prompt, input_target_reg = True, "Enter Watchdog Timeout (s): ", REG_HOLDING_WATCHDOG_TIMEOUT_S input_mode, input_prompt, input_target_reg = True, "Enter Watchdog Timeout (s): ", REG_HOLDING_WATCHDOG_TIMEOUT_S
elif selected_option == "Reset Node": elif selected_option == "Reset Node":
try:
client.write_register(REG_HOLDING_DEVICE_RESET, 1, slave=slave_id) client.write_register(REG_HOLDING_DEVICE_RESET, 1, slave=slave_id)
message = "-> Sent RESET command" message = "-> Sent RESET command. Node should reboot."
elif selected_option == "Firmware Update": except Exception as e:
client.write_register(REG_HOLDING_DEVICE_RESET, 1, slave=slave_id) message = f"-> Error sending reset: {e}"
message = "-> Sent RESET command"
elif selected_option == "Firmware Update": elif selected_option == "Firmware Update":
filepath = file_browser(stdscr) filepath = file_browser(stdscr)
if filepath: if filepath: