From bcde69c92b3f1b7f7ce21a11e802837694f5b308 Mon Sep 17 00:00:00 2001 From: Phil Taylor Date: Sat, 14 May 2022 11:48:58 +0100 Subject: [PATCH] Update commhandler.cpp --- commhandler.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/commhandler.cpp b/commhandler.cpp index bee481a..3b500ef 100644 --- a/commhandler.cpp +++ b/commhandler.cpp @@ -88,7 +88,7 @@ void commHandler::receiveDataFromUserToRig(const QByteArray &data) void commHandler::sendDataOut(const QByteArray &writeData) { // Recycle port to attempt reconnection. - if (!this->isConnected || lastDataReceived.msecsTo(QTime::currentTime()) > 2000) { + if (lastDataReceived.msecsTo(QTime::currentTime()) > 2000) { qDebug(logSerial()) << "Serial port error? Attempting reconnect..."; lastDataReceived = QTime::currentTime(); QTimer::singleShot(500, this, SLOT(init())); @@ -378,8 +378,11 @@ void commHandler::handleError(QSerialPort::SerialPortError err) case QSerialPort::NoError: break; default: - qDebug(logSerial()) << "Serial port" << port->portName() << "Error, attempting disconnect/reconnect"; - QTimer::singleShot(500, this, SLOT(init())); + if (lastDataReceived.msecsTo(QTime::currentTime()) > 2000) { + qDebug(logSerial()) << "Serial port" << port->portName() << "Error, attempting disconnect/reconnect"; + lastDataReceived = QTime::currentTime(); + QTimer::singleShot(500, this, SLOT(init())); + } break; } }