From fa91de9e4fc5311a6154a401ce1a528976c3830d Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Wed, 13 Feb 2019 20:57:51 -0500 Subject: [PATCH] Tweaks to GVRET code to make it work better with the variety of compatible hardware. --- connections/connectionwindow.cpp | 2 +- connections/gvretserial.cpp | 17 ++++++++--------- connections/gvretserial.h | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/connections/connectionwindow.cpp b/connections/connectionwindow.cpp index 4fbc7a2..158f457 100644 --- a/connections/connectionwindow.cpp +++ b/connections/connectionwindow.cpp @@ -41,7 +41,7 @@ ConnectionWindow::ConnectionWindow(QWidget *parent) : ui->lineSend->setEnabled(false); /* load connection configuration */ - loadConnections(); + //loadConnections(); ui->rbSocketCAN->setEnabled(isSerialBusAvailable()); diff --git a/connections/gvretserial.cpp b/connections/gvretserial.cpp index 74987e7..c3e64f1 100644 --- a/connections/gvretserial.cpp +++ b/connections/gvretserial.cpp @@ -306,7 +306,7 @@ void GVRetSerial::connectDevice() tcpClient = new QTcpSocket(); tcpClient->connectToHost(getPort(), 23); 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"); // */ /* @@ -334,12 +334,11 @@ void GVRetSerial::connectDevice() connect(serial, SIGNAL(error(QSerialPort::SerialPortError)), this, SLOT(serialError(QSerialPort::SerialPortError))); /* configure */ + serial->setBaudRate(1000000); //most GVRET devices ignore baud, ESP32 needs it set explicitly to the proper value serial->setDataBits(serial->Data8); if (espSerialMode) { - serial->setFlowControl(serial->NoFlowControl); - serial->setBaudRate(115200); if (!serial->open(QIODevice::ReadWrite)) { //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->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 - { - serial->setFlowControl(serial->HardwareControl); //this is important though - serial->setBaudRate(1000000); + { if (!serial->open(QIODevice::ReadWrite)) { //qDebug() << serial->errorString(); } else { + serial->setFlowControl(serial->HardwareControl); //this is important though 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... + deviceConnected(); } } } } -void GVRetSerial::tcpConnected() +void GVRetSerial::deviceConnected() { qDebug() << "Connecting to GVRET Device!"; debugOutput("Connecting to GVRET Device!"); diff --git a/connections/gvretserial.h b/connections/gvretserial.h index 9bfdf7f..ac8b7e4 100644 --- a/connections/gvretserial.h +++ b/connections/gvretserial.h @@ -65,7 +65,7 @@ private slots: void connectionTimeout(); void readSerialData(); void serialError(QSerialPort::SerialPortError err); - void tcpConnected(); + void deviceConnected(); void handleTick(); private: