Fix Serial Ports with dots

Added bool passed to GVRETSerial to indicate when to use TCP,
rather than infering from port name.
This commit is contained in:
Jackson Smith
2018-06-14 22:17:56 -04:00
parent 8934842133
commit 22e1fe64d7
3 changed files with 10 additions and 5 deletions
+2 -2
View File
@@ -11,9 +11,9 @@ CANConnection* CanConFactory::create(type pType, QString pPortName)
case SOCKETCAN: case SOCKETCAN:
return new SerialBusConnection(pPortName); return new SerialBusConnection(pPortName);
case GVRET_SERIAL: case GVRET_SERIAL:
return new GVRetSerial(pPortName); return new GVRetSerial(pPortName, false);
case REMOTE: 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: {} default: {}
} }
+6 -2
View File
@@ -8,7 +8,8 @@
#include "gvretserial.h" #include "gvretserial.h"
GVRetSerial::GVRetSerial(QString portName) : GVRetSerial::GVRetSerial(QString portName, useTcp) :
useTcp(useTcp),
CANConnection(portName, CANCon::GVRET_SERIAL, 3, 4000, true), CANConnection(portName, CANCon::GVRET_SERIAL, 3, 4000, true),
mTimer(this) /*NB: set this as parent of timer to manage it from working thread */ mTimer(this) /*NB: set this as parent of timer to manage it from working thread */
{ {
@@ -284,7 +285,10 @@ void GVRetSerial::connectDevice()
disconnectDevice(); disconnectDevice();
/* open new device */ /* 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"; qDebug() << "TCP Connection to a GVRET device";
tcpClient = new QTcpSocket(); tcpClient = new QTcpSocket();
+2 -1
View File
@@ -42,7 +42,7 @@ class GVRetSerial : public CANConnection
Q_OBJECT Q_OBJECT
public: public:
GVRetSerial(QString portName); GVRetSerial(QString portName, bool useTcp);
virtual ~GVRetSerial(); virtual ~GVRetSerial();
protected: protected:
@@ -82,6 +82,7 @@ protected:
bool gotValidated; bool gotValidated;
bool isAutoRestart; bool isAutoRestart;
bool continuousTimeSync; bool continuousTimeSync;
bool useTcp;
QSerialPort *serial; QSerialPort *serial;
QTcpSocket *tcpClient; QTcpSocket *tcpClient;
int framesRapid; int framesRapid;