fix: guard UART window creation with try-except to prevent silent crash
On Windows the UartMonitorWindow could crash instantly without any error message. Added try-except around window creation in _read_serial so errors are logged instead of silently killing the window. Also added empty port guard before attempting to open.
This commit is contained in:
+13
-5
@@ -1585,12 +1585,20 @@ class MainWindow(ctk.CTk):
|
||||
|
||||
def _read_serial(self) -> None:
|
||||
"""Open the UART Monitor window."""
|
||||
port = self._port_var.get()
|
||||
port = self._port_var.get().strip()
|
||||
if not port:
|
||||
self._log_message(" ✗ No serial port selected")
|
||||
return
|
||||
baudrate = self._config.serial_baudrate if self._config else 115200
|
||||
self._uart_window = UartMonitorWindow(
|
||||
self, port=port, baudrate=baudrate,
|
||||
on_log=self._log_message,
|
||||
)
|
||||
try:
|
||||
self._uart_window = UartMonitorWindow(
|
||||
self, port=port, baudrate=baudrate,
|
||||
on_log=self._log_message,
|
||||
)
|
||||
except Exception as e:
|
||||
self._log_message(f" ✗ Failed to open UART window: {e}")
|
||||
import traceback
|
||||
self._log_message(traceback.format_exc())
|
||||
|
||||
def _test_serial_version(self) -> None:
|
||||
"""Test serial port by sending 'ver()' command and parsing response."""
|
||||
|
||||
Reference in New Issue
Block a user