diff --git a/libs/serialport/qserialport_unix.cpp b/libs/serialport/qserialport_unix.cpp index 2f6c8ccbafa734f578db1aca5a6abfeedfbbb9a8..92d9f2f4c554419b41a31501276ccb19a0412bfd 100644 --- a/libs/serialport/qserialport_unix.cpp +++ b/libs/serialport/qserialport_unix.cpp @@ -429,7 +429,8 @@ bool QSerialPortPrivate::waitForReadyRead(int msecs) bool timedOut = false; if (!waitForReadOrWrite(&readyToRead, &readyToWrite, true, !writeBuffer.isEmpty(), timeoutValue(msecs, stopWatch.elapsed()), &timedOut)) { - q_ptr->setError(decodeSystemError()); + if (!timedOut) + q_ptr->setError(decodeSystemError()); return false; } @@ -460,7 +461,8 @@ bool QSerialPortPrivate::waitForBytesWritten(int msecs) bool timedOut = false; if (!waitForReadOrWrite(&readyToRead, &readyToWrite, true, !writeBuffer.isEmpty(), timeoutValue(msecs, stopWatch.elapsed()), &timedOut)) { - q_ptr->setError(decodeSystemError()); + if (!timedOut) + q_ptr->setError(decodeSystemError()); return false; } diff --git a/src/comm/SerialLink.cc b/src/comm/SerialLink.cc index e8bf610881b2553474c35c5b1678283b0329471e..cf92e8f34962495334d99cabfa61ac163415c838 100644 --- a/src/comm/SerialLink.cc +++ b/src/comm/SerialLink.cc @@ -26,7 +26,6 @@ SerialLink::SerialLink(QString portname, int baudRate, bool hardwareFlowControl, m_stopp(false), m_reqReset(false) { - // Get the name of the current port in use. m_portName = portname.trimmed(); if (m_portName == "" && getCurrentPorts().size() > 0) @@ -445,7 +444,13 @@ bool SerialLink::hardwareConnect() void SerialLink::linkError(QSerialPort::SerialPortError error) { - qDebug() << error; + if (error != QSerialPort::NoError) { + // You can use the following qDebug output as needed during development. Make sure to comment it back out + // when you are done. The reason for this is that this signal is very noisy. For example if you try to + // connect to a PixHawk before it is ready to accept the connection it will output a continuous stream + // of errors until the Pixhawk responds. + //qDebug() << "SerialLink::linkError" << error; + } } diff --git a/src/comm/SerialLink.h b/src/comm/SerialLink.h index df3877907b7030f08fa74d2f3ed0e89cac3984ad..4effbfc9ba80eab65e4b0595e5365f0b86cf6649 100644 --- a/src/comm/SerialLink.h +++ b/src/comm/SerialLink.h @@ -36,10 +36,14 @@ This file is part of the QGROUNDCONTROL project #include #include #include -#include #include #include "SerialLinkInterface.h" +// We use QSerialPort::SerialPortError in a signal so we must declare it as a meta type +#include +#include +Q_DECLARE_METATYPE(QSerialPort::SerialPortError) + /** * @brief The SerialLink class provides cross-platform access to serial links. * It takes care of the link management and provides a common API to higher diff --git a/src/comm/TCPLink.h b/src/comm/TCPLink.h index 43d160f87797a6f49e2039a188ee626e7b9fedd7..b7e7fe72e7796e698acbb4c9e2f94dfbb5d9ed2a 100644 --- a/src/comm/TCPLink.h +++ b/src/comm/TCPLink.h @@ -34,10 +34,16 @@ #include #include #include -#include #include #include +// Even though QAbstractSocket::SocketError is used in a signal by Qt, Qt doesn't declare it as a meta type. +// This in turn causes debug output to be kicked out about not being able to queue the signal. We declare it +// as a meta type to silence that. +#include +#include +Q_DECLARE_METATYPE(QAbstractSocket::SocketError) + //#define TCPLINK_READWRITE_DEBUG // Use to debug data reads/writes class TCPLink : public LinkInterface diff --git a/src/main.cc b/src/main.cc index a660902b98adc548abd0131a3006c655a6a67c9f..1b0e8846a8ebf0a2ca3123528a0c922d7f295072 100644 --- a/src/main.cc +++ b/src/main.cc @@ -32,6 +32,8 @@ This file is part of the QGROUNDCONTROL project #include "QGCCore.h" #include "MainWindow.h" #include "configuration.h" +#include "SerialLink.h" +#include "TCPLink.h" #ifdef QT_DEBUG #include "AutoTest.h" #endif @@ -70,6 +72,13 @@ int main(int argc, char *argv[]) #ifdef Q_OS_WIN qInstallMsgHandler( msgHandler ); #endif + + // The following calls to qRegisterMetaType are done to silence debug output which warns + // that we use these types in signals, and without calling qRegisterMetaType we can't queue + // these signals. In general we don't queue these signals, but we do what the warning says + // anyway to silence the debug output. + qRegisterMetaType(); + qRegisterMetaType(); #ifdef QT_DEBUG if (argc > 1 && QString(argv[1]).compare("--unittest", Qt::CaseInsensitive) == 0) {