diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2014-10-10 22:41:24 +0400 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> | 2014-11-27 21:31:47 +0100 |
commit | 367ed19c803497105dd219039fbd8c69ba070296 (patch) | |
tree | 911bd7cdcfaadd17e0d4e9b841ab990ae6fba62e | |
parent | cb2ff89d4250fb089d5cf0fb4aeecdc35ae526ac (diff) | |
download | qtserialport-367ed19c803497105dd219039fbd8c69ba070296.tar.gz |
Improve the QSP::clear() on Windows
Commit 9c88ad89801596e1d94acc4f32ff55c34118a66f solves a problem
partially. Still when used QSP::clear() with some devices (e.g.
virtual ports from the "AGG Software") the reading can be stalled.
It is reasonable to make following:
1. Prevent to reset the both readStarted and writeStarted variables
inside of QSP::clear() method. These variables shall be reset inside
of _q_completeXX() methods which will be called automatically from the
notifiers, since the PurgeComm should terminate pending read or write
operations.
2. Instead of startAsyncRead() should be called the
startAsyncCommunication(), that allow to correctly startup of the read
sequence.
This scenario can be reproduced with running of the
tst_QSerialPort::readAfterInputClear() autotest.
Tested on Windows 8 with the virtual com0com ports and with the
virtual ports from the "AGG Software" using Qt5.
Change-Id: Ic1a53334abd97667a9dd3291c3b975eb04062efd
Reviewed-by: Robert Kurjata <rkurjata@gmail.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
-rw-r--r-- | src/serialport/qserialport_win.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp index c47f1e4..62a547c 100644 --- a/src/serialport/qserialport_win.cpp +++ b/src/serialport/qserialport_win.cpp @@ -271,13 +271,10 @@ bool QSerialPortPrivate::clear(QSerialPort::Directions directions) Q_Q(QSerialPort); DWORD flags = 0; - if (directions & QSerialPort::Input) { + if (directions & QSerialPort::Input) flags |= PURGE_RXABORT | PURGE_RXCLEAR; - readStarted = false; - } if (directions & QSerialPort::Output) { flags |= PURGE_TXABORT | PURGE_TXCLEAR; - writeStarted = false; actualBytesToWrite = 0; } if (!::PurgeComm(handle, flags)) { @@ -289,7 +286,7 @@ bool QSerialPortPrivate::clear(QSerialPort::Directions directions) // PurgeComm can abort of current reading sequence, or a port is in hardware // flow control mode, or a port has a limited read buffer size. if (directions & QSerialPort::Input) - startAsyncRead(); + startAsyncCommunication(); return true; } |