diff --git a/QGCApplication.pro b/QGCApplication.pro index 61c579de8519fbd0b8181d9f0dd7ec973d040df5..eb7ec6e3cf2817934b0e7b8ad0255481e8bd3ccd 100644 --- a/QGCApplication.pro +++ b/QGCApplication.pro @@ -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 \ diff --git a/src/SerialPortIds.h b/src/SerialPortIds.h new file mode 100644 index 0000000000000000000000000000000000000000..16ec55d8e4408c9ff7efb2971342dd7444bf4f85 --- /dev/null +++ b/src/SerialPortIds.h @@ -0,0 +1,42 @@ +/*===================================================================== + + QGroundControl Open Source Ground Control Station + + (c) 2009 - 2015 QGROUNDCONTROL PROJECT + + 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 . + + ======================================================================*/ + +#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 \ No newline at end of file diff --git a/src/VehicleSetup/PX4FirmwareUpgradeThread.cc b/src/VehicleSetup/PX4FirmwareUpgradeThread.cc index a8c0d7d4797bfe22aa8777db32cc1d9e18590510..484f3162f187bb866ee098b9ad3294b737bb7b34 100644 --- a/src/VehicleSetup/PX4FirmwareUpgradeThread.cc +++ b/src/VehicleSetup/PX4FirmwareUpgradeThread.cc @@ -29,6 +29,7 @@ #include "Bootloader.h" #include "QGCLoggingCategory.h" #include "QGC.h" +#include "SerialPortIds.h" #include #include @@ -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; } } diff --git a/src/VehicleSetup/PX4FirmwareUpgradeThread.h b/src/VehicleSetup/PX4FirmwareUpgradeThread.h index afbe5990d803676d112e3196638d09c79a27ea14..23b35d221234eedac33517fe8a9a53f4ed7d5e94 100644 --- a/src/VehicleSetup/PX4FirmwareUpgradeThread.h +++ b/src/VehicleSetup/PX4FirmwareUpgradeThread.h @@ -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 diff --git a/src/comm/LinkManager.cc b/src/comm/LinkManager.cc index 385dfb7bd4df4dcfb9b0e7bba5b03d5b53bb5f23..8c556888c0570aa2c18278e14518444e22ca174e 100644 --- a/src/comm/LinkManager.cc +++ b/src/comm/LinkManager.cc @@ -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.