10
10
#include " SerialLink.h"
11
11
#include " QGCLoggingCategory.h"
12
12
#include " QGCSerialPortInfo.h"
13
- #ifdef Q_OS_ANDROID
14
- #include " qserialportinfo.h"
15
- #else
16
- #include < QtSerialPort/QSerialPortInfo>
17
- #endif
18
13
#include < QtCore/QSettings>
19
14
#include < QtCore/QThread>
20
15
#include < QtCore/QTimer>
@@ -32,20 +27,20 @@ namespace {
32
27
SerialConfiguration::SerialConfiguration (const QString &name, QObject *parent)
33
28
: LinkConfiguration(name, parent)
34
29
{
35
- // qCDebug(SerialLinkLog) << Q_FUNC_INFO << this;
30
+ // qCDebug(SerialLinkLog) << this;
36
31
}
37
32
38
33
SerialConfiguration::SerialConfiguration (const SerialConfiguration *source, QObject *parent)
39
34
: LinkConfiguration(source, parent)
40
35
{
41
- // qCDebug(SerialLinkLog) << Q_FUNC_INFO << this;
36
+ // qCDebug(SerialLinkLog) << this;
42
37
43
38
SerialConfiguration::copyFrom (source);
44
39
}
45
40
46
41
SerialConfiguration::~SerialConfiguration ()
47
42
{
48
- // qCDebug(SerialLinkLog) << Q_FUNC_INFO << this;
43
+ // qCDebug(SerialLinkLog) << this;
49
44
}
50
45
51
46
void SerialConfiguration::setPortName (const QString &name)
@@ -142,7 +137,7 @@ SerialWorker::SerialWorker(const SerialConfiguration *config, QObject *parent)
142
137
: QObject(parent)
143
138
, _serialConfig(config)
144
139
{
145
- // qCDebug(SerialLinkLog) << Q_FUNC_INFO << this;
140
+ // qCDebug(SerialLinkLog) << this;
146
141
147
142
(void ) qRegisterMetaType<QSerialPort::SerialPortError>(" QSerialPort::SerialPortError" );
148
143
}
@@ -151,7 +146,7 @@ SerialWorker::~SerialWorker()
151
146
{
152
147
disconnectFromPort ();
153
148
154
- // qCDebug(SerialLinkLog) << Q_FUNC_INFO << this;
149
+ // qCDebug(SerialLinkLog) << this;
155
150
}
156
151
157
152
bool SerialWorker::isConnected () const
@@ -289,7 +284,7 @@ void SerialWorker::_onPortReadyRead()
289
284
{
290
285
const QByteArray data = _port->readAll ();
291
286
if (!data.isEmpty ()) {
292
- // qCDebug(SerialLinkLog) << "_onPortReadyRead:" << data.size();
287
+ // qCDebug(SerialLinkLog) << data.size();
293
288
emit dataReceived (data);
294
289
}
295
290
}
@@ -354,11 +349,11 @@ SerialLink::SerialLink(SharedLinkConfigurationPtr &config, QObject *parent)
354
349
, _worker(new SerialWorker(_serialConfig))
355
350
, _workerThread(new QThread(this ))
356
351
{
357
- // qCDebug(SerialLinkLog) << Q_FUNC_INFO << this;
352
+ // qCDebug(SerialLinkLog) << this;
358
353
359
354
_workerThread->setObjectName (QStringLiteral (" Serial_%1" ).arg (_serialConfig->name ()));
360
355
361
- _worker->moveToThread (_workerThread);
356
+ ( void ) _worker->moveToThread (_workerThread);
362
357
363
358
(void ) connect (_workerThread, &QThread::started, _worker, &SerialWorker::setupPort);
364
359
(void ) connect (_workerThread, &QThread::finished, _worker, &QObject::deleteLater);
@@ -374,15 +369,14 @@ SerialLink::SerialLink(SharedLinkConfigurationPtr &config, QObject *parent)
374
369
375
370
SerialLink::~SerialLink ()
376
371
{
377
- SerialLink::disconnect ( );
372
+ ( void ) QMetaObject::invokeMethod (_worker, " disconnectFromPort " , Qt::BlockingQueuedConnection );
378
373
379
374
_workerThread->quit ();
380
375
if (!_workerThread->wait (DISCONNECT_TIMEOUT_MS)) {
381
376
qCWarning (SerialLinkLog) << " Failed to wait for Serial Thread to close" ;
382
- // _workerThread->terminate();
383
377
}
384
378
385
- // qCDebug(SerialLinkLog) << Q_FUNC_INFO << this;
379
+ // qCDebug(SerialLinkLog) << this;
386
380
}
387
381
388
382
bool SerialLink::isConnected () const
0 commit comments