diff --git a/src/VehicleSetup/FirmwareUpgradeController.cc b/src/VehicleSetup/FirmwareUpgradeController.cc index 365e5d0d2599233ad31c2f3bc12125a3fa02404d..97e4a33a786b2faf41603a1b8d1afae7b06b018b 100644 --- a/src/VehicleSetup/FirmwareUpgradeController.cc +++ b/src/VehicleSetup/FirmwareUpgradeController.cc @@ -127,6 +127,23 @@ void FirmwareUpgradeController::cancel(void) _threadController->cancel(); } +QStringList FirmwareUpgradeController::availableBoardsName(void) +{ + QGCSerialPortInfo::BoardType_t boardType; + QString boardName; + QStringList names; + + auto ports = QGCSerialPortInfo::availablePorts(); + for(const auto info : ports) { + if(info.canFlash()) { + info.getBoardInfo(boardType, boardName); + names.append(boardName); + } + } + + return names; +} + void FirmwareUpgradeController::_foundBoard(bool firstAttempt, const QSerialPortInfo& info, int boardType, QString boardName) { _foundBoardInfo = info; diff --git a/src/VehicleSetup/FirmwareUpgradeController.h b/src/VehicleSetup/FirmwareUpgradeController.h index 112117f7575e93012d18d2d72d4fca8f4287b1ac..6ba76f43f1823cf4f064ad365e12552eeb2a6111 100644 --- a/src/VehicleSetup/FirmwareUpgradeController.h +++ b/src/VehicleSetup/FirmwareUpgradeController.h @@ -152,6 +152,13 @@ public: bool pixhawkBoard(void) const { return _foundBoardType == QGCSerialPortInfo::BoardTypePixhawk; } bool px4FlowBoard(void) const { return _foundBoardType == QGCSerialPortInfo::BoardTypePX4Flow; } + /** + * @brief Return a human friendly string of available boards + * + * @return availableBoardNames + */ + Q_INVOKABLE QStringList availableBoardsName(void); + signals: void boardFound(void); void noBoardFound(void);