From 6917d469f207e43caa17fd9db6f04e2e06d75a47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Jos=C3=A9=20Pereira?= Date: Thu, 9 May 2019 13:15:16 -0300 Subject: [PATCH] FirmwareUpgradeController: Add availableBoardsName function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Patrick José Pereira --- src/VehicleSetup/FirmwareUpgradeController.cc | 17 +++++++++++++++++ src/VehicleSetup/FirmwareUpgradeController.h | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/src/VehicleSetup/FirmwareUpgradeController.cc b/src/VehicleSetup/FirmwareUpgradeController.cc index 365e5d0d2..97e4a33a7 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 112117f75..6ba76f43f 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); -- 2.22.0