diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2015-09-10 16:25:15 +0300 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2015-09-24 16:22:58 +0000 |
commit | 2e7e58c7f225ee2237b27285c19a060a277e35fe (patch) | |
tree | b7b8e53103713abc588c2a4edf23c67a0ea1f8e7 /src/serialport/qserialport_wince.cpp | |
parent | 5c0fed7b7c19641e0dcc7740277ac5f54422b4bf (diff) | |
download | qtserialport-2e7e58c7f225ee2237b27285c19a060a277e35fe.tar.gz |
Cleanup remainders of code relating to data error policy handling
It is impossible to implement all these features on all platforms,
and particular drivers may not support them, too.
Consequently, the user should handle such errors themselves by applying
platform-specific ioctls on the device descriptor and/or parsing the
stream's byte-stuffing.
This commit also deprecates ParityError, FramingError, and
BreakConditionError.
Tested on Windows and Linux with the virtual and the
USB serial ports.
(cherry-picked from a1655d6ccf3f82508286b471819cc5e5cb64ff44)
Change-Id: I4ffc2f067787bc304a83326acb2a2421b428f986
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Diffstat (limited to 'src/serialport/qserialport_wince.cpp')
-rw-r--r-- | src/serialport/qserialport_wince.cpp | 58 |
1 files changed, 2 insertions, 56 deletions
diff --git a/src/serialport/qserialport_wince.cpp b/src/serialport/qserialport_wince.cpp index 530873b..65613aa 100644 --- a/src/serialport/qserialport_wince.cpp +++ b/src/serialport/qserialport_wince.cpp @@ -127,8 +127,6 @@ private slots: error = true; } - if (error || (EV_ERR & eventMask)) - dptr->processIoErrors(error); if (EV_RXCHAR & eventMask) dptr->notifyRead(); if (EV_TXEMPTY & eventMask) @@ -195,7 +193,7 @@ QSerialPortPrivate::QSerialPortPrivate(QSerialPort *q) bool QSerialPortPrivate::open(QIODevice::OpenMode mode) { DWORD desiredAccess = 0; - DWORD eventMask = EV_ERR; + DWORD eventMask = 0; if (mode & QIODevice::ReadOnly) { desiredAccess |= GENERIC_READ; @@ -484,17 +482,11 @@ bool QSerialPortPrivate::setFlowControl(QSerialPort::FlowControl flowControl) return updateDcb(); } -bool QSerialPortPrivate::setDataErrorPolicy(QSerialPort::DataErrorPolicy policy) -{ - policy = policy; - return true; -} - bool QSerialPortPrivate::notifyRead() { Q_Q(QSerialPort); - DWORD bytesToRead = (policy == QSerialPort::IgnorePolicy) ? ReadChunkSize : 1; + DWORD bytesToRead = ReadChunkSize; if (readBufferMaxSize && bytesToRead > (readBufferMaxSize - readBuffer.size())) { bytesToRead = readBufferMaxSize - readBuffer.size(); @@ -518,27 +510,6 @@ bool QSerialPortPrivate::notifyRead() readBuffer.chop(bytesToRead - qMax(readBytes, DWORD(0))); - // Process emulate policy. - if ((policy != QSerialPort::IgnorePolicy) && parityErrorOccurred) { - - parityErrorOccurred = false; - - switch (policy) { - case QSerialPort::SkipPolicy: - readBuffer.getChar(); - return true; - case QSerialPort::PassZeroPolicy: - readBuffer.getChar(); - readBuffer.putChar('\0'); - break; - case QSerialPort::StopReceivingPolicy: - // FIXME: Maybe need disable read notifier? - break; - default: - break; - } - } - if (readBytes > 0) emit q->readyRead(); @@ -575,31 +546,6 @@ qint64 QSerialPortPrivate::writeData(const char *data, qint64 maxSize) return maxSize; } -void QSerialPortPrivate::processIoErrors(bool hasError) -{ - if (hasError) { - setError(QSerialPortErrorInfo(QSerialPort::ResourceError)); - return; - } - - DWORD errors = 0; - if (!::ClearCommError(handle, &errors, Q_NULLPTR)) { - setError(getSystemError()); - return; - } - - if (errors & CE_FRAME) { - setError(QSerialPortErrorInfo(QSerialPort::FramingError)); - } else if (errors & CE_RXPARITY) { - setError(QSerialPortErrorInfo(QSerialPort::ParityError)); - parityErrorOccurred = true; - } else if (errors & CE_BREAK) { - setError(QSerialPortErrorInfo(QSerialPort::BreakConditionError)); - } else { - setError(QSerialPortErrorInfo(QSerialPort::UnknownError, QSerialPort::tr("Unknown streaming error"))); - } -} - inline bool QSerialPortPrivate::initialize(DWORD eventMask) { Q_Q(QSerialPort); |