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:
@@ -342,26 +342,32 @@ void GVRetSerial::connectDevice()
|
|||||||
serial->setBaudRate(115200);
|
serial->setBaudRate(115200);
|
||||||
if (!serial->open(QIODevice::ReadWrite))
|
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->setDataTerminalReady(false); //ESP32 uses these for bootloader selection and reset so turn them off
|
||||||
serial->setRequestToSend(false);
|
serial->setRequestToSend(false);
|
||||||
QTimer::singleShot(3000, this, SLOT(tcpConnected())); //give ESP32 some time as it probably rebooted
|
QTimer::singleShot(3000, this, SLOT(tcpConnected())); //give ESP32 some time as it probably rebooted
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
serial->setFlowControl(serial->HardwareControl); //this is important though
|
serial->setFlowControl(serial->HardwareControl); //this is important though
|
||||||
serial->setBaudRate(1000000);
|
serial->setBaudRate(1000000);
|
||||||
if (!serial->open(QIODevice::ReadWrite))
|
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->setDataTerminalReady(true); //you do need to set these or the fan gets dirty
|
||||||
serial->setRequestToSend(true);
|
serial->setRequestToSend(true);
|
||||||
tcpConnected(); //well, not a proper function name I guess...
|
tcpConnected(); //well, not a proper function name I guess...
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GVRetSerial::tcpConnected()
|
void GVRetSerial::tcpConnected()
|
||||||
{
|
{
|
||||||
@@ -511,9 +517,13 @@ void GVRetSerial::serialError(QSerialPort::SerialPortError err)
|
|||||||
killConnection = true;
|
killConnection = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
if (serial)
|
||||||
|
{
|
||||||
serial->clearError();
|
serial->clearError();
|
||||||
serial->flush();
|
serial->flush();
|
||||||
serial->close();
|
serial->close();
|
||||||
|
}*/
|
||||||
if (errMessage.length() > 1)
|
if (errMessage.length() > 1)
|
||||||
{
|
{
|
||||||
qDebug() << errMessage;
|
qDebug() << errMessage;
|
||||||
|
|||||||
Reference in New Issue
Block a user