From 22e1fe64d7fae1a2f406ee0049413ca6de7b7e7b Mon Sep 17 00:00:00 2001 From: Jackson Smith Date: Thu, 14 Jun 2018 22:17:56 -0400 Subject: [PATCH 1/2] Fix Serial Ports with dots Added bool passed to GVRETSerial to indicate when to use TCP, rather than infering from port name. --- connections/canconfactory.cpp | 4 ++-- connections/gvretserial.cpp | 8 ++++++-- connections/gvretserial.h | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/connections/canconfactory.cpp b/connections/canconfactory.cpp index 5042ac0..55e1727 100644 --- a/connections/canconfactory.cpp +++ b/connections/canconfactory.cpp @@ -11,9 +11,9 @@ CANConnection* CanConFactory::create(type pType, QString pPortName) case SOCKETCAN: return new SerialBusConnection(pPortName); case GVRET_SERIAL: - return new GVRetSerial(pPortName); + return new GVRetSerial(pPortName, false); case REMOTE: - return new GVRetSerial(pPortName); //it's a special case of GVRET connected over TCP/IP so it uses the same class + return new GVRetSerial(pPortName, true); //it's a special case of GVRET connected over TCP/IP so it uses the same class default: {} } diff --git a/connections/gvretserial.cpp b/connections/gvretserial.cpp index 4aa1540..79d5a8d 100644 --- a/connections/gvretserial.cpp +++ b/connections/gvretserial.cpp @@ -8,7 +8,8 @@ #include "gvretserial.h" -GVRetSerial::GVRetSerial(QString portName) : +GVRetSerial::GVRetSerial(QString portName, useTcp) : + useTcp(useTcp), CANConnection(portName, CANCon::GVRET_SERIAL, 3, 4000, true), mTimer(this) /*NB: set this as parent of timer to manage it from working thread */ { @@ -284,7 +285,10 @@ void GVRetSerial::connectDevice() disconnectDevice(); /* open new device */ - if (getPort().contains('.')) //TCP/IP mode then since it looks like an IP address + + // this does the wrong thing if the serial port has a '.' in the name + // if (getPort().contains('.')) //TCP/IP mode then since it looks like an IP address + if (useTcp) { qDebug() << "TCP Connection to a GVRET device"; tcpClient = new QTcpSocket(); diff --git a/connections/gvretserial.h b/connections/gvretserial.h index 6a54ad6..efff041 100644 --- a/connections/gvretserial.h +++ b/connections/gvretserial.h @@ -42,7 +42,7 @@ class GVRetSerial : public CANConnection Q_OBJECT public: - GVRetSerial(QString portName); + GVRetSerial(QString portName, bool useTcp); virtual ~GVRetSerial(); protected: @@ -82,6 +82,7 @@ protected: bool gotValidated; bool isAutoRestart; bool continuousTimeSync; + bool useTcp; QSerialPort *serial; QTcpSocket *tcpClient; int framesRapid; From fca08a91a7a1891dc5df7a10402f87b291ddf9d5 Mon Sep 17 00:00:00 2001 From: Jackson Smith Date: Thu, 14 Jun 2018 22:40:44 -0400 Subject: [PATCH 2/2] Fix silly mistake --- connections/gvretserial.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/connections/gvretserial.cpp b/connections/gvretserial.cpp index 79d5a8d..efee5f3 100644 --- a/connections/gvretserial.cpp +++ b/connections/gvretserial.cpp @@ -8,9 +8,9 @@ #include "gvretserial.h" -GVRetSerial::GVRetSerial(QString portName, useTcp) : - useTcp(useTcp), +GVRetSerial::GVRetSerial(QString portName, bool useTcp) : CANConnection(portName, CANCon::GVRET_SERIAL, 3, 4000, true), + useTcp(useTcp), mTimer(this) /*NB: set this as parent of timer to manage it from working thread */ { qDebug() << "GVRetSerial()";