From 6d686964e29173192d72e888bdb7b2222cd291aa Mon Sep 17 00:00:00 2001 From: Jeremy Shen Date: Thu, 11 Jun 2026 15:21:36 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20Step=204=20boot=20wait=20?= =?UTF-8?q?uses=20UART=20window=20monitor=20data,=20not=20just=20main=20mo?= =?UTF-8?q?nitor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Root cause: When UART window is open, self._uart_monitor is None (the window creates its own UartMonitor). Step 4 boot wait loop only checked self._uart_monitor.latest_info → always saw empty data → fell through to IP scanning even though UART had detected the IP. Fix: - UartMonitorWindow.get_latest_info() exposes parsed BootInfo - Step 4 checks both: self._uart_monitor first, then UART window - Null guard on info before accessing .ip_address --- src/gui/main_window.py | 18 +++++++++++++----- src/gui/widgets.py | 6 ++++++ 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/gui/main_window.py b/src/gui/main_window.py index a7bc515..e71c663 100644 --- a/src/gui/main_window.py +++ b/src/gui/main_window.py @@ -1144,15 +1144,23 @@ class MainWindow(ctk.CTk): # Wait for board to boot — UART if available, else config delay boot_delay = self._config.boot_wait_delay - uart_alive = (self._uart_monitor is not None - and self._uart_monitor.is_running()) + # Check both main monitor and UART window monitor + uart_alive = False + _uart_src = None # source of latest_info + if self._uart_monitor and self._uart_monitor.is_running(): + uart_alive = True + _uart_src = self._uart_monitor + elif (self._uart_window and self._uart_window.winfo_exists() + and self._uart_window.is_monitoring): + uart_alive = True + _uart_src = self._uart_window discovered_ip: str = "" - if uart_alive: + if uart_alive and _uart_src: self._log_message(f" ⏳ Waiting for UART boot signal (max {boot_delay}s)...") elapsed = 0.0 while elapsed < boot_delay: - info = self._uart_monitor.latest_info - if info.ip_address or info.version: + info = _uart_src.latest_info if hasattr(_uart_src, 'latest_info') else _uart_src.get_latest_info() + if info and (info.ip_address or info.version): self._log_message( f" ✓ Boot detected after {elapsed:.1f}s" f" (IP={info.ip_address}, Ver={info.version})" diff --git a/src/gui/widgets.py b/src/gui/widgets.py index c29a824..420807b 100644 --- a/src/gui/widgets.py +++ b/src/gui/widgets.py @@ -1190,6 +1190,12 @@ class UartMonitorWindow(ctk.CTkToplevel): """True if the UART monitor thread is currently running.""" return self._monitor is not None and self._monitor.is_running() + def get_latest_info(self): + """Return latest parsed BootInfo from the UART monitor, or None.""" + if self._monitor: + return self._monitor.latest_info + return None + def _on_close(self) -> None: """Cleanup UartMonitor and destroy window.""" if self._monitor: