Browse Source

Filter serial port handles already in initial list

This ensures no ports are being displayed to the user that are definitely unusable.
QGC4.4
Lorenz Meier 7 years ago
parent
commit
971aa24d2b
  1. 6
      src/comm/LinkManager.cc
  2. 27
      src/comm/QGCSerialPortInfo.cc
  3. 2
      src/comm/QGCSerialPortInfo.h

6
src/comm/LinkManager.cc

@ -502,12 +502,6 @@ void LinkManager::_updateAutoConnectLinks(void) @@ -502,12 +502,6 @@ void LinkManager::_updateAutoConnectLinks(void)
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();

27
src/comm/QGCSerialPortInfo.cc

@ -252,7 +252,9 @@ QList<QGCSerialPortInfo> QGCSerialPortInfo::availablePorts(void) @@ -252,7 +252,9 @@ QList<QGCSerialPortInfo> QGCSerialPortInfo::availablePorts(void)
QList<QGCSerialPortInfo> list;
foreach(QSerialPortInfo portInfo, QSerialPortInfo::availablePorts()) {
list << *((QGCSerialPortInfo*)&portInfo);
if (!isSystemPort(&portInfo)) {
list << *((QGCSerialPortInfo*)&portInfo);
}
}
return list;
@ -271,21 +273,22 @@ bool QGCSerialPortInfo::isBootloader(void) const @@ -271,21 +273,22 @@ bool QGCSerialPortInfo::isBootloader(void) const
}
}
bool QGCSerialPortInfo::isSystemPort(void) const
bool QGCSerialPortInfo::isSystemPort(QSerialPortInfo* port)
{
// 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")
// Known operating system peripherals that are NEVER a peripheral
// that we should connect to.
// XXX Add Linux (LTE modems, etc) and Windows as needed
// MAC OS
if (port->systemLocation().contains("tty.MALS")
|| port->systemLocation().contains("tty.SOC")
|| port->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")) {
|| port->systemLocation().contains("tty.usbserial")
|| port->systemLocation().contains("tty.usbmodem")) {
return true;
}

2
src/comm/QGCSerialPortInfo.h

@ -50,7 +50,7 @@ public: @@ -50,7 +50,7 @@ public:
bool isBootloader(void) const;
/// @return true: Port is a system port and not an autopilot
bool isSystemPort(void) const;
static bool isSystemPort(QSerialPortInfo* port);
private:
typedef struct {

Loading…
Cancel
Save