Commit 0f851eea authored by Don Gagne's avatar Don Gagne

Merge pull request #1693 from DonLakeFlyer/VendorProductId

Better handling of vendor and product ids
parents 68fd43e3 5a771e5f
......@@ -268,6 +268,7 @@ HEADERS += \
src/QmlControls/MavManager.h \
src/QmlControls/ParameterEditorController.h \
src/QmlControls/ScreenToolsController.h \
src/SerialPortIds.h \
src/uas/QGCMAVLinkUASFactory.h \
src/uas/FileManager.h \
src/uas/UAS.h \
......
/*=====================================================================
QGroundControl Open Source Ground Control Station
(c) 2009 - 2015 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
This file is part of the QGROUNDCONTROL project
QGROUNDCONTROL is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
QGROUNDCONTROL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with QGROUNDCONTROL. If not, see <http://www.gnu.org/licenses/>.
======================================================================*/
#ifndef SerialPortIds_H
#define SerialPortIds_H
// SerialPortInfo Vendor and Product Ids for known boards
class SerialPortIds {
public:
static const int px4VendorId = 9900; ///< Vendor ID for Pixhawk board (V2 and V1) and PX4 Flow
static const int pixhawkFMUV2ProductId = 17; ///< Product ID for Pixhawk V2 board
static const int pixhawkFMUV1ProductId = 16; ///< Product ID for PX4 FMU V1 board
static const int px4FlowProductId = 21; ///< Product ID for PX4 Flow board
static const int threeDRRadioVendorId = 1027; ///< Vendor ID for 3DR Radio
static const int threeDRRadioProductId = 24597; ///< Product ID for 3DR Radio
};
#endif
......@@ -29,6 +29,7 @@
#include "Bootloader.h"
#include "QGCLoggingCategory.h"
#include "QGC.h"
#include "SerialPortIds.h"
#include <QTimer>
#include <QSerialPortInfo>
......@@ -145,24 +146,29 @@ bool PX4FirmwareUpgradeThreadWorker::_findBoardFromPorts(QSerialPortInfo& portIn
#endif
if (!info.portName().isEmpty()) {
if (info.vendorIdentifier() == _px4VendorId) {
if (info.productIdentifier() == _pixhawkFMUV2ProductId) {
qCDebug(FirmwareUpgradeLog) << "Found PX4 FMU V2";
type = FoundBoardPX4FMUV2;
found = true;
} else if (info.productIdentifier() == _pixhawkFMUV1ProductId) {
qCDebug(FirmwareUpgradeLog) << "Found PX4 FMU V1";
type = FoundBoardPX4FMUV2;
found = true;
} else if (info.productIdentifier() == _flowProductId) {
qCDebug(FirmwareUpgradeLog) << "Found PX4 Flow";
type = FoundBoardPX4Flow;
found = true;
}
} else if (info.vendorIdentifier() == _3drRadioVendorId && info.productIdentifier() == _3drRadioProductId) {
qCDebug(FirmwareUpgradeLog) << "Found 3DR Radio";
type = FoundBoard3drRadio;
found = true;
switch (info.vendorIdentifier()) {
case SerialPortIds::px4VendorId:
if (info.productIdentifier() == SerialPortIds::pixhawkFMUV2ProductId) {
qCDebug(FirmwareUpgradeLog) << "Found PX4 FMU V2";
type = FoundBoardPX4FMUV2;
found = true;
} else if (info.productIdentifier() == SerialPortIds::pixhawkFMUV1ProductId) {
qCDebug(FirmwareUpgradeLog) << "Found PX4 FMU V1";
type = FoundBoardPX4FMUV2;
found = true;
} else if (info.productIdentifier() == SerialPortIds::px4FlowProductId) {
qCDebug(FirmwareUpgradeLog) << "Found PX4 Flow";
type = FoundBoardPX4Flow;
found = true;
}
break;
case SerialPortIds::threeDRRadioVendorId:
if (info.productIdentifier() == SerialPortIds::threeDRRadioProductId) {
qCDebug(FirmwareUpgradeLog) << "Found 3DR Radio";
type = FoundBoard3drRadio;
found = true;
}
break;
}
}
......
......@@ -100,17 +100,6 @@ private:
bool _foundBoard; ///< true: board is currently connected
bool _findBoardFirstAttempt; ///< true: this is our first try looking for a board
QSerialPortInfo _foundBoardPortInfo; ///< port info for found board
// Serial port info for supported devices
static const int _px4VendorId = 9900;
static const int _pixhawkFMUV2ProductId = 17;
static const int _pixhawkFMUV1ProductId = 16;
static const int _flowProductId = 21;
static const int _3drRadioVendorId = 1027;
static const int _3drRadioProductId = 24597;
};
/// @brief Provides methods to interact with the bootloader. The commands themselves are signalled
......
......@@ -45,6 +45,7 @@ This file is part of the QGROUNDCONTROL project
#include "MainWindow.h"
#include "QGCMessageBox.h"
#include "QGCApplication.h"
#include "SerialPortIds.h"
IMPLEMENT_QGC_SINGLETON(LinkManager, LinkManager)
QGC_LOGGING_CATEGORY(LinkManagerLog, "LinkManagerLog")
......@@ -493,7 +494,7 @@ void LinkManager::_updateConfigurationList(void)
// Save port name
currentPorts << portInfo.systemLocation();
// Is this a PX4 and NOT in bootloader mode?
if (portInfo.vendorIdentifier() == 9900 && !portInfo.description().contains("BL")) {
if (portInfo.vendorIdentifier() == SerialPortIds::px4VendorId && !portInfo.description().contains("BL")) {
SerialConfiguration* pSerial = _findSerialConfiguration(portInfo.systemLocation());
if (pSerial) {
//-- If this port is configured make sure it has the preferred flag set
......@@ -521,7 +522,7 @@ void LinkManager::_updateConfigurationList(void)
}
}
// Is this an FTDI Chip? It could be a 3DR Modem
if (portInfo.vendorIdentifier() == 1027) {
if (portInfo.vendorIdentifier() == SerialPortIds::threeDRRadioVendorId && portInfo.productIdentifier() == SerialPortIds::threeDRRadioProductId) {
SerialConfiguration* pSerial = _findSerialConfiguration(portInfo.systemLocation());
if (pSerial) {
//-- If this port is configured make sure it has the preferred flag set, unless someone else already has it set.
......
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