summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2015-03-01 18:59:44 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2015-03-02 20:58:42 +0000
commita7a90ae10b45bf6339fe2a51201df67f87f9901d (patch)
treedf3da1ebeda3be6ccecc59029a9388365b1b02fe
parent5636dddba85235b5b52d6ce51cd1ec68bc452386 (diff)
downloadqtserialport-a7a90ae10b45bf6339fe2a51201df67f87f9901d.tar.gz
Fix reading on Windows with the limited read buffer
The previous commit ac0422e8c9e74f2275129e3c7c69ef64299f07a9 already fix this issue on 5.4 branch, but in 5.5 branch this issue is appeared again. The reason is that in 5.5 branch is used the private read buffer from the QIODevice, but in 5.4 branch is used the own read buffer. In 5.5 when called the QSP::readData() then it always returns an empty buffer, since the buffer is already read inside of QIODevice. In this case the QSP::startAsyncRead() is never called, because a condition in the QSP::readData() is always false. Need to call the QSP::startAsyncRead() only if the buffer has a limited size or in the HardwareFlow mode. Tested on Windows 8 with the virtual com0com serial ports. Change-Id: Idc1893f5be5034f89fc7a8fdc654a8375679c21d Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
-rw-r--r--src/serialport/qserialport_win.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp
index 48db81d..c37aa3b 100644
--- a/src/serialport/qserialport_win.cpp
+++ b/src/serialport/qserialport_win.cpp
@@ -255,17 +255,18 @@ bool QSerialPortPrivate::setBreakEnabled(bool set)
qint64 QSerialPortPrivate::readData(char *data, qint64 maxSize)
{
- const qint64 result = buffer.read(data, maxSize);
+ Q_UNUSED(data);
+ Q_UNUSED(maxSize);
+
// We need try to start async reading to read a remainder from a driver's queue
// in case we have a limited read buffer size. Because the read notification can
// be stalled since Windows do not re-triggered an EV_RXCHAR event if a driver's
// buffer has a remainder of data ready to read until a new data will be received.
- if (readBufferMaxSize
- && result > 0
- && (result == readBufferMaxSize || flowControl == QSerialPort::HardwareControl)) {
+ if (readBufferMaxSize || flowControl == QSerialPort::HardwareControl)
startAsyncRead();
- }
- return result;
+
+ // return 0 indicating there may be more data in the future
+ return qint64(0);
}
bool QSerialPortPrivate::waitForReadyRead(int msecs)