Tweaks to GVRET code to make it work better with the variety of

compatible hardware.
This commit is contained in:
Collin Kidder
2019-02-13 20:57:51 -05:00
parent a138968e85
commit fa91de9e4f
3 changed files with 10 additions and 11 deletions
+1 -1
View File
@@ -41,7 +41,7 @@ ConnectionWindow::ConnectionWindow(QWidget *parent) :
ui->lineSend->setEnabled(false); ui->lineSend->setEnabled(false);
/* load connection configuration */ /* load connection configuration */
loadConnections(); //loadConnections();
ui->rbSocketCAN->setEnabled(isSerialBusAvailable()); ui->rbSocketCAN->setEnabled(isSerialBusAvailable());
+8 -9
View File
@@ -306,7 +306,7 @@ void GVRetSerial::connectDevice()
tcpClient = new QTcpSocket(); tcpClient = new QTcpSocket();
tcpClient->connectToHost(getPort(), 23); tcpClient->connectToHost(getPort(), 23);
connect(tcpClient, SIGNAL(readyRead()), this, SLOT(readSerialData())); connect(tcpClient, SIGNAL(readyRead()), this, SLOT(readSerialData()));
connect(tcpClient, SIGNAL(connected()), this, SLOT(tcpConnected())); connect(tcpClient, SIGNAL(connected()), this, SLOT(deviceConnected()));
debugOutput("Created TCP Socket"); debugOutput("Created TCP Socket");
// */ // */
/* /*
@@ -334,12 +334,11 @@ void GVRetSerial::connectDevice()
connect(serial, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(serialError(QSerialPort::SerialPortError))); connect(serial, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(serialError(QSerialPort::SerialPortError)));
/* configure */ /* configure */
serial->setBaudRate(1000000); //most GVRET devices ignore baud, ESP32 needs it set explicitly to the proper value
serial->setDataBits(serial->Data8); serial->setDataBits(serial->Data8);
if (espSerialMode) if (espSerialMode)
{ {
serial->setFlowControl(serial->NoFlowControl);
serial->setBaudRate(115200);
if (!serial->open(QIODevice::ReadWrite)) if (!serial->open(QIODevice::ReadWrite))
{ {
//qDebug() << serial->errorString(); //qDebug() << serial->errorString();
@@ -348,28 +347,28 @@ void GVRetSerial::connectDevice()
{ {
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 serial->setFlowControl(serial->NoFlowControl);
QTimer::singleShot(3000, this, SLOT(deviceConnected())); //give ESP32 some time as it could have rebooted
} }
} }
else else
{ {
serial->setFlowControl(serial->HardwareControl); //this is important though
serial->setBaudRate(1000000);
if (!serial->open(QIODevice::ReadWrite)) if (!serial->open(QIODevice::ReadWrite))
{ {
//qDebug() << serial->errorString(); //qDebug() << serial->errorString();
} }
else else
{ {
serial->setFlowControl(serial->HardwareControl); //this is important though
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... deviceConnected();
} }
} }
} }
} }
void GVRetSerial::tcpConnected() void GVRetSerial::deviceConnected()
{ {
qDebug() << "Connecting to GVRET Device!"; qDebug() << "Connecting to GVRET Device!";
debugOutput("Connecting to GVRET Device!"); debugOutput("Connecting to GVRET Device!");
+1 -1
View File
@@ -65,7 +65,7 @@ private slots:
void connectionTimeout(); void connectionTimeout();
void readSerialData(); void readSerialData();
void serialError(QSerialPort::SerialPortError err); void serialError(QSerialPort::SerialPortError err);
void tcpConnected(); void deviceConnected();
void handleTick(); void handleTick();
private: private: