From 6feb451d776cd5cac93dadc38db326d3b2026ce5 Mon Sep 17 00:00:00 2001 From: Don Gagne Date: Sat, 20 Jun 2020 08:26:25 -0700 Subject: [PATCH] Special case handling for Cube Orange/Yellow --- ChangeLog.md | 3 ++- src/comm/QGCSerialPortInfo.cc | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/ChangeLog.md b/ChangeLog.md index 739a03f93..4a2c6c520 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -14,8 +14,9 @@ Note: This file only contains high level features or important fixes. ## 4.0 -## 4.0.8 - Not yet released +## 4.0.9 - Not yet released +* Don't auto-connect to second Cube Orange/Yellow composite port * Plan: Fix bugs associated with mission commands which specify and altitude but no lat/lon * Fix bug which could prevent view switching from working after altitude mode warning dialog would pop up diff --git a/src/comm/QGCSerialPortInfo.cc b/src/comm/QGCSerialPortInfo.cc index 4cf191454..3835e8db9 100644 --- a/src/comm/QGCSerialPortInfo.cc +++ b/src/comm/QGCSerialPortInfo.cc @@ -294,10 +294,35 @@ 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; 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; + } list << *((QGCSerialPortInfo*)&portInfo); } } -- 2.22.0