From ee713caeb2238ed80dfc6f6c5bf7d7b762588088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Mon, 31 Aug 2026 20:32:41 +0000 Subject: [PATCH] core: services: ardupilot_manager: Return none if board path is gone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GET /board keeps the last USB board after unplug. Signed-off-by: Patrick José Pereira --- core/services/ardupilot_manager/api/v1/routers/index.py | 2 +- core/services/ardupilot_manager/autopilot_manager.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/core/services/ardupilot_manager/api/v1/routers/index.py b/core/services/ardupilot_manager/api/v1/routers/index.py index ea7566653e..57cf75d532 100644 --- a/core/services/ardupilot_manager/api/v1/routers/index.py +++ b/core/services/ardupilot_manager/api/v1/routers/index.py @@ -220,7 +220,7 @@ async def install_firmware_from_file( ) @index_to_http_exception def get_board() -> Any: - return autopilot.current_board + return autopilot.current_board_sanitized @index_router_v1.post("/board", summary="Set board to be used.") diff --git a/core/services/ardupilot_manager/autopilot_manager.py b/core/services/ardupilot_manager/autopilot_manager.py index 0c3a040c2c..fe02d941b3 100644 --- a/core/services/ardupilot_manager/autopilot_manager.py +++ b/core/services/ardupilot_manager/autopilot_manager.py @@ -263,6 +263,13 @@ async def start_mavlink_manager_watchdog(self) -> None: def current_board(self) -> Optional[FlightController]: return self._current_board + @property + def current_board_sanitized(self) -> Optional[FlightController]: + board = self._current_board + if board and board.path and not pathlib.Path(board.path).exists(): + return None + return board + @property def current_sitl_frame(self) -> SITLFrame: return self._current_sitl_frame