summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2013-03-15 18:51:10 +0400
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-03-16 18:13:49 +0100
commit169b901f6af118f9eccacc2d8ab4d6d8c8c0d8d1 (patch)
treeb8f9b7c8b4c94d482fc2586fa2b301465b319ef9
parente08753474802607611532590b58816f0eee30b5f (diff)
downloadqtserialport-169b901f6af118f9eccacc2d8ab4d6d8c8c0d8d1.tar.gz
Windows: Fix receive policies processing
Policies should be handled only with ParityError occurred according to the description of the method setDataErrorPolicy(). Change-Id: Ie0dc9347e50d358508def5ba1a84dadbb0ead4be Reviewed-by: Laszlo Papp <lpapp@kde.org>
-rw-r--r--src/serialport/qserialport_win.cpp20
-rw-r--r--src/serialport/qserialport_win_p.h2
-rw-r--r--src/serialport/qserialport_wince.cpp7
3 files changed, 15 insertions, 14 deletions
diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp
index 0137e5e..3a42816 100644
--- a/src/serialport/qserialport_win.cpp
+++ b/src/serialport/qserialport_win.cpp
@@ -208,7 +208,7 @@ public:
QSerialPortPrivate::QSerialPortPrivate(QSerialPort *q)
: QSerialPortPrivateData(q)
, descriptor(INVALID_HANDLE_VALUE)
- , flagErrorFromCommEvent(false)
+ , parityErrorOccurred(false)
, actualReadBufferSize(0)
, actualWriteBufferSize(0)
, acyncWritePosition(0)
@@ -292,7 +292,7 @@ void QSerialPortPrivate::close()
acyncWritePosition = 0;
readyReadEmitted = false;
- flagErrorFromCommEvent = false;
+ parityErrorOccurred = false;
if (settingsRestoredOnClose) {
::SetCommState(descriptor, &restoredDcb);
@@ -707,16 +707,16 @@ bool QSerialPortPrivate::processIoErrors(bool error)
DWORD errors = 0;
const bool ret = ::ClearCommError(descriptor, &errors, NULL);
if (ret && errors) {
- if (errors & CE_FRAME)
+ if (errors & CE_FRAME) {
q_ptr->setError(QSerialPort::FramingError);
- else if (errors & CE_RXPARITY)
+ } else if (errors & CE_RXPARITY) {
q_ptr->setError(QSerialPort::ParityError);
- else if (errors & CE_BREAK)
+ parityErrorOccurred = true;
+ } else if (errors & CE_BREAK) {
q_ptr->setError(QSerialPort::BreakConditionError);
- else
+ } else {
q_ptr->setError(QSerialPort::UnknownError);
-
- flagErrorFromCommEvent = true;
+ }
}
return ret;
}
@@ -731,9 +731,9 @@ bool QSerialPortPrivate::completeAsyncRead(DWORD numberOfBytes)
if (numberOfBytes > 0) {
// Process emulate policy.
- if (flagErrorFromCommEvent) {
+ if ((policy != QSerialPort::IgnorePolicy) && parityErrorOccurred) {
- flagErrorFromCommEvent = false;
+ parityErrorOccurred = false;
// Ignore received character, remove it from buffer
if (policy == QSerialPort::SkipPolicy) {
diff --git a/src/serialport/qserialport_win_p.h b/src/serialport/qserialport_win_p.h
index 5178efc..d058e52 100644
--- a/src/serialport/qserialport_win_p.h
+++ b/src/serialport/qserialport_win_p.h
@@ -125,7 +125,7 @@ public:
COMMTIMEOUTS currentCommTimeouts;
COMMTIMEOUTS restoredCommTimeouts;
HANDLE descriptor;
- bool flagErrorFromCommEvent;
+ bool parityErrorOccurred;
#ifndef Q_OS_WINCE
QHash<HANDLE, AbstractOverlappedEventNotifier *> notifiers;
diff --git a/src/serialport/qserialport_wince.cpp b/src/serialport/qserialport_wince.cpp
index 4e61a8c..1c5c890 100644
--- a/src/serialport/qserialport_wince.cpp
+++ b/src/serialport/qserialport_wince.cpp
@@ -157,7 +157,7 @@ private:
QSerialPortPrivate::QSerialPortPrivate(QSerialPort *q)
: QSerialPortPrivateData(q)
, descriptor(INVALID_HANDLE_VALUE)
- , flagErrorFromCommEvent(0)
+ , parityErrorOccurred(false)
, eventNotifier(0)
{
}
@@ -376,8 +376,9 @@ bool QSerialPortPrivate::notifyRead()
readBuffer.truncate(readBytes);
// Process emulate policy.
- if (flagErrorFromCommEvent) {
- flagErrorFromCommEvent = false;
+ if ((policy != QSerialPort::IgnorePolicy) && parityErrorOccurred) {
+
+ parityErrorOccurred = false;
switch (policy) {
case QSerialPort::SkipPolicy: