Unverified Commit 85d7f06e authored by Don Gagne's avatar Don Gagne Committed by GitHub

Fix composite USB detection (#9069)

Co-authored-by: 's avatarDon Gagne <dongagne@outlook.com>
parent e76d49f6
......@@ -113,8 +113,6 @@ linux {
} else {
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
}
#-- Not forcing anything. Let qmake find the latest, installed SDK.
QMAKE_MAC_SDK = macosx10.15
QMAKE_CXXFLAGS += -fvisibility=hidden
QMAKE_CXXFLAGS_WARN_ON += -Werror \
-Wno-unused-parameter # gst-plugins-good
......
......@@ -81,7 +81,7 @@ void MultiVehicleManager::_vehicleHeartbeatInfo(LinkInterface* link, int vehicle
// Special case for PX4 Flow
if (vehicleId != 81 || componentId != 50) {
// Don't create vehicles for components other than the autopilot
qCDebug(MultiVehicleManagerLog()) << "Ignoring heartbeat from unknown component "
qCDebug(MultiVehicleManagerLog()) << "Ignoring heartbeat from unknown component port:vehicleId:componentId:fwType:vehicleType"
<< link->getName()
<< vehicleId
<< componentId
......
......@@ -294,17 +294,22 @@ QString QGCSerialPortInfo::_boardTypeToString(BoardType_t boardType)
QList<QGCSerialPortInfo> QGCSerialPortInfo::availablePorts(void)
{
QList<QGCSerialPortInfo> list;
QStringList seenSerialNumbers;
typedef QPair<quint16, quint16> VidPidPair_t;
for(QSerialPortInfo portInfo: QSerialPortInfo::availablePorts()) {
QList<QGCSerialPortInfo> list;
QMap<VidPidPair_t, QStringList> seenSerialNumbers;
for (QSerialPortInfo portInfo: QSerialPortInfo::availablePorts()) {
if (!isSystemPort(&portInfo)) {
if (seenSerialNumbers.contains(portInfo.serialNumber())) {
// Some boards are a composite USB device, with the first port being mavlink and the second something else
qCDebug(QGCSerialPortInfoLog) << "Skipping secondary port on same device" << portInfo.portName() << portInfo.serialNumber();
continue;
if (portInfo.hasVendorIdentifier() && portInfo.hasProductIdentifier() && !portInfo.serialNumber().isEmpty() && portInfo.serialNumber() != "0") {
VidPidPair_t vidPid(portInfo.vendorIdentifier(), portInfo.productIdentifier());
if (seenSerialNumbers.contains(vidPid) && seenSerialNumbers[vidPid].contains(portInfo.serialNumber())) {
// Some boards are a composite USB device, with the first port being mavlink and the second something else. We only expose to first mavlink port.
qCDebug(QGCSerialPortInfoLog) << "Skipping secondary port on same device" << portInfo.portName() << portInfo.vendorIdentifier() << portInfo.productIdentifier() << portInfo.serialNumber();
continue;
}
seenSerialNumbers[vidPid].append(portInfo.serialNumber());
}
seenSerialNumbers.append(portInfo.serialNumber());
list << *((QGCSerialPortInfo*)&portInfo);
}
}
......
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