diff options
author | Denis Shienkov <denis.shienkov@gmail.com> | 2015-09-08 22:05:49 +0300 |
---|---|---|
committer | Denis Shienkov <denis.shienkov@gmail.com> | 2015-09-09 12:11:15 +0000 |
commit | eb0535c9701202d5f74fe1fc9b3b094bbecb8043 (patch) | |
tree | 23139e533027e16aada5bd2d1396bbe7525b2192 /tests/auto | |
parent | e07a665edef5a238e3f1b948bc3f5e3e244f2ab2 (diff) | |
download | qtserialport-eb0535c9701202d5f74fe1fc9b3b094bbecb8043.tar.gz |
Use the termios v2 to custom baud rate switching
For a long time the Linux kernel has support new version of
the termios structure (V2). To setup the user speed it is
necessary to do following steps:
* Query current content of termios2 by calling the ioctl() with
the TCGETS2 flag.
* Add to the c_cflag field the BOTHER flag.
* Set to the c_ispeed/c_ospeed fields an actual values of custom speeds.
* Write new content of termios2 back by calling the ioctl() with the
TCSETS2 flag.
This new method much simpler and is more transparent in implementation
than changes of a custom divisor. It is preferable and will be used
by default for all cases. If for some reason a current Linux kernel
doesn't support the termios2, then will be falling back to the old
method with changing of a custom divisor.
Tested with the on-board and the USB (PL2303) serial ports.
Task-number: QTBUG-48094
Change-Id: I49a5389b089980b616b4e2ff815ce0b579752d0e
Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com>
Reviewed-by: Massimo Callegari <massimocallegari@yahoo.it>
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/qserialport/tst_qserialport.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/tests/auto/qserialport/tst_qserialport.cpp b/tests/auto/qserialport/tst_qserialport.cpp index 1a2813d..893982b 100644 --- a/tests/auto/qserialport/tst_qserialport.cpp +++ b/tests/auto/qserialport/tst_qserialport.cpp @@ -345,6 +345,8 @@ void tst_QSerialPort::baudRate_data() QTest::newRow("Baud38400") << static_cast<qint32>(QSerialPort::Baud38400); QTest::newRow("Baud57600") << static_cast<qint32>(QSerialPort::Baud57600); QTest::newRow("Baud115200") << static_cast<qint32>(QSerialPort::Baud115200); + + QTest::newRow("31250") << 31250; // custom baudrate (MIDI) } void tst_QSerialPort::baudRate() @@ -1099,6 +1101,14 @@ void tst_QSerialPort::readWriteWithDifferentBaudRate_data() QTest::newRow("9600, 9600") << 9600 << 9600 << true; QTest::newRow("115200, 115200") << 115200 << 115200 << true; QTest::newRow("9600, 115200") << 9600 << 115200 << false; + + QTest::newRow("31250, 31250") << 31250 << 31250 << true; // custom baudrate (MIDI) + QTest::newRow("31250, 115200") << 31250 << 115200 << false; + +#ifdef Q_OS_LINUX + QTest::newRow("14400, 14400") << 14400 << 14400 << true; // custom baudrate for Linux + QTest::newRow("14400, 115200") << 14400 << 115200 << false; +#endif } void tst_QSerialPort::readWriteWithDifferentBaudRate() |