From 90dbacd9dae2b82fad9c68ca95c06a6d6b1ae030 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Wed, 25 Dec 2013 16:32:28 +0400 Subject: Fix the waitForReadyRead() behavior on Windows It is necessary to compare size of the readBuffer before and after completion of each read operation. If size of readBuffer are equal it means that are no more data available for reading. In this case the method should returns true if an initial size of readBuffer is not equal to the current size of readBuffer. Otherwise in all other cases should be continue waiting until timeout has been expired. Also must not to do check for the NoError code and to hope for valid value of this code inside waitForReadyRead(). Because a last error code do not clears automatically. It lead to false returns of this method in case the error number is not equal to NoError (for example it error remained after failed of any previous method). This check should be implemented in a different way in case of need. But at present this check is unnecessary because result of the waitAnyEvent() cover it. Task-number: QTBUG-33987 Change-Id: Ic8d8e3806fd4863c2720ffb83d5c19eae54d57f0 Reviewed-by: Sergey Belyashov Reviewed-by: Laszlo Papp --- src/serialport/qserialport_win.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp index e460c785..4a72da05 100644 --- a/src/serialport/qserialport_win.cpp +++ b/src/serialport/qserialport_win.cpp @@ -381,6 +381,9 @@ bool QSerialPortPrivate::waitForReadyRead(int msecs) QElapsedTimer stopWatch; stopWatch.start(); + const qint64 initialReadBufferSize = readBuffer.size(); + qint64 currentReadBufferSize = initialReadBufferSize; + do { bool timedOut = false; HANDLE triggeredEvent = 0; @@ -394,11 +397,12 @@ bool QSerialPortPrivate::waitForReadyRead(int msecs) if (triggeredEvent == communicationOverlapped.hEvent) { _q_canCompleteCommunication(); - if (error != QSerialPort::NoError) - return false; } else if (triggeredEvent == readCompletionOverlapped.hEvent) { _q_canCompleteRead(); - return error == QSerialPort::NoError; + if (qint64(readBuffer.size()) != currentReadBufferSize) + currentReadBufferSize = readBuffer.size(); + else if (initialReadBufferSize != currentReadBufferSize) + return true; } else if (triggeredEvent == writeCompletionOverlapped.hEvent) { _q_canCompleteWrite(); } else { -- cgit v1.2.3 From 14b543782535e34bb28cc82c46e1e1ddda6a3898 Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Thu, 16 Jan 2014 18:11:00 +0000 Subject: Fix the broken handle() documentation This is likely to be happening due to the mismatching function signature include the return type between the header and source file. Two things are being fixed: 1) Dropped scope for the Handle just like with the winId case in QWidget. 2) "const" qualifier is now added for the method. Here you can see the documentation that it is empty: http://qt-project.org/doc/qt-5/qserialport.html#handle Change-Id: I5e9e0732cfd746a863de523fe90e58eafa42c081 Reviewed-by: Alex Henrie Reviewed-by: Sergey Belyashov Reviewed-by: Martin Smith --- src/serialport/qserialport.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/serialport/qserialport.cpp b/src/serialport/qserialport.cpp index 5d9442e3..1fca4250 100644 --- a/src/serialport/qserialport.cpp +++ b/src/serialport/qserialport.cpp @@ -1279,7 +1279,7 @@ bool QSerialPort::waitForReadyRead(int msecs) } /*! - \fn QSerialPort::Handle QSerialPort::handle() + \fn Handle QSerialPort::handle() const \since 5.2 Returns the native serial port descriptor of the object. If the serial port -- cgit v1.2.3 From 53595fd08ed82830009e6f4860332fb7b81da379 Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Thu, 16 Jan 2014 18:19:57 +0000 Subject: Fix the creaderasync example name in the qdoc file This change eliminates the following warnings when using "make docs": /home/lpapp/Projects/qt/qt5/qtserialport/examples/serialport/doc/creaderasync.qdoc:28: warning: Cannot find file 'creader/creader.pro' or 'creader/creader.qmlproject' /home/lpapp/Projects/qt/qt5/qtserialport/examples/serialport/doc/creaderasync.qdoc:28: warning: EXAMPLE PATH DOES NOT EXIST: creader It is also visible that the example is unreachable on the following documentation page: http://qt-project.org/doc/qt-5/examples.html Change-Id: I09f1532fcff6b1f7bfc5c4857bd14252aceb2eb3 Reviewed-by: Denis Shienkov Reviewed-by: Sergey Belyashov --- examples/serialport/doc/creaderasync.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/serialport/doc/creaderasync.qdoc b/examples/serialport/doc/creaderasync.qdoc index 23498565..a8b21013 100644 --- a/examples/serialport/doc/creaderasync.qdoc +++ b/examples/serialport/doc/creaderasync.qdoc @@ -26,7 +26,7 @@ ****************************************************************************/ /*! - \example creader + \example creaderasync \title Command Line Reader Async Example \ingroup qtserialport-examples -- cgit v1.2.3 From 1927f5751a86988a9615d5abdf7fe4ef69d41180 Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Fri, 24 Jan 2014 08:08:14 +0000 Subject: Refactor the reference in the documentation for property setters/getters The documentation contains broken links due to this, and it is also inconsistent with the rest. Properties should be referred to as properties, not individual methods like setter, getter, notified signal, etc. The change is tested with "make docs" and the broken links are history. Change-Id: Id94cba1f88503754318c865793229e3d3947bec6 Reviewed-by: Sergey Belyashov Reviewed-by: Jerome Pasion Reviewed-by: Martin Smith --- src/serialport/qserialport.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/serialport/qserialport.cpp b/src/serialport/qserialport.cpp index 1fca4250..b41e7a56 100644 --- a/src/serialport/qserialport.cpp +++ b/src/serialport/qserialport.cpp @@ -116,10 +116,10 @@ int QSerialPortPrivateData::timeoutValue(int msecs, int elapsed) port to the desired setting using the setBaudRate(), setDataBits(), setParity(), setStopBits(), and setFlowControl() methods. - The status of the control pinout signals is determined with the - isDataTerminalReady(), isRequestToSend, and pinoutSignals() methods. To - change the control line status, use the setDataTerminalReady(), and - setRequestToSend() methods. + There are a couple of properties to work with the pinout signals namely: + QSerialPort::dataTerminalReady, QSerialPort::requestToSend. It is also + possible to use the pinoutSignals() method to query the current pinout + signals set. Once you know that the ports are ready to read or write, you can use the read() or write() methods. Alternatively the @@ -981,8 +981,7 @@ bool QSerialPort::isRequestToSend() \note The serial port has to be open before trying to get the pinout signals; otherwise returns NoSignal and sets the NotOpenError error code. - \sa isDataTerminalReady(), isRequestToSend, setDataTerminalReady(), - setRequestToSend() + \sa QSerialPort::dataTerminalReady, QSerialPort::requestToSend */ QSerialPort::PinoutSignals QSerialPort::pinoutSignals() { -- cgit v1.2.3 From 84ec01711a9869da26f04e14fda5a5fc54073e98 Mon Sep 17 00:00:00 2001 From: Laszlo Papp Date: Mon, 20 Jan 2014 17:48:41 +0000 Subject: Obsolete the TxD/RxD signals They are not much of use due to the low-level OS limitations as of now, hence the obsolete proposal. It can be brought back to life at any point when we have a more clear idea what to do with this API. "faking" this signal as RealTterm probably does it, is not a nice impression for the end users. That would be more like a software "signal" (which we already have in place) rather than a real pinout hardware signal. It is interesting why Windows, Linux, etc do not provide an option for this. There must be some strong reason for it. Change-Id: Ia065e2ee9226d16e724f5e2690b25b954329d78e Reviewed-by: Denis Shienkov Reviewed-by: Sergey Belyashov --- src/serialport/qserialport.cpp | 10 ++++++++-- src/serialport/qserialport.h | 22 ++++++++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/serialport/qserialport.cpp b/src/serialport/qserialport.cpp index b41e7a56..aa9b616b 100644 --- a/src/serialport/qserialport.cpp +++ b/src/serialport/qserialport.cpp @@ -291,8 +291,14 @@ int QSerialPortPrivateData::timeoutValue(int msecs, int elapsed) This enum describes the possible RS-232 pinout signals. \value NoSignal No line active - \value TransmittedDataSignal TxD (Transmitted Data). - \value ReceivedDataSignal RxD (Received Data). + \value TransmittedDataSignal TxD (Transmitted Data). This value is + obsolete. It is provided to keep old + source code working. We strongly + advise against using it in new code. + \value ReceivedDataSignal RxD (Received Data). This value is + obsolete. It is provided to keep old + source code working. We strongly + advise against using it in new code. \value DataTerminalReadySignal DTR (Data Terminal Ready). \value DataCarrierDetectSignal DCD (Data Carrier Detect). \value DataSetReadySignal DSR (Data Set Ready). diff --git a/src/serialport/qserialport.h b/src/serialport/qserialport.h index c07af91b..795cf33d 100644 --- a/src/serialport/qserialport.h +++ b/src/serialport/qserialport.h @@ -131,16 +131,6 @@ public: UnknownFlowControl = -1 }; -#if QT_DEPRECATED_SINCE(5, 2) -#if defined _MSC_VER -#pragma deprecated(UnknownBaud) -#pragma deprecated(UnknownDataBits) -#pragma deprecated(UnknownParity) -#pragma deprecated(UnknownStopBits) -#pragma deprecated(UnknownFlowControl) -#endif -#endif - enum PinoutSignal { NoSignal = 0x00, TransmittedDataSignal = 0x01, @@ -156,6 +146,18 @@ public: }; Q_DECLARE_FLAGS(PinoutSignals, PinoutSignal) +#if QT_DEPRECATED_SINCE(5, 2) +#if defined _MSC_VER +#pragma deprecated(UnknownBaud) +#pragma deprecated(UnknownDataBits) +#pragma deprecated(UnknownParity) +#pragma deprecated(UnknownStopBits) +#pragma deprecated(UnknownFlowControl) +#pragma deprecated(TransmittedDataSignal) +#pragma deprecated(ReceivedDataSignal) +#endif +#endif + #if QT_DEPRECATED_SINCE(5, 2) enum DataErrorPolicy { SkipPolicy, -- cgit v1.2.3