From d402b2cd84fc55c6c9399bb4fc9e1ad764c07cde Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Sat, 19 Jul 2014 19:53:16 +0400 Subject: Make the QSerialPort::flush() non-blocking According to documentation, the flush() method shall be non-blocking. Tested on Linux 64-bit with auto-tests with the on-board and the USB serial ports for Qt4 and then Qt5. Note: On Windows the flush() method still does not work. Change-Id: Iaee80361e59e0c281206ca24c817a446cdbf6ed1 Reviewed-by: Sergey Belyashov Reviewed-by: Denis Shienkov --- src/serialport/qserialport_unix.cpp | 7 +------ src/serialport/qserialport_win.cpp | 15 +-------------- 2 files changed, 2 insertions(+), 20 deletions(-) diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp index 11ab16f..d555805 100644 --- a/src/serialport/qserialport_unix.cpp +++ b/src/serialport/qserialport_unix.cpp @@ -337,12 +337,7 @@ bool QSerialPortPrivate::setRequestToSend(bool set) bool QSerialPortPrivate::flush() { - return completeAsyncWrite() -#ifndef Q_OS_ANDROID - && (::tcdrain(descriptor) != -1); -#else - && (::ioctl(descriptor, TCSBRK, 1) != -1); -#endif + return completeAsyncWrite(); } bool QSerialPortPrivate::clear(QSerialPort::Directions directions) diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp index eccaca9..19f35b7 100644 --- a/src/serialport/qserialport_win.cpp +++ b/src/serialport/qserialport_win.cpp @@ -259,20 +259,7 @@ bool QSerialPortPrivate::setRequestToSend(bool set) bool QSerialPortPrivate::flush() { - Q_Q(QSerialPort); - - bool returnValue = true; - - if (!startAsyncWrite()) - returnValue = false; - - if (!::FlushFileBuffers(handle)) { - q->setError(decodeSystemError()); - returnValue = false; - } - - return returnValue; - + return startAsyncWrite(); } bool QSerialPortPrivate::clear(QSerialPort::Directions directions) -- cgit v1.2.1