Update commhandler.cpp

merge-requests/9/merge
Phil Taylor 2022-05-14 11:48:58 +01:00
rodzic 2e1d88c194
commit bcde69c92b
1 zmienionych plików z 6 dodań i 3 usunięć

Wyświetl plik

@ -88,7 +88,7 @@ void commHandler::receiveDataFromUserToRig(const QByteArray &data)
void commHandler::sendDataOut(const QByteArray &writeData) void commHandler::sendDataOut(const QByteArray &writeData)
{ {
// Recycle port to attempt reconnection. // 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..."; qDebug(logSerial()) << "Serial port error? Attempting reconnect...";
lastDataReceived = QTime::currentTime(); lastDataReceived = QTime::currentTime();
QTimer::singleShot(500, this, SLOT(init())); QTimer::singleShot(500, this, SLOT(init()));
@ -378,8 +378,11 @@ void commHandler::handleError(QSerialPort::SerialPortError err)
case QSerialPort::NoError: case QSerialPort::NoError:
break; break;
default: default:
qDebug(logSerial()) << "Serial port" << port->portName() << "Error, attempting disconnect/reconnect"; if (lastDataReceived.msecsTo(QTime::currentTime()) > 2000) {
QTimer::singleShot(500, this, SLOT(init())); qDebug(logSerial()) << "Serial port" << port->portName() << "Error, attempting disconnect/reconnect";
lastDataReceived = QTime::currentTime();
QTimer::singleShot(500, this, SLOT(init()));
}
break; break;
} }
} }