From 0807173f1fdb5c8919ae79995e7ec4d989b5bd68 Mon Sep 17 00:00:00 2001 From: Jacob Walser Date: Mon, 8 Jul 2019 17:45:15 -0400 Subject: [PATCH] fixup new port selection --- src/sensor/protocoldetector.cpp | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/sensor/protocoldetector.cpp b/src/sensor/protocoldetector.cpp index 570bb8d15..96c81d87a 100644 --- a/src/sensor/protocoldetector.cpp +++ b/src/sensor/protocoldetector.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include #include "pingmessage/ping_ping1d.h" @@ -52,9 +53,28 @@ void ProtocolDetector::doScan() // QThread::msleep(500); auto current = QSerialPortInfo::availablePorts(); if (current.size() > start.size()) { - auto portInfo = current.last(); + +// auto difference = current.toSet().subtract(start.toSet()); +// auto newDeviceList = difference.toList(); +// auto portInfo = newDeviceList.last(); + QSerialPortInfo portInfo; + for (auto p1 : current) { + + bool found = true; + for (auto p2 : start) { + if (p1.portName() == p2.portName()) { + found = false; + break; + } + } + if (found) { + portInfo = p1; + break; + } + } + //qCDebug(PING_PROTOCOL_PROTOCOLDETECTOR) << current; - qCDebug(PING_PROTOCOL_PROTOCOLDETECTOR) << portInfo.manufacturer() << portInfo.portName(); + qCDebug(PING_PROTOCOL_PROTOCOLDETECTOR) << portInfo.manufacturer() << portInfo.portName() << portInfo.systemLocation(); QSerialPort p(portInfo); while (!p.open(QIODevice::ReadWrite)); p.setBaudRate(115200);