diff options
author | Liang Qi <liang.qi@qt.io> | 2016-05-19 21:37:33 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-05-19 21:37:33 +0200 |
commit | 9e8daaed0466d760e047c5da58811e55e7807c0a (patch) | |
tree | eb75deaa8be7b1bbd777416aa1995990cd0f86a1 | |
parent | 2ac9c0c0e6210f73884bbe2bcb3d8269519003a8 (diff) | |
parent | 9c9255eda50af191636ff9f18df35567c307dd8c (diff) | |
download | qtserialport-9e8daaed0466d760e047c5da58811e55e7807c0a.tar.gz |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
.qmake.conf
Change-Id: I6a4c3e446633e6f142b87c268096b1bdc1598a62
-rw-r--r-- | examples/serialport/blockingmaster/blockingmaster.pro | 3 | ||||
-rw-r--r-- | examples/serialport/blockingslave/blockingslave.pro | 3 | ||||
-rw-r--r-- | examples/serialport/cenumerator/cenumerator.pro | 3 | ||||
-rw-r--r-- | examples/serialport/creaderasync/creaderasync.pro | 3 | ||||
-rw-r--r-- | examples/serialport/creadersync/creadersync.pro | 3 | ||||
-rw-r--r-- | examples/serialport/cwriterasync/cwriterasync.pro | 3 | ||||
-rw-r--r-- | examples/serialport/cwritersync/cwritersync.pro | 3 | ||||
-rw-r--r-- | examples/serialport/enumerator/enumerator.pro | 3 | ||||
-rw-r--r-- | examples/serialport/master/master.pro | 3 | ||||
-rw-r--r-- | examples/serialport/serialport.pro | 3 | ||||
-rw-r--r-- | examples/serialport/slave/slave.pro | 3 | ||||
-rw-r--r-- | examples/serialport/terminal/terminal.pro | 3 | ||||
-rw-r--r-- | src/serialport/doc/qtserialport.qdocconf | 2 | ||||
-rw-r--r-- | src/serialport/qserialport_p.h | 2 | ||||
-rw-r--r-- | src/serialport/qserialport_unix.cpp | 12 | ||||
-rw-r--r-- | src/serialport/qserialport_win.cpp | 29 | ||||
-rw-r--r-- | src/serialport/qserialportinfo_unix.cpp | 2 |
17 files changed, 61 insertions, 22 deletions
diff --git a/examples/serialport/blockingmaster/blockingmaster.pro b/examples/serialport/blockingmaster/blockingmaster.pro index 8f3e0a1..7cf76d8 100644 --- a/examples/serialport/blockingmaster/blockingmaster.pro +++ b/examples/serialport/blockingmaster/blockingmaster.pro @@ -11,3 +11,6 @@ SOURCES += \ main.cpp \ dialog.cpp \ masterthread.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/serialport/blockingmaster +INSTALLS += target diff --git a/examples/serialport/blockingslave/blockingslave.pro b/examples/serialport/blockingslave/blockingslave.pro index 2477b52..11b9b80 100644 --- a/examples/serialport/blockingslave/blockingslave.pro +++ b/examples/serialport/blockingslave/blockingslave.pro @@ -11,3 +11,6 @@ SOURCES += \ main.cpp \ dialog.cpp \ slavethread.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/serialport/blockingslave +INSTALLS += target diff --git a/examples/serialport/cenumerator/cenumerator.pro b/examples/serialport/cenumerator/cenumerator.pro index f5494fd..75a43e3 100644 --- a/examples/serialport/cenumerator/cenumerator.pro +++ b/examples/serialport/cenumerator/cenumerator.pro @@ -9,3 +9,6 @@ TEMPLATE = app SOURCES += \ main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/serialport/cenumerator +INSTALLS += target diff --git a/examples/serialport/creaderasync/creaderasync.pro b/examples/serialport/creaderasync/creaderasync.pro index 3565dc9..38d8b52 100644 --- a/examples/serialport/creaderasync/creaderasync.pro +++ b/examples/serialport/creaderasync/creaderasync.pro @@ -13,3 +13,6 @@ HEADERS += \ SOURCES += \ main.cpp \ serialportreader.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/serialport/creaderasync +INSTALLS += target diff --git a/examples/serialport/creadersync/creadersync.pro b/examples/serialport/creadersync/creadersync.pro index ee9eaf2..a2690aa 100644 --- a/examples/serialport/creadersync/creadersync.pro +++ b/examples/serialport/creadersync/creadersync.pro @@ -9,3 +9,6 @@ TEMPLATE = app SOURCES += \ main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/serialport/creadersync +INSTALLS += target diff --git a/examples/serialport/cwriterasync/cwriterasync.pro b/examples/serialport/cwriterasync/cwriterasync.pro index 0945f1d..f6105bc 100644 --- a/examples/serialport/cwriterasync/cwriterasync.pro +++ b/examples/serialport/cwriterasync/cwriterasync.pro @@ -13,3 +13,6 @@ HEADERS += \ SOURCES += \ main.cpp \ serialportwriter.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/serialport/cwriterasync +INSTALLS += target diff --git a/examples/serialport/cwritersync/cwritersync.pro b/examples/serialport/cwritersync/cwritersync.pro index 08f50a2..1e0996d 100644 --- a/examples/serialport/cwritersync/cwritersync.pro +++ b/examples/serialport/cwritersync/cwritersync.pro @@ -9,3 +9,6 @@ TEMPLATE = app SOURCES += \ main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/serialport/cwritersync +INSTALLS += target diff --git a/examples/serialport/enumerator/enumerator.pro b/examples/serialport/enumerator/enumerator.pro index 9819fd7..3989335 100644 --- a/examples/serialport/enumerator/enumerator.pro +++ b/examples/serialport/enumerator/enumerator.pro @@ -5,3 +5,6 @@ TEMPLATE = app SOURCES += \ main.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/serialport/enumerator +INSTALLS += target diff --git a/examples/serialport/master/master.pro b/examples/serialport/master/master.pro index 977de6c..354d174 100644 --- a/examples/serialport/master/master.pro +++ b/examples/serialport/master/master.pro @@ -13,3 +13,6 @@ HEADERS += \ SOURCES += \ main.cpp \ dialog.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/serialport/master +INSTALLS += target diff --git a/examples/serialport/serialport.pro b/examples/serialport/serialport.pro index c0e77df..6d00a22 100644 --- a/examples/serialport/serialport.pro +++ b/examples/serialport/serialport.pro @@ -1,4 +1,3 @@ TEMPLATE = subdirs -CONFIG += ordered SUBDIRS = cenumerator creaderasync creadersync cwriterasync cwritersync -!isEmpty(QT.widgets.name):SUBDIRS += enumerator terminal blockingmaster blockingslave +!isEmpty(QT.widgets.name):SUBDIRS += enumerator terminal blockingmaster blockingslave master slave diff --git a/examples/serialport/slave/slave.pro b/examples/serialport/slave/slave.pro index df996ac..54e7d02 100644 --- a/examples/serialport/slave/slave.pro +++ b/examples/serialport/slave/slave.pro @@ -13,3 +13,6 @@ HEADERS += \ SOURCES += \ main.cpp \ dialog.cpp + +target.path = $$[QT_INSTALL_EXAMPLES]/serialport/slave +INSTALLS += target diff --git a/examples/serialport/terminal/terminal.pro b/examples/serialport/terminal/terminal.pro index 1e45e55..4dbed02 100644 --- a/examples/serialport/terminal/terminal.pro +++ b/examples/serialport/terminal/terminal.pro @@ -20,3 +20,6 @@ FORMS += \ RESOURCES += \ terminal.qrc + +target.path = $$[QT_INSTALL_EXAMPLES]/serialport/terminal +INSTALLS += target diff --git a/src/serialport/doc/qtserialport.qdocconf b/src/serialport/doc/qtserialport.qdocconf index ac1fc1e..78c1b35 100644 --- a/src/serialport/doc/qtserialport.qdocconf +++ b/src/serialport/doc/qtserialport.qdocconf @@ -34,7 +34,7 @@ exampledirs += ../../../examples/serialport imagedirs += images excludedirs += ../qt4support -examplesinstallpath = qtserialport/serialport +examplesinstallpath = serialport depends += qtcore qtdoc qtnetwork qmake diff --git a/src/serialport/qserialport_p.h b/src/serialport/qserialport_p.h index ae2089d..cb300ad 100644 --- a/src/serialport/qserialport_p.h +++ b/src/serialport/qserialport_p.h @@ -188,6 +188,8 @@ public: bool getDcb(DCB *dcb); OVERLAPPED *waitForNotified(int msecs); + qint64 queuedBytesCount(QSerialPort::Direction direction) const; + bool completeAsyncCommunication(qint64 bytesTransferred); bool completeAsyncRead(qint64 bytesTransferred); bool completeAsyncWrite(qint64 bytesTransferred); diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp index 41dad55..2d49822 100644 --- a/src/serialport/qserialport_unix.cpp +++ b/src/serialport/qserialport_unix.cpp @@ -250,15 +250,11 @@ void QSerialPortPrivate::close() ::ioctl(descriptor, TIOCNXCL); #endif - if (readNotifier) { - delete readNotifier; - readNotifier = Q_NULLPTR; - } + delete readNotifier; + readNotifier = Q_NULLPTR; - if (writeNotifier) { - delete writeNotifier; - writeNotifier = Q_NULLPTR; - } + delete writeNotifier; + writeNotifier = Q_NULLPTR; qt_safe_close(descriptor); diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp index 36e7164..5dccd39 100644 --- a/src/serialport/qserialport_win.cpp +++ b/src/serialport/qserialport_win.cpp @@ -112,15 +112,11 @@ void QSerialPortPrivate::close() { ::CancelIo(handle); - if (notifier) { - delete notifier; - notifier = Q_NULLPTR; - } + delete notifier; + notifier = Q_NULLPTR; - if (startAsyncWriteTimer) { - delete startAsyncWriteTimer; - startAsyncWriteTimer = Q_NULLPTR; - } + delete startAsyncWriteTimer; + startAsyncWriteTimer = Q_NULLPTR; communicationStarted = false; readStarted = false; @@ -443,10 +439,13 @@ bool QSerialPortPrivate::completeAsyncRead(qint64 bytesTransferred) readStarted = false; bool result = true; - if (bytesTransferred == ReadChunkSize) + if (bytesTransferred == ReadChunkSize + || queuedBytesCount(QSerialPort::Input) > 0) { result = startAsyncRead(); - else if (readBufferMaxSize == 0 || readBufferMaxSize > buffer.size()) + } else if (readBufferMaxSize == 0 + || readBufferMaxSize > buffer.size()) { result = startAsyncCommunication(); + } if (bytesTransferred > 0) emitReadyRead(); @@ -604,6 +603,16 @@ OVERLAPPED *QSerialPortPrivate::waitForNotified(int msecs) return overlapped; } +qint64 QSerialPortPrivate::queuedBytesCount(QSerialPort::Direction direction) const +{ + COMSTAT comstat; + if (::ClearCommError(handle, Q_NULLPTR, &comstat) == 0) + return -1; + return (direction == QSerialPort::Input) + ? comstat.cbInQue + : ((direction == QSerialPort::Output) ? comstat.cbOutQue : -1); +} + inline bool QSerialPortPrivate::initialize() { Q_Q(QSerialPort); diff --git a/src/serialport/qserialportinfo_unix.cpp b/src/serialport/qserialportinfo_unix.cpp index 3a37999..08e75c1 100644 --- a/src/serialport/qserialportinfo_unix.cpp +++ b/src/serialport/qserialportinfo_unix.cpp @@ -157,7 +157,7 @@ static bool isRfcommDevice(const QString &portName) return false; bool ok; - const int portNumber = portName.mid(6).toInt(&ok); + const int portNumber = portName.midRef(6).toInt(&ok); if (!ok || (portNumber < 0) || (portNumber > 255)) return false; return true; |