From 4679301c184b7964fd197cca5bf5b30fefaee386 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Fri, 22 Apr 2016 18:47:41 +0300 Subject: Fix reading of data remainder with CDC USB device on Windows In some cases the WaitCommEvent function does not triggered, even if the input driver's queue has an unread bytes. Most likely this happens if a bytes has been arrived between calls of ReadFile and WaitCommEvent. Thus, it can be avoided by means of ClearCommError function which should be called in end of ReadFile to require amount of bytes that has been arrived but still are unread. If it returns more than zero, then we start reading again, without calling of WaitCommEvent. Task-number: QTBUG-48677 Change-Id: I054975971a7c1823f7de879669c3d97f31348ed8 Reviewed-by: Sergey Belyashov Reviewed-by: Denis Shienkov --- src/serialport/qserialport_p.h | 2 ++ src/serialport/qserialport_win.cpp | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/serialport/qserialport_p.h b/src/serialport/qserialport_p.h index 29c1d5a..81febed 100644 --- a/src/serialport/qserialport_p.h +++ b/src/serialport/qserialport_p.h @@ -206,6 +206,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_win.cpp b/src/serialport/qserialport_win.cpp index 6d5dac0..e356e4c 100644 --- a/src/serialport/qserialport_win.cpp +++ b/src/serialport/qserialport_win.cpp @@ -437,10 +437,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(); @@ -598,6 +601,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); -- cgit v1.2.1 From d110ff0c4431a134c0b0895f005ea2b1e45b8125 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 21 Apr 2016 16:31:52 +0200 Subject: remove most pointless CONFIG+=ordered Change-Id: I3d0c3cc192c3da07dfcd59f64a7c61864fe20ad8 Reviewed-by: Denis Shienkov --- examples/serialport/serialport.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/serialport/serialport.pro b/examples/serialport/serialport.pro index c0e77df..a1819bf 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 -- cgit v1.2.1 From 8d8bdacaebf38d46ab59fb8e1c8ce0d31f4d71ac Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 21 Apr 2016 11:37:35 +0200 Subject: add example installs Change-Id: Iadcc0afaae8a54f10a587f0b2f37db128d7ea02d Reviewed-by: Denis Shienkov --- examples/serialport/blockingmaster/blockingmaster.pro | 3 +++ examples/serialport/blockingslave/blockingslave.pro | 3 +++ examples/serialport/cenumerator/cenumerator.pro | 3 +++ examples/serialport/creaderasync/creaderasync.pro | 3 +++ examples/serialport/creadersync/creadersync.pro | 3 +++ examples/serialport/cwriterasync/cwriterasync.pro | 3 +++ examples/serialport/cwritersync/cwritersync.pro | 3 +++ examples/serialport/enumerator/enumerator.pro | 3 +++ examples/serialport/master/master.pro | 3 +++ examples/serialport/slave/slave.pro | 3 +++ examples/serialport/terminal/terminal.pro | 3 +++ 11 files changed, 33 insertions(+) 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/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 -- cgit v1.2.1 From 0f68acf35c745a6409d2c1559887fa888a7b06cd Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 21 Apr 2016 16:25:38 +0200 Subject: enable build of master and slave examples Change-Id: I0680e485a0c3ecde410a090204f192ece66fa6c4 Reviewed-by: Denis Shienkov --- examples/serialport/serialport.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/serialport/serialport.pro b/examples/serialport/serialport.pro index a1819bf..6d00a22 100644 --- a/examples/serialport/serialport.pro +++ b/examples/serialport/serialport.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs 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 -- cgit v1.2.1 From 7d0d53c6a390dfbdb803ea635ef61e80588063a8 Mon Sep 17 00:00:00 2001 From: Frank Meerkoetter Date: Sat, 30 Apr 2016 21:08:41 +0200 Subject: Avoid allocating a string by using a QStringRef Change-Id: I01693dcdbd8a0e99a2845d16676c4e9302d244e6 Reviewed-by: Denis Shienkov --- src/serialport/qserialportinfo_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/serialport/qserialportinfo_unix.cpp b/src/serialport/qserialportinfo_unix.cpp index 475aeb4..8f39045 100644 --- a/src/serialport/qserialportinfo_unix.cpp +++ b/src/serialport/qserialportinfo_unix.cpp @@ -149,7 +149,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; -- cgit v1.2.1 From 8a30a60a03af3979de8988209f8f77638713c30d Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Tue, 3 May 2016 17:05:50 +0300 Subject: Remove superfluous check during removal of the pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... as deleting of a null-pointer it is a valid operation. Change-Id: Ia4ffd8b69ab75b9e3b200ce2ce999ab2820b915e Reviewed-by: Frank Meerkoetter Reviewed-by: André Hartmann --- src/serialport/qserialport_unix.cpp | 12 ++++-------- src/serialport/qserialport_win.cpp | 12 ++++-------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp index 7153449..7662a90 100644 --- a/src/serialport/qserialport_unix.cpp +++ b/src/serialport/qserialport_unix.cpp @@ -244,15 +244,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 e356e4c..1680d5a 100644 --- a/src/serialport/qserialport_win.cpp +++ b/src/serialport/qserialport_win.cpp @@ -106,15 +106,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; -- cgit v1.2.1 From 6e650c77d5bde2e747852df4f8fbeca8ead57e30 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Tue, 10 May 2016 14:54:30 +0200 Subject: Doc: Remove repository name from examplesinstallpath Examples in binary packages now directly match the install path. Change-Id: Ife24588c333e014f8cdd8367153e8d0643db5f83 Reviewed-by: Denis Shienkov --- src/serialport/doc/qtserialport.qdocconf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 -- cgit v1.2.1 From 9c9255eda50af191636ff9f18df35567c307dd8c Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 19 May 2016 13:27:16 +0200 Subject: Bump version Change-Id: I64efbfd780839873b8e28832fcd5c1324fd404f7 --- .qmake.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.qmake.conf b/.qmake.conf index b642527..21c63db 100644 --- a/.qmake.conf +++ b/.qmake.conf @@ -1,3 +1,3 @@ load(qt_build_config) -MODULE_VERSION = 5.6.1 +MODULE_VERSION = 5.6.2 -- cgit v1.2.1