summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/serialport/qserialport_unix.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp
index 9b560be..f058acf 100644
--- a/src/serialport/qserialport_unix.cpp
+++ b/src/serialport/qserialport_unix.cpp
@@ -483,17 +483,20 @@ bool QSerialPortPrivate::setStandardBaudRate(qint32 baudRate, QSerialPort::Direc
bool QSerialPortPrivate::setCustomBaudRate(qint32 baudRate, QSerialPort::Directions directions)
{
+ if (directions != QSerialPort::AllDirections) {
+ setError(QSerialPortErrorInfo(QSerialPort::UnsupportedOperationError,
+ QSerialPort::tr("Cannot set custom speed for one direction")));
+ return false;
+ }
+
struct termios2 tio2;
if (::ioctl(descriptor, TCGETS2, &tio2) != -1) {
tio2.c_cflag &= ~CBAUD;
tio2.c_cflag |= BOTHER;
- if (directions & QSerialPort::Input)
- tio2.c_ispeed = baudRate;
-
- if (directions & QSerialPort::Output)
- tio2.c_ospeed = baudRate;
+ tio2.c_ispeed = baudRate;
+ tio2.c_ospeed = baudRate;
if (::ioctl(descriptor, TCSETS2, &tio2) != -1
&& ::ioctl(descriptor, TCGETS2, &tio2) != -1) {
@@ -537,7 +540,11 @@ bool QSerialPortPrivate::setCustomBaudRate(qint32 baudRate, QSerialPort::Directi
bool QSerialPortPrivate::setCustomBaudRate(qint32 baudRate, QSerialPort::Directions directions)
{
- Q_UNUSED(directions);
+ if (directions != QSerialPort::AllDirections) {
+ setError(QSerialPortErrorInfo(QSerialPort::UnsupportedOperationError,
+ QSerialPort::tr("Cannot set custom speed for one direction")));
+ return false;
+ }
#if defined(MAC_OS_X_VERSION_10_4) && (MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_4)
if (::ioctl(descriptor, IOSSIOSPEED, &baudRate) == -1) {