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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user