summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaszlo Papp <lpapp@kde.org>2013-09-02 02:30:38 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-03 14:34:32 +0200
commitab919b700600f8f6555b4848655f15559c9861ee (patch)
tree4f3ec59d850cae7025ee2cdee1d02fcd882841c1
parentfea1f6030287b5499ed6d4922695e1f3b4ebc00a (diff)
downloadqtserialport-ab919b700600f8f6555b4848655f15559c9861ee.tar.gz
Fix the compilation for Android with Qt 5.
1) The termios struct is basically copied and pasted from the documentation: http://linux.die.net/man/3/termios Since, it is just an interface without complicated methods, it is not copyrightable, so it is safe enough. 2) This is also the same situation with the two defines we need for the kernel interface. They are just interface numbers, and not something that copyrightable. This has also been double checked and discussed with Lars in email. 3) The ::tcdrain convenience method cannot be used on Android, so the fallback "raw" ioctl syscall is used with the relevant parameters, e.g. TCSBREAK. http://linux.die.net/man/3/tcdrain 5) cfsetspeed seems to be a BSD 4.4 extension based on the termios(3) man page: http://linux.die.net/man/3/termios "cfsetspeed() is a 4.4BSD extension. It takes the same arguments as cfsetispeed(), and sets both input and output speed." ... hence this is replaced with separate calls for input and output without a specific Android "ifdef" in the code. It is actually also more consistent with the setcfispeed and setcfospeed just right above that snippet. Task-number: QTBUG-33139 Change-Id: If0abb8cec9e900fa2b6fc24df938cb778a344d55 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
-rw-r--r--src/serialport/qserialport_unix.cpp9
-rw-r--r--src/serialport/qserialport_unix_p.h25
2 files changed, 32 insertions, 2 deletions
diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp
index 448701b..0176e5f 100644
--- a/src/serialport/qserialport_unix.cpp
+++ b/src/serialport/qserialport_unix.cpp
@@ -324,7 +324,12 @@ bool QSerialPortPrivate::setRequestToSend(bool set)
bool QSerialPortPrivate::flush()
{
- return writeNotification() && (::tcdrain(descriptor) != -1);
+ return writeNotification()
+#ifndef Q_OS_ANDROID
+ && (::tcdrain(descriptor) != -1);
+#else
+ && (::ioctl(descriptor, TCSBRK, 1) != -1);
+#endif
}
bool QSerialPortPrivate::clear(QSerialPort::Directions dir)
@@ -515,7 +520,7 @@ bool QSerialPortPrivate::setBaudRate(qint32 baudRate, QSerialPort::Directions di
if (currentSerialInfo.custom_divisor == 0)
currentSerialInfo.custom_divisor = 1;
// for custom mode needed prepare to set B38400 baud rate
- ret = (::cfsetspeed(&currentTermios, B38400) != -1);
+ ret = (::cfsetispeed(&currentTermios, B38400) != -1) && (::cfsetospeed(&currentTermios, B38400) != -1);
} else {
ret = false;
}
diff --git a/src/serialport/qserialport_unix_p.h b/src/serialport/qserialport_unix_p.h
index d75bc90..0c723a9 100644
--- a/src/serialport/qserialport_unix_p.h
+++ b/src/serialport/qserialport_unix_p.h
@@ -47,9 +47,34 @@
#include <limits.h>
#include <termios.h>
+#ifndef Q_OS_ANDROID
#ifdef Q_OS_LINUX
# include <linux/serial.h>
#endif
+#else
+struct serial_struct {
+ int type;
+ int line;
+ unsigned int port;
+ int irq;
+ int flags;
+ int xmit_fifo_size;
+ int custom_divisor;
+ int baud_base;
+ unsigned short close_delay;
+ char io_type;
+ char reserved_char[1];
+ int hub6;
+ unsigned short closing_wait;
+ unsigned short closing_wait2;
+ unsigned char *iomem_base;
+ unsigned short iomem_reg_shift;
+ unsigned int port_high;
+ unsigned long iomap_base;
+};
+#define ASYNC_SPD_CUST 0x0030
+#define ASYNC_SPD_MASK 0x1030
+#endif
QT_BEGIN_NAMESPACE