Commit 9c4f4c6e authored by Don Gagne's avatar Don Gagne

parent 67b72725
...@@ -383,8 +383,7 @@ SetupPage { ...@@ -383,8 +383,7 @@ SetupPage {
anchors.right: parent.right anchors.right: parent.right
visible: !px4Flow && apmFlightStack.checked && !controller.downloadingFirmwareList && controller.apmFirmwareNames.length !== 0 visible: !px4Flow && apmFlightStack.checked && !controller.downloadingFirmwareList && controller.apmFirmwareNames.length !== 0
model: controller.apmFirmwareNames model: controller.apmFirmwareNames
onModelChanged: currentIndex = controller.apmFirmwareNamesBestIndex
onModelChanged: console.log("model", model)
} }
QGCLabel { QGCLabel {
......
...@@ -730,52 +730,47 @@ void FirmwareUpgradeController::_buildAPMFirmwareNames(void) ...@@ -730,52 +730,47 @@ void FirmwareUpgradeController::_buildAPMFirmwareNames(void)
QString boardDescription = _foundBoardInfo.description(); QString boardDescription = _foundBoardInfo.description();
quint16 boardVID = _foundBoardInfo.vendorIdentifier(); quint16 boardVID = _foundBoardInfo.vendorIdentifier();
quint16 boardPID = _foundBoardInfo.productIdentifier(); quint16 boardPID = _foundBoardInfo.productIdentifier();
uint32_t rawBoardId = _bootloaderBoardID == Bootloader::boardIDPX4FMUV3 ? Bootloader::boardIDPX4FMUV2 : _bootloaderBoardID;
#if 0
// This is left in for debugging manifest problems
boardDescription = "KakuteF7";
boardVID = 1155;
boardPID = 22336;
#endif
qCDebug(FirmwareUpgradeLog) << QStringLiteral("_buildAPMFirmwareNames description(%1) vid(%2/0x%3) pid(%4/0x%5)").arg(boardDescription).arg(boardVID).arg(boardVID, 1, 16).arg(boardPID).arg(boardPID, 1, 16); qCDebug(FirmwareUpgradeLog) << QStringLiteral("_buildAPMFirmwareNames description(%1) vid(%2/0x%3) pid(%4/0x%5)").arg(boardDescription).arg(boardVID).arg(boardVID, 1, 16).arg(boardPID).arg(boardPID, 1, 16);
_apmFirmwareNames.clear(); _apmFirmwareNames.clear();
_apmFirmwareNamesBestIndex = -1;
_apmFirmwareUrls.clear(); _apmFirmwareUrls.clear();
QString apmDescriptionSuffix("-BL"); QString apmDescriptionSuffix("-BL");
QString boardDescriptionPrefix;
bool bootloaderMatch = boardDescription.endsWith(apmDescriptionSuffix); bool bootloaderMatch = boardDescription.endsWith(apmDescriptionSuffix);
int currentIndex = 0;
for (const ManifestFirmwareInfo_t& firmwareInfo: _rgManifestFirmwareInfo) { for (const ManifestFirmwareInfo_t& firmwareInfo: _rgManifestFirmwareInfo) {
bool match = false; bool match = false;
if (firmwareInfo.firmwareBuildType == _selectedFirmwareBuildType && firmwareInfo.chibios == chibios && firmwareInfo.vehicleType == vehicleType) { if (firmwareInfo.firmwareBuildType == _selectedFirmwareBuildType && firmwareInfo.chibios == chibios && firmwareInfo.vehicleType == vehicleType && firmwareInfo.boardId == rawBoardId) {
if (bootloaderMatch) { if (firmwareInfo.fmuv2 && _bootloaderBoardID == Bootloader::boardIDPX4FMUV3) {
if (firmwareInfo.rgBootloaderPortString.contains(boardDescription)) { qCDebug(FirmwareUpgradeLog) << "Skipping fmuv2 manifest entry for fmuv3 board:" << firmwareInfo.friendlyName << boardDescription << firmwareInfo.rgBootloaderPortString << firmwareInfo.url << firmwareInfo.vehicleType;
qCDebug(FirmwareUpgradeLog) << "Bootloader match:" << firmwareInfo.friendlyName << boardDescription << firmwareInfo.rgBootloaderPortString << firmwareInfo.url << firmwareInfo.vehicleType;
match = true;
}
} else { } else {
if (firmwareInfo.rgVID.contains(boardVID) && firmwareInfo.rgPID.contains(boardPID)) { qCDebug(FirmwareUpgradeLog) << "Board id match:" << firmwareInfo.friendlyName << boardDescription << firmwareInfo.rgBootloaderPortString << firmwareInfo.url << firmwareInfo.vehicleType;
qCDebug(FirmwareUpgradeLog) << "VID/PID match:" << firmwareInfo.friendlyName << boardVID << boardPID << _bootloaderBoardID << firmwareInfo.url << firmwareInfo.vehicleType; match = true;
match = true; if (bootloaderMatch && _apmFirmwareNamesBestIndex == -1 && firmwareInfo.rgBootloaderPortString.contains(boardDescription)) {
_apmFirmwareNamesBestIndex = currentIndex;
qCDebug(FirmwareUpgradeLog) << "Bootloader best match:" << firmwareInfo.friendlyName << boardDescription << firmwareInfo.rgBootloaderPortString << firmwareInfo.url << firmwareInfo.vehicleType;
} }
} }
} }
// Do a final filter on fmuv2/fmuv3
if (match && _bootloaderBoardID == Bootloader::boardIDPX4FMUV3) {
match = !firmwareInfo.fmuv2;
}
if (match) { if (match) {
_apmFirmwareNames.append(firmwareInfo.friendlyName); _apmFirmwareNames.append(firmwareInfo.friendlyName);
_apmFirmwareUrls.append(firmwareInfo.url); _apmFirmwareUrls.append(firmwareInfo.url);
currentIndex++;
} }
} }
if (_apmFirmwareNames.count() > 1) { if (_apmFirmwareNamesBestIndex == -1) {
_apmFirmwareNames.prepend(tr("Choose board type")); _apmFirmwareNamesBestIndex++;
_apmFirmwareUrls.prepend(QString()); if (_apmFirmwareNames.count() > 1) {
_apmFirmwareNames.prepend(tr("Choose board type"));
_apmFirmwareUrls.prepend(QString());
}
} }
emit apmFirmwareNamesChanged(); emit apmFirmwareNamesChanged();
......
...@@ -94,6 +94,7 @@ public: ...@@ -94,6 +94,7 @@ public:
Q_PROPERTY(bool px4FlowBoard READ px4FlowBoard NOTIFY boardFound) Q_PROPERTY(bool px4FlowBoard READ px4FlowBoard NOTIFY boardFound)
Q_PROPERTY(FirmwareBuildType_t selectedFirmwareBuildType READ selectedFirmwareBuildType WRITE setSelectedFirmwareBuildType NOTIFY selectedFirmwareBuildTypeChanged) Q_PROPERTY(FirmwareBuildType_t selectedFirmwareBuildType READ selectedFirmwareBuildType WRITE setSelectedFirmwareBuildType NOTIFY selectedFirmwareBuildTypeChanged)
Q_PROPERTY(QStringList apmFirmwareNames MEMBER _apmFirmwareNames NOTIFY apmFirmwareNamesChanged) Q_PROPERTY(QStringList apmFirmwareNames MEMBER _apmFirmwareNames NOTIFY apmFirmwareNamesChanged)
Q_PROPERTY(int apmFirmwareNamesBestIndex MEMBER _apmFirmwareNamesBestIndex NOTIFY apmFirmwareNamesChanged)
Q_PROPERTY(QStringList apmFirmwareUrls MEMBER _apmFirmwareUrls NOTIFY apmFirmwareNamesChanged) Q_PROPERTY(QStringList apmFirmwareUrls MEMBER _apmFirmwareUrls NOTIFY apmFirmwareNamesChanged)
Q_PROPERTY(QString px4StableVersion READ px4StableVersion NOTIFY px4StableVersionChanged) Q_PROPERTY(QString px4StableVersion READ px4StableVersion NOTIFY px4StableVersionChanged)
Q_PROPERTY(QString px4BetaVersion READ px4BetaVersion NOTIFY px4BetaVersionChanged) Q_PROPERTY(QString px4BetaVersion READ px4BetaVersion NOTIFY px4BetaVersionChanged)
...@@ -308,6 +309,7 @@ private: ...@@ -308,6 +309,7 @@ private:
QMap<QString, FirmwareBuildType_t> _manifestMavFirmwareVersionTypeToFirmwareBuildTypeMap; QMap<QString, FirmwareBuildType_t> _manifestMavFirmwareVersionTypeToFirmwareBuildTypeMap;
QMap<QString, FirmwareVehicleType_t> _manifestMavTypeToFirmwareVehicleTypeMap; QMap<QString, FirmwareVehicleType_t> _manifestMavTypeToFirmwareVehicleTypeMap;
QStringList _apmFirmwareNames; QStringList _apmFirmwareNames;
int _apmFirmwareNamesBestIndex = 0;
QStringList _apmFirmwareUrls; QStringList _apmFirmwareUrls;
Fact* _apmChibiOSSetting; Fact* _apmChibiOSSetting;
Fact* _apmVehicleTypeSetting; Fact* _apmVehicleTypeSetting;
......
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