Add connection state verification in command execution

- Check serial connection status before sending commands
- Prevent command execution on closed or inactive connections
- Add informative log message when connection is lost
- Enhance robustness of command sending mechanism
This commit is contained in:
2025-02-19 21:51:55 +03:00
parent 7d92682482
commit d3f832cdbb

View File

@@ -633,6 +633,12 @@ def send_command_and_process_response(
):
attempt = 0
while attempt < max_attempts:
# Проверяем, что соединение всё ещё активно
if not serial_connection or not serial_connection.is_open:
if log_callback:
log_callback("[INFO] Соединение закрыто.\n")
return False, None
msg = f"\nОтправка команды: {cmd}\n"
if log_callback:
log_callback(msg)