diff --git a/src/comm/SerialLink.cc b/src/comm/SerialLink.cc index ac628f91e332e2452b38bc07fa1802ac42e3b1df..d1e09d1dbf90c27388417c2e9dd7172f4b3d5693 100644 --- a/src/comm/SerialLink.cc +++ b/src/comm/SerialLink.cc @@ -99,19 +99,11 @@ QList SerialLink::getCurrentPorts() m_ports.clear(); QList portList = QSerialPortInfo::availablePorts(); - - if( portList.count() == 0){ - qDebug() << "No Ports Found" << m_ports; - } - foreach (const QSerialPortInfo &info, portList) { -// qDebug() << "PortName : " << info.portName() -// << "Description : " << info.description(); -// qDebug() << "Manufacturer: " << info.manufacturer(); - m_ports.append(info.portName()); } + return m_ports; } diff --git a/src/ui/SerialConfigurationWindow.cc b/src/ui/SerialConfigurationWindow.cc index a6fd2cfa169ef2db847800c61de10c5b9b783de1..052043e5d7416494426ad4f77bd792246a7935ab 100644 --- a/src/ui/SerialConfigurationWindow.cc +++ b/src/ui/SerialConfigurationWindow.cc @@ -55,7 +55,10 @@ SerialConfigurationWindow::SerialConfigurationWindow(LinkInterface* link, QWidge action = new QAction(QIcon(":/files/images/devices/network-wireless.svg"), "", this); setLinkName(link->getName()); - setupPortList(); + // Scan for serial ports. Let the user know if none were found for debugging purposes + if (!setupPortList()) { + qDebug() << "No serial ports found."; + } // Set up baud rates ui.baudRate->clear(); @@ -213,9 +216,9 @@ void SerialConfigurationWindow::configureCommunication() this->show(); } -void SerialConfigurationWindow::setupPortList() +bool SerialConfigurationWindow::setupPortList() { - if (!link) return; + if (!link) return false; // Get the ports available on this system QList ports = link->getCurrentPorts(); @@ -240,6 +243,8 @@ void SerialConfigurationWindow::setupPortList() if (storedFound) ui.portName->setEditText(storedName); + + return (ports.count() > 0); } void SerialConfigurationWindow::enableFlowControl(bool flow) diff --git a/src/ui/SerialConfigurationWindow.h b/src/ui/SerialConfigurationWindow.h index 41a95f59df246c71e4dba5fc0bc4120e5b79d075..57b8600ed8b8ac0f295ceeb67d73bfb95b49a9e3 100644 --- a/src/ui/SerialConfigurationWindow.h +++ b/src/ui/SerialConfigurationWindow.h @@ -60,7 +60,13 @@ public slots: void setParityEven(bool accept); void setPortName(QString port); void setLinkName(QString name); - void setupPortList(); + /** + * @brief setupPortList Populates the dropdown with the list of available serial ports. + * This function is called at 1s intervals to check that the serial port still exists and to see if + * any new ones have been attached. + * @return True if any ports were found, false otherwise. + */ + bool setupPortList(); protected: void showEvent(QShowEvent* event);