diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2014-05-31 20:51:45 +0400 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2014-06-03 10:24:10 +0200 |
commit | 2271479ff5d58b792af2c3823afe0f88fbf047ea (patch) | |
tree | 2d4b5830e23b7fec5f520106cb238a817a784b56 | |
parent | 91f818d6f7589553b45d680034445e3775191f2d (diff) | |
download | qtserialport-2271479ff5d58b792af2c3823afe0f88fbf047ea.tar.gz |
Improve the setStandardBaudRate() on Linux
* The ASYNC_SPD_CUST flag shall be cleared only if it was earlier
set; otherwise it is not necessary to touch of the serial struct.
* Seems, that is more reasonable to return an error code when
writing back of the serial struct is failed. In this case it is
an error, because we know that serial struct is supported, since
we got it successfully earlier.
Tested build on Archlinux 64 bit using Qt4 and then Qt5.
Tested build on Android x86 using Qt5.
Change-Id: I54ca4772dc770dabac5e3555e6cb42ecc23255a4
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
-rw-r--r-- | src/serialport/qserialport_unix.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp index ab6aad9..aabcf4c 100644 --- a/src/serialport/qserialport_unix.cpp +++ b/src/serialport/qserialport_unix.cpp @@ -537,12 +537,12 @@ QSerialPortPrivate::setStandardBaudRate(qint32 baudRate, QSerialPort::Directions { struct serial_struct currentSerialInfo; - if (::ioctl(descriptor, TIOCGSERIAL, ¤tSerialInfo) != -1) { - + if ((::ioctl(descriptor, TIOCGSERIAL, ¤tSerialInfo) != -1) + && (currentSerialInfo.flags & ASYNC_SPD_CUST)) { currentSerialInfo.flags &= ~ASYNC_SPD_CUST; currentSerialInfo.custom_divisor = 0; - - ::ioctl(descriptor, TIOCSSERIAL, ¤tSerialInfo); + if (::ioctl(descriptor, TIOCSSERIAL, ¤tSerialInfo) == -1) + return decodeSystemError(); } return setBaudRate_helper(baudRate, directions); |