77#include < QtNetwork>
88
99#include " gvretserial.h"
10+ #include " canconmanager.h"
1011
1112GVRetSerial::GVRetSerial (QString portName, bool useTcp) :
1213 CANConnection(portName, " gvret" , CANCon::GVRET_SERIAL , 0 , 0 , false , 0 , 3 , 4000 , true ),
@@ -21,7 +22,6 @@ GVRetSerial::GVRetSerial(QString portName, bool useTcp) :
2122 rx_state = IDLE ;
2223 rx_step = 0 ;
2324 validationCounter = 10 ; // how many times we can miss validation before we die
24- isAutoRestart = false ;
2525 espSerialMode = true ;
2626
2727 timeBasis = 0 ;
@@ -236,8 +236,6 @@ bool GVRetSerial::piSendFrame(const CommFrame& frame)
236236
237237 // qDebug() << "Sending out GVRET frame with id " << frame.ID << " on bus " << frame.bus;
238238
239- framesRapid++;
240-
241239 if (serial == nullptr && tcpClient == nullptr && udpClient == nullptr ) return false ;
242240 if (serial && !serial->isOpen ()) return false ;
243241 if (tcpClient && !tcpClient->isOpen ()) return false ;
@@ -307,16 +305,16 @@ void GVRetSerial::connectDevice()
307305 sendDebug (" TCP Connection to a GVRET device" );
308306 tcpClient = new QTcpSocket ();
309307 tcpClient->connectToHost (getPort (), 23 );
310- connect (tcpClient, SIGNAL ( readyRead ()) , this , SLOT ( readSerialData ()) );
311- connect (tcpClient, SIGNAL ( connected ()) , this , SLOT ( deviceConnected ()) );
308+ connect (tcpClient, &QTcpSocket:: readyRead, this , &GVRetSerial:: readSerialData);
309+ connect (tcpClient, &QTcpSocket:: connected, this , &GVRetSerial:: deviceConnected);
312310 sendDebug (" Created TCP Socket" );
313311 // */
314312 /*
315313 qDebug() << "UDP Connection to a GVRET device";
316314 udpClient = new QUdpSocket();
317315 udpClient->connectToHost(getPort(), 17222);
318- connect(udpClient, SIGNAL( readyRead()) , this, SLOT( readSerialData()) );
319- //connect(udpClient, SIGNAL( connected()) , this, SLOT( tcpConnected()) );
316+ connect(udpClient, &QUdpSocket:: readyRead, this, &GVRetSerial:: readSerialData);
317+ //connect(udpClient, &QUdpSocket:: connected, this, &GVRetSerial:: tcpConnected);
320318 debugOutput("Created UDP Socket");
321319 tcpConnected();
322320 */
@@ -331,8 +329,8 @@ void GVRetSerial::connectDevice()
331329 sendDebug (" Created Serial Port Object" );
332330
333331 /* connect reading event */
334- connect (serial, SIGNAL ( readyRead ()) , this , SLOT ( readSerialData ()) );
335- connect (serial, SIGNAL ( error ( QSerialPort::SerialPortError)) , this , SLOT ( serialError (QSerialPort::SerialPortError)) );
332+ connect (serial, &QSerialPort:: readyRead, this , &GVRetSerial:: readSerialData);
333+ connect (serial, & QSerialPort::errorOccurred , this , &GVRetSerial::serialError );
336334
337335 /* configure */
338336 serial->setBaudRate (1000000 ); // most GVRET devices ignore baud, ESP32 needs it set explicitly to the proper value
@@ -350,7 +348,7 @@ void GVRetSerial::connectDevice()
350348 {
351349 serial->setDataTerminalReady (false ); // ESP32 uses these for bootloader selection and reset so turn them off
352350 serial->setRequestToSend (false );
353- QTimer::singleShot (3000 , this , SLOT ( deviceConnected ()) ); // give ESP32 some time as it could have rebooted
351+ QTimer::singleShot (3000 , this , &GVRetSerial:: deviceConnected); // give ESP32 some time as it could have rebooted
354352 }
355353 }
356354 else
@@ -410,7 +408,7 @@ void GVRetSerial::deviceConnected()
410408 sendToSerial (output);
411409
412410 if (doValidation) {
413- QTimer::singleShot (5000 , this , SLOT ( connectionTimeout ()) );
411+ QTimer::singleShot (5000 , this , &GVRetSerial:: connectionTimeout);
414412 }
415413 else {
416414 setStatus (CANCon::CONNECTED );
@@ -563,7 +561,7 @@ void GVRetSerial::connectionTimeout()
563561 else
564562 {
565563 /* start timer */
566- connect (&mTimer , SIGNAL ( timeout ()) , this , SLOT ( handleTick ()) );
564+ connect (&mTimer , &QTimer:: timeout, this , &GVRetSerial:: handleTick);
567565 mTimer .setInterval (250 ); // tick four times per second
568566 mTimer .setSingleShot (false ); // keep ticking
569567 mTimer .start ();
@@ -943,13 +941,13 @@ void GVRetSerial::procRXChar(unsigned char c)
943941 stats.numHardwareBuses = mNumBuses ;
944942 emit status (stats);
945943
946- int can0Status = 0x78 ; // updating everything we can update
947- int can1Status = 0x78 ;
948- if (can0Enabled) can0Status +=1 ;
949- if (can0ListenOnly) can0Status += 4 ;
950- if (can1Enabled) can1Status += 1 ;
951- if (deviceSingleWireMode > 0 ) can1Status += 2 ;
952- if (can1ListenOnly) can1Status += 4 ;
944+ // int can0Status = 0x78; //updating everything we can update
945+ // int can1Status = 0x78;
946+ // if (can0Enabled) can0Status +=1;
947+ // if (can0ListenOnly) can0Status += 4;
948+ // if (can1Enabled) can1Status += 1;
949+ // if (deviceSingleWireMode > 0) can1Status += 2;
950+ // if (can1ListenOnly) can1Status += 4;
953951 // emit busStatus(busBase, can0Baud & 0xFFFFF, can0Status);
954952 // emit busStatus(busBase + 1, can1Baud & 0xFFFFF, can1Status);
955953 break ;
@@ -1122,7 +1120,7 @@ void GVRetSerial::handleTick()
11221120
11231121 disconnectDevice (); // start by stopping everything.
11241122 // Then wait 500ms and restart the connection automatically
1125- // QTimer::singleShot(500, this, SLOT( connectDevice()) );
1123+ // QTimer::singleShot(500, this, &GVRetSerial:: connectDevice);
11261124 return ;
11271125 }
11281126 }
0 commit comments