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