diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2013-01-19 22:07:25 +0400 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2013-01-23 19:49:56 +0100 |
commit | 7667227bc50e54569625ab14169a585c22a34cad (patch) | |
tree | b01777a04e01a6581e0a56b00ce4886f71527646 | |
parent | f94d7b796e37cd594e31fc8acf8c1240a0d3a79b (diff) | |
download | qtserialport-7667227bc50e54569625ab14169a585c22a34cad.tar.gz |
Windows: Fix clear() method
For Win32 and WinCE the clear() method must have a
different implementation. E.g. on Win32 should be also
cleaned variables: actualReadBufferSize, actualWriteBufferSize,
acyncWritePosition and writeSequenceStarted.
Change-Id: I80bcd223afb17f929e80889947a52fb505f8a5e6
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
-rw-r--r-- | src/serialport/serialport_win.cpp | 14 | ||||
-rw-r--r-- | src/serialport/serialport_wince.cpp | 10 |
2 files changed, 20 insertions, 4 deletions
diff --git a/src/serialport/serialport_win.cpp b/src/serialport/serialport_win.cpp index 1f8d45f..0476536 100644 --- a/src/serialport/serialport_win.cpp +++ b/src/serialport/serialport_win.cpp @@ -338,18 +338,24 @@ bool SerialPortPrivate::flush() return startAsyncWrite() && ::FlushFileBuffers(descriptor); } -#endif - bool SerialPortPrivate::clear(SerialPort::Directions dir) { DWORD flags = 0; - if (dir & SerialPort::Input) + if (dir & SerialPort::Input) { flags |= PURGE_RXABORT | PURGE_RXCLEAR; - if (dir & SerialPort::Output) + actualReadBufferSize = 0; + } + if (dir & SerialPort::Output) { flags |= PURGE_TXABORT | PURGE_TXCLEAR; + actualWriteBufferSize = 0; + acyncWritePosition = 0; + writeSequenceStarted = false; + } return ::PurgeComm(descriptor, flags); } +#endif + bool SerialPortPrivate::sendBreak(int duration) { // FIXME: diff --git a/src/serialport/serialport_wince.cpp b/src/serialport/serialport_wince.cpp index e713ce9..d6ff872 100644 --- a/src/serialport/serialport_wince.cpp +++ b/src/serialport/serialport_wince.cpp @@ -228,6 +228,16 @@ bool SerialPortPrivate::flush() return notifyWrite() && ::FlushFileBuffers(descriptor); } +bool SerialPortPrivate::clear(SerialPort::Directions dir) +{ + DWORD flags = 0; + if (dir & SerialPort::Input) + flags |= PURGE_RXABORT | PURGE_RXCLEAR; + if (dir & SerialPort::Output) + flags |= PURGE_TXABORT | PURGE_TXCLEAR; + return ::PurgeComm(descriptor, flags); +} + qint64 SerialPortPrivate::bytesAvailable() const { return readBuffer.size(); |