|
|
|
@ -150,12 +150,21 @@ bool TCPLink::_hardwareConnect()
@@ -150,12 +150,21 @@ bool TCPLink::_hardwareConnect()
|
|
|
|
|
Q_ASSERT(_socket == nullptr); |
|
|
|
|
_socket = new QTcpSocket(); |
|
|
|
|
|
|
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) |
|
|
|
|
QSignalSpy errorSpy(_socket, static_cast<void (QTcpSocket::*)(QAbstractSocket::SocketError)>(&QTcpSocket::error)); |
|
|
|
|
#else |
|
|
|
|
QSignalSpy errorSpy(_socket, &QAbstractSocket::errorOccurred); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
_socket->connectToHost(_tcpConfig->address(), _tcpConfig->port()); |
|
|
|
|
QObject::connect(_socket, &QTcpSocket::readyRead, this, &TCPLink::readBytes); |
|
|
|
|
|
|
|
|
|
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0) |
|
|
|
|
QObject::connect(_socket,static_cast<void (QTcpSocket::*)(QAbstractSocket::SocketError)>(&QTcpSocket::error), |
|
|
|
|
this, &TCPLink::_socketError); |
|
|
|
|
#else |
|
|
|
|
QObject::connect(_socket, &QAbstractSocket::errorOccurred, this, &TCPLink::_socketError); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// Give the socket a second to connect to the other side otherwise error out
|
|
|
|
|
if (!_socket->waitForConnected(1000)) |
|
|
|
|