Commit 2c68aa23 authored by Thomas BOUTROUE's avatar Thomas BOUTROUE

Allow changing wait delay for connection

parent a105e73f
......@@ -13,6 +13,7 @@ const QString CanDriver_cobsTcp::CACHE_ALL = QS ("cacheAll");
const QString CanDriver_cobsTcp::CACHE_LAST = QS ("cacheLast");
const QString CanDriver_cobsTcp::LOOPBACK = QS ("loopback");
const QString CanDriver_cobsTcp::FORCE_FLUSH = QS ("forceFlush");
const QString CanDriver_cobsTcp::WAIT_DELAY = QS ("waitDelay");
CanDriver_cobsTcp::CobsEncodeStatusFlags CanDriver_cobsTcp::cobsEncode (const qbyte * srcPtr,
const qsize srcLen,
......@@ -149,6 +150,7 @@ bool CanDriver_cobsTcp::init (const QVariantMap & options) {
const bool serv = options.value (SERV, false).value<bool> ();
const bool loop = options.value (LOOPBACK, false).value<bool> ();
const bool flush = options.value (FORCE_FLUSH, false).value<bool> ();
const int delay = options.value (WAIT_DELAY, 3000).value<int> ();
const quint16 port = options.value (PORT, 0).value<quint16> ();
const QString host = options.value (HOST, "localhost").value<QString> ();
const QVariantList cacheAll = options.value (CACHE_ALL).value<QVariantList> ();
......@@ -177,7 +179,7 @@ bool CanDriver_cobsTcp::init (const QVariantMap & options) {
if (actualPort > 0 && !host.isEmpty ()) {
diag (Information, QS ("Initializing COBS socket driver with host %1 and port %2...").arg (host).arg (actualPort));
m_socket->connectToHost (host, actualPort, QTcpSocket::ReadWrite, QTcpSocket::IPv4Protocol);
if (m_socket->waitForConnected (3000)) {
if (m_socket->waitForConnected (delay)) {
ret = true;
diag (Information, QS ("COBS socket driver connected."));
}
......
......@@ -59,6 +59,7 @@ public:
static const QString CACHE_LAST;
static const QString LOOPBACK;
static const QString FORCE_FLUSH;
static const QString WAIT_DELAY;
enum CobsEncodeStatusFlag {
COBS_ENCODE_OK = 0x00,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment