diff options
author | Liang Qi <liang.qi@qt.io> | 2016-11-26 12:56:00 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-11-26 12:56:00 +0100 |
commit | 4e667fa7f88144e198692d9794baacc86bb4eb98 (patch) | |
tree | 14e41749bfdbdc6936a2c996514e8eb4f47368ab | |
parent | e2a658a2472d9fa710c251a065f488bae981c0ae (diff) | |
parent | 12575ecc41a54609aaa1ecac0c918fa444d869ec (diff) | |
download | qtserialport-4e667fa7f88144e198692d9794baacc86bb4eb98.tar.gz |
Merge remote-tracking branch 'origin/5.7' into 5.8
Change-Id: Ia83609bd366762621857a6c63bf935a6cd230742
-rw-r--r-- | dist/changes-5.7.1 | 27 | ||||
-rw-r--r-- | src/serialport/qserialport_unix.cpp | 5 | ||||
-rw-r--r-- | src/serialport/qserialport_win.cpp | 13 | ||||
-rw-r--r-- | sync.profile | 4 | ||||
-rw-r--r-- | tests/auto/qserialport/tst_qserialport.cpp | 53 |
5 files changed, 93 insertions, 9 deletions
diff --git a/dist/changes-5.7.1 b/dist/changes-5.7.1 new file mode 100644 index 0000000..e9bf668 --- /dev/null +++ b/dist/changes-5.7.1 @@ -0,0 +1,27 @@ +Qt 5.7.1 is a bug-fix release. It maintains both forward and backward +compatibility (source and binary) with Qt 5.7.0. + +For more details, refer to the online documentation included in this +distribution. The documentation is also available online: + +http://doc.qt.io/qt-5/index.html + +The Qt version 5.7 series is binary compatible with the 5.6.x series. +Applications compiled for 5.6 will continue to run with 5.7. + +Some of the changes listed in this file include issue tracking numbers +corresponding to tasks in the Qt Bug Tracker: + +https://bugreports.qt.io/ + +Each of these identifiers can be entered in the bug tracker to obtain more +information about a particular change. + +**************************************************************************** +* Library * +**************************************************************************** + + - QSerialPort: + * [QTBUG-55847] Fixed crash after closing of ejected device on Linux. + * [QTBUG-55907] Now the RTS does not resets after changing of other + properties on Windows. diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp index 8e06ada..fafe8c5 100644 --- a/src/serialport/qserialport_unix.cpp +++ b/src/serialport/qserialport_unix.cpp @@ -778,6 +778,8 @@ bool QSerialPortPrivate::readNotification() char *ptr = buffer.reserve(bytesToRead); const qint64 readBytes = readFromPort(ptr, bytesToRead); + buffer.chop(bytesToRead - qMax(readBytes, qint64(0))); + if (readBytes <= 0) { QSerialPortErrorInfo error = getSystemError(); if (error.errorCode != QSerialPort::ResourceError) @@ -785,12 +787,9 @@ bool QSerialPortPrivate::readNotification() else setReadNotificationEnabled(false); setError(error); - buffer.chop(bytesToRead); return false; } - buffer.chop(bytesToRead - qMax(readBytes, qint64(0))); - newBytes = buffer.size() - newBytes; // If read buffer is full, disable the read port notifier. diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp index 9ab4448..84bf5b9 100644 --- a/src/serialport/qserialport_win.cpp +++ b/src/serialport/qserialport_win.cpp @@ -90,6 +90,9 @@ static inline void qt_set_common_props(DCB *dcb) if (dcb->fDtrControl == DTR_CONTROL_HANDSHAKE) dcb->fDtrControl = DTR_CONTROL_DISABLE; + + if (dcb->fRtsControl != RTS_CONTROL_HANDSHAKE) + dcb->fRtsControl = RTS_CONTROL_DISABLE; } static inline void qt_set_baudrate(DCB *dcb, qint32 baudrate) @@ -152,7 +155,8 @@ static inline void qt_set_flowcontrol(DCB *dcb, QSerialPort::FlowControl flowcon dcb->fInX = FALSE; dcb->fOutX = FALSE; dcb->fOutxCtsFlow = FALSE; - dcb->fRtsControl = RTS_CONTROL_DISABLE; + if (dcb->fRtsControl == RTS_CONTROL_HANDSHAKE) + dcb->fRtsControl = RTS_CONTROL_DISABLE; switch (flowcontrol) { case QSerialPort::NoFlowControl: break; @@ -278,7 +282,12 @@ bool QSerialPortPrivate::setRequestToSend(bool set) return false; } - return true; + DCB dcb; + if (!getDcb(&dcb)) + return false; + + dcb.fRtsControl = set ? RTS_CONTROL_ENABLE : RTS_CONTROL_DISABLE; + return setDcb(&dcb); } bool QSerialPortPrivate::flush() diff --git a/sync.profile b/sync.profile index a1e480d..bcd9ff6 100644 --- a/sync.profile +++ b/sync.profile @@ -1,7 +1,3 @@ %modules = ( "QtSerialPort" => "$basedir/src/serialport", ); - -%dependencies = ( - "qtbase" => "", -); diff --git a/tests/auto/qserialport/tst_qserialport.cpp b/tests/auto/qserialport/tst_qserialport.cpp index 33a48fe..94eaaa5 100644 --- a/tests/auto/qserialport/tst_qserialport.cpp +++ b/tests/auto/qserialport/tst_qserialport.cpp @@ -98,6 +98,7 @@ private slots: void rts(); void dtr(); + void independenceRtsAndDtr(); void flush(); void doubleFlush(); @@ -549,6 +550,58 @@ void tst_QSerialPort::dtr() QCOMPARE(qvariant_cast<bool>(dtrSpy.at(2).at(0)), toggle3); } +void tst_QSerialPort::independenceRtsAndDtr() +{ + QSerialPort serialPort(m_senderPortName); + QVERIFY(serialPort.open(QIODevice::ReadWrite)); // No flow control by default! + + QVERIFY(serialPort.setDataTerminalReady(true)); + QVERIFY(serialPort.setRequestToSend(true)); + QVERIFY(serialPort.isDataTerminalReady()); + QVERIFY(serialPort.isRequestToSend()); + + // check that DTR changing does not change RTS + QVERIFY(serialPort.setDataTerminalReady(false)); + QVERIFY(!serialPort.isDataTerminalReady()); + QVERIFY(serialPort.isRequestToSend()); + QVERIFY(serialPort.setDataTerminalReady(true)); + QVERIFY(serialPort.isDataTerminalReady()); + QVERIFY(serialPort.isRequestToSend()); + + // check that RTS changing does not change DTR + QVERIFY(serialPort.setRequestToSend(false)); + QVERIFY(!serialPort.isRequestToSend()); + QVERIFY(serialPort.isDataTerminalReady()); + QVERIFY(serialPort.setRequestToSend(true)); + QVERIFY(serialPort.isRequestToSend()); + QVERIFY(serialPort.isDataTerminalReady()); + + // check that baud rate changing does not change DTR or RTS + QVERIFY(serialPort.setBaudRate(115200)); + QVERIFY(serialPort.isRequestToSend()); + QVERIFY(serialPort.isDataTerminalReady()); + + // check that data bits changing does not change DTR or RTS + QVERIFY(serialPort.setDataBits(QSerialPort::Data7)); + QVERIFY(serialPort.isRequestToSend()); + QVERIFY(serialPort.isDataTerminalReady()); + + // check that parity changing does not change DTR or RTS + QVERIFY(serialPort.setParity(QSerialPort::EvenParity)); + QVERIFY(serialPort.isRequestToSend()); + QVERIFY(serialPort.isDataTerminalReady()); + + // check that stop bits changing does not change DTR or RTS + QVERIFY(serialPort.setStopBits(QSerialPort::TwoStop)); + QVERIFY(serialPort.isRequestToSend()); + QVERIFY(serialPort.isDataTerminalReady()); + + // check that software flow control changing does not change DTR or RTS + QVERIFY(serialPort.setFlowControl(QSerialPort::SoftwareControl)); + QVERIFY(serialPort.isRequestToSend()); + QVERIFY(serialPort.isDataTerminalReady()); +} + void tst_QSerialPort::handleBytesWrittenAndExitLoopSlot(qint64 bytesWritten) { QCOMPARE(bytesWritten, qint64(alphabetArray.size() + newlineArray.size())); |