From d127d07cc51f2734f307039a4b7664aed591c819 Mon Sep 17 00:00:00 2001 From: DonLakeFlyer Date: Wed, 8 Jul 2020 10:54:23 -0700 Subject: [PATCH] Serial number based composite usb check --- src/comm/QGCSerialPortInfo.cc | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/src/comm/QGCSerialPortInfo.cc b/src/comm/QGCSerialPortInfo.cc index 3835e8db9..b4fd03b67 100644 --- a/src/comm/QGCSerialPortInfo.cc +++ b/src/comm/QGCSerialPortInfo.cc @@ -294,35 +294,17 @@ QString QGCSerialPortInfo::_boardTypeToString(BoardType_t boardType) QList QGCSerialPortInfo::availablePorts(void) { - // Cube Orange/Yellow are composite devices which expose two usb ports over a single usb connection. - // The first port is the mavlink connection, the second is the SLCAN connection by default. - // We don't expose the second port as being available to QGC. - - static const int hexCubeVID = 11694; - static const int hexCubeOrangePID = 4118; - static const int hexCubeYellowPID = 4114; - - bool cubeOrangeAlreadySeen = false; - bool cubeYellowAlreadySeen = false; - QList list; + QStringList seenSerialNumbers; for(QSerialPortInfo portInfo: QSerialPortInfo::availablePorts()) { if (!isSystemPort(&portInfo)) { - if (portInfo.vendorIdentifier() == hexCubeVID && portInfo.productIdentifier() == hexCubeOrangePID) { - if (cubeOrangeAlreadySeen) { - continue; - } - qCDebug(QGCSerialPortInfoLog) << "Skipping secondary port on Cube Orange" << portInfo.portName(); - cubeOrangeAlreadySeen = true; - } - if (portInfo.vendorIdentifier() == hexCubeVID && portInfo.productIdentifier() == hexCubeYellowPID) { - if (cubeYellowAlreadySeen) { - continue; - } - qCDebug(QGCSerialPortInfoLog) << "Skipping secondary port on Cube Yellow" << portInfo.portName(); - cubeYellowAlreadySeen = true; + 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; } + seenSerialNumbers.append(portInfo.serialNumber()); list << *((QGCSerialPortInfo*)&portInfo); } } -- 2.22.0