From 5c56bd037ad6cbfa6d91f442f4d6b935baf6976b Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Thu, 28 Dec 2017 21:25:08 +0100 Subject: [PATCH] Serial links: Do not connect to known system peripherals We were connecting to system peripherals before, which adds boot delay as QGC re-tries opening the port. We were also opening serial ports two times on Mac OS: Once as /dev/cu.usbmodem1 and once as /dev/tty.usbmodem1 - since the cu.usbmodem alias was already open, the 2nd opening always failed, leading to further boot delay. --- src/comm/LinkManager.cc | 7 +++++++ src/comm/QGCSerialPortInfo.cc | 21 +++++++++++++++++++++ src/comm/QGCSerialPortInfo.h | 3 +++ 3 files changed, 31 insertions(+) diff --git a/src/comm/LinkManager.cc b/src/comm/LinkManager.cc index c115728a4..f4cdd0a04 100644 --- a/src/comm/LinkManager.cc +++ b/src/comm/LinkManager.cc @@ -501,6 +501,13 @@ void LinkManager::_updateAutoConnectLinks(void) QString boardName; if (portInfo.getBoardInfo(boardType, boardName)) { + + if (portInfo.isSystemPort()) { + // Don't connect to system ports + qCDebug(LinkManagerLog) << "Not opening known system ports" << portInfo.systemLocation(); + continue; + } + if (portInfo.isBootloader()) { // Don't connect to bootloader qCDebug(LinkManagerLog) << "Waiting for bootloader to finish" << portInfo.systemLocation(); diff --git a/src/comm/QGCSerialPortInfo.cc b/src/comm/QGCSerialPortInfo.cc index 1f07da7d2..8eabe4e24 100644 --- a/src/comm/QGCSerialPortInfo.cc +++ b/src/comm/QGCSerialPortInfo.cc @@ -271,6 +271,27 @@ bool QGCSerialPortInfo::isBootloader(void) const } } +bool QGCSerialPortInfo::isSystemPort(void) const +{ + // Known operating system peripherals that are NOT a drone + + // These are known Mac OS ports that + // are never connected to a drone but instead + // to other system peripherals. + if (systemLocation().contains("tty.MALS") + || systemLocation().contains("tty.SOC") + || systemLocation().contains("tty.Bluetooth-Incoming-Port") + // We open these by their cu.usbserial and cu.usbmodem handles + // already. We don't want to open them twice and conflict + // with ourselves. + || systemLocation().contains("tty.usbserial") + || systemLocation().contains("tty.usbmodem")) { + + return true; + } + return false; +} + bool QGCSerialPortInfo::canFlash(void) { BoardType_t boardType; diff --git a/src/comm/QGCSerialPortInfo.h b/src/comm/QGCSerialPortInfo.h index 0148da2f0..23b4c7cbe 100644 --- a/src/comm/QGCSerialPortInfo.h +++ b/src/comm/QGCSerialPortInfo.h @@ -49,6 +49,9 @@ public: /// @return true: Board is currently in bootloader bool isBootloader(void) const; + /// @return true: Port is a system port and not an autopilot + bool isSystemPort(void) const; + private: typedef struct { const char* classString; -- 2.22.0