Fix up a crash that could happen if a gvret device was not connected when starting savvycan (when it was connected when savvycan closed)

This commit is contained in:
Collin Kidder
2018-07-24 21:36:25 -04:00
parent 6ee5a7f7d7
commit ec6d716ae3
+21 -11
View File
@@ -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;