Unverified Commit 49ef8c14 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #7429 from patrickelectric/firmware_upgrade_devices

Warn user when multiple devices are connected while doing the firmware upgrade
parents 5be9accf 8371c95c
......@@ -130,6 +130,13 @@ SetupPage {
// Board was found right away, so something is already plugged in before we've started upgrade
statusTextArea.append(qgcUnplugText1)
statusTextArea.append(qgcUnplugText2)
var availableDevices = controller.availableBoardsName()
if(availableDevices.length > 1) {
statusTextArea.append(highlightPrefix + qsTr("Multiple devices detected! Remove all detected devices to perform the firmware upgrade."))
statusTextArea.append(qsTr("Detected [%1]: ").arg(availableDevices.length) + availableDevices.join(", "))
}
QGroundControl.multiVehicleManager.activeVehicle.autoDisconnect = true
} else {
// We end up here when we detect a board plugged in after we've started upgrade
......
......@@ -166,6 +166,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;
......
......@@ -146,6 +146,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);
......
......@@ -340,7 +340,7 @@ bool QGCSerialPortInfo::isSystemPort(QSerialPortInfo* port)
return false;
}
bool QGCSerialPortInfo::canFlash(void)
bool QGCSerialPortInfo::canFlash(void) const
{
BoardType_t boardType;
QString name;
......
......@@ -43,7 +43,7 @@ public:
bool getBoardInfo(BoardType_t& boardType, QString& name) const;
/// @return true: we can flash this board type
bool canFlash(void);
bool canFlash(void) const;
/// @return true: Board is currently in bootloader
bool isBootloader(void) const;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment