From f345642b034bb04228225599da30cd77e3875719 Mon Sep 17 00:00:00 2001 From: Collin Kidder Date: Thu, 17 May 2018 20:41:19 -0400 Subject: [PATCH] Fixes to gvret serial for use with TCP/IP connection --- connections/gvretserial.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/connections/gvretserial.cpp b/connections/gvretserial.cpp index 83a53ec..ff0a1d0 100644 --- a/connections/gvretserial.cpp +++ b/connections/gvretserial.cpp @@ -72,12 +72,6 @@ void GVRetSerial::sendToSerial(const QByteArray &bytes) void GVRetSerial::piStarted() { connectDevice(); - - /* start timer */ - connect(&mTimer, SIGNAL(timeout()), this, SLOT(handleTick())); - mTimer.setInterval(250); //tick four times per second - mTimer.setSingleShot(false); //keep ticking - mTimer.start(); } @@ -287,12 +281,14 @@ void GVRetSerial::connectDevice() /* open new device */ if (getPort().contains('.')) //TCP/IP mode then since it looks like an IP address { + qDebug() << "TCP Connection to a GVRET device"; tcpClient = new QTcpSocket(); tcpClient->connectToHost(getPort(), 23); connect(tcpClient, SIGNAL(readyRead()), this, SLOT(readSerialData())); connect(tcpClient, SIGNAL(connected()), this, SLOT(tcpConnected())); } else { + qDebug() << "Serial connection to a GVRET device"; serial = new QSerialPort(QSerialPortInfo(getPort())); if(!serial) { qDebug() << "can't open serial port " << getPort(); @@ -362,6 +358,12 @@ void GVRetSerial::tcpConnected() sendToSerial(output); + /* start timer */ + connect(&mTimer, SIGNAL(timeout()), this, SLOT(handleTick())); + mTimer.setInterval(250); //tick four times per second + mTimer.setSingleShot(false); //keep ticking + mTimer.start(); + if(doValidation) { QTimer::singleShot(1000, this, SLOT(connectionTimeout())); }