From ec6d716ae3be20aa854baff87fe75aac67c96042 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Tue, 24 Jul 2018 21:36:25 -0400 Subject: [PATCH] Fix up a crash that could happen if a gvret device was not connected when starting savvycan (when it was connected when savvycan closed) --- connections/gvretserial.cpp | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/connections/gvretserial.cpp b/connections/gvretserial.cpp index 5a1a211..9479a36 100644 --- a/connections/gvretserial.cpp +++ b/connections/gvretserial.cpp @@ -342,11 +342,14 @@ void GVRetSerial::connectDevice() serial->setBaudRate(115200); if (!serial->open(QIODevice::ReadWrite)) { - qDebug() << serial->errorString(); + //qDebug() << serial->errorString(); + } + else + { + serial->setDataTerminalReady(false); //ESP32 uses these for bootloader selection and reset so turn them off + serial->setRequestToSend(false); + QTimer::singleShot(3000, this, SLOT(tcpConnected())); //give ESP32 some time as it probably rebooted } - serial->setDataTerminalReady(false); //ESP32 uses these for bootloader selection and reset so turn them off - serial->setRequestToSend(false); - QTimer::singleShot(3000, this, SLOT(tcpConnected())); //give ESP32 some time as it probably rebooted } else { @@ -354,11 +357,14 @@ void GVRetSerial::connectDevice() serial->setBaudRate(1000000); if (!serial->open(QIODevice::ReadWrite)) { - qDebug() << serial->errorString(); + //qDebug() << serial->errorString(); + } + else + { + serial->setDataTerminalReady(true); //you do need to set these or the fan gets dirty + serial->setRequestToSend(true); + tcpConnected(); //well, not a proper function name I guess... } - serial->setDataTerminalReady(true); //you do need to set these or the fan gets dirty - serial->setRequestToSend(true); - tcpConnected(); //well, not a proper function name I guess... } } } @@ -511,9 +517,13 @@ void GVRetSerial::serialError(QSerialPort::SerialPortError err) killConnection = true; break; } - serial->clearError(); - serial->flush(); - serial->close(); + /* + if (serial) + { + serial->clearError(); + serial->flush(); + serial->close(); + }*/ if (errMessage.length() > 1) { qDebug() << errMessage;