diff options
Diffstat (limited to 'src/serialport')
-rw-r--r-- | src/serialport/qserialport_unix.cpp | 5 | ||||
-rw-r--r-- | src/serialport/qserialport_win.cpp | 13 |
2 files changed, 13 insertions, 5 deletions
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() |