From 39d79e16577331f2a8f84df2f63d28e2f03a1ca4 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Thu, 23 Feb 2017 20:53:55 +0300 Subject: Doc: Describe limitations to use of QSP::setRequestToSend() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The limitations were introduced by the commit 56c001b, but were not documented. Change-Id: I5e44ab78e2e5cce2477ebc1f83280fa8c22e0ef6 Reviewed-by: Topi Reiniƶ --- src/serialport/qserialport.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/serialport/qserialport.cpp b/src/serialport/qserialport.cpp index 81beb2d..8140deb 100644 --- a/src/serialport/qserialport.cpp +++ b/src/serialport/qserialport.cpp @@ -956,6 +956,10 @@ bool QSerialPort::isDataTerminalReady() property; otherwise \c false is returned and the error code is set to NotOpenError. + \note An attempt to control the RTS signal in the HardwareControl mode + will fail with error code set to UnsupportedOperationError, because + the signal is automatically controlled by the driver. + \sa pinoutSignals() */ bool QSerialPort::setRequestToSend(bool set) -- cgit v1.2.1 From 5c6a433d6a6a4176082036ae94931467101a199a Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Sun, 12 Mar 2017 16:52:03 +0300 Subject: Doc: Remove unnecessary \fn tag for the swap() function ... as this function is implemented in cpp file. Change-Id: Ia5a0c262ebdb4b98b4575c85ab45fdc93742731f Reviewed-by: Leena Miettinen --- src/serialport/qserialportinfo.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/serialport/qserialportinfo.cpp b/src/serialport/qserialportinfo.cpp index 2547e01..f49051d 100644 --- a/src/serialport/qserialportinfo.cpp +++ b/src/serialport/qserialportinfo.cpp @@ -122,8 +122,7 @@ QSerialPortInfo::~QSerialPortInfo() { } -/*! \fn void QSerialPortInfo::swap(QSerialPortInfo &other) - +/*! Swaps QSerialPortInfo \a other with this QSerialPortInfo. This operation is very fast and never fails. */ -- cgit v1.2.1 From e5dfb098638628b0215e11791bce372a656af390 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Fri, 21 Apr 2017 19:31:58 +0300 Subject: Fix bytesToWrite() We should not add the size of the internal write buffer here because QIODevice::bytesToWrite() already checks it. Also, take into account the size of 'writeChunkBuffer' on Windows. Change-Id: I87dfcb4dd1cd9d2bbb6f82a084d79fb4db9323d8 Reviewed-by: Thiago Macieira --- src/serialport/qserialport.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/serialport/qserialport.cpp b/src/serialport/qserialport.cpp index 8140deb..5534bb8 100644 --- a/src/serialport/qserialport.cpp +++ b/src/serialport/qserialport.cpp @@ -1283,8 +1283,11 @@ qint64 QSerialPort::bytesAvailable() const */ qint64 QSerialPort::bytesToWrite() const { - Q_D(const QSerialPort); - return QIODevice::bytesToWrite() + d->writeBuffer.size(); + qint64 pendingBytes = QIODevice::bytesToWrite(); +#if defined(Q_OS_WIN32) + pendingBytes += d_func()->writeChunkBuffer.size(); +#endif + return pendingBytes; } /*! -- cgit v1.2.1 From 225ef1baeb0e49f157f3ba1271915e623bd27dd9 Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Sat, 22 Apr 2017 19:33:33 +0300 Subject: Fix possible UB in read() under Unix If the user calls setReadBufferSize() with a value lesser than the current size of the read buffer, then we get UB in readNotification(): readFromPort(nullptr, some_negative_value); Change-Id: Iddf5838c84c8615670285e9883c48f29faacc07e Reviewed-by: Denis Shienkov --- src/serialport/qserialport_unix.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp index 8f9f087..4df1fcb 100644 --- a/src/serialport/qserialport_unix.cpp +++ b/src/serialport/qserialport_unix.cpp @@ -773,7 +773,7 @@ bool QSerialPortPrivate::readNotification() if (readBufferMaxSize && bytesToRead > (readBufferMaxSize - buffer.size())) { bytesToRead = readBufferMaxSize - buffer.size(); - if (bytesToRead == 0) { + if (bytesToRead <= 0) { // Buffer is full. User must read data from the buffer // before we can read more from the port. setReadNotificationEnabled(false); -- cgit v1.2.1 From d88ded29d968b8ccf41d4dffa73c3f8f030a9f5d Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Tue, 25 Apr 2017 19:28:04 +0300 Subject: Fix possible UB in ReadFile() This patch replicates commit 225ef1baeb0e49f157f3ba1271915e623bd27dd9 for Windows. Change-Id: Ic4e3444183289e7ce1a487500633fb5ad95590b9 Reviewed-by: Denis Shienkov --- src/serialport/qserialport_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp index 84bf5b9..0494889 100644 --- a/src/serialport/qserialport_win.cpp +++ b/src/serialport/qserialport_win.cpp @@ -545,7 +545,7 @@ bool QSerialPortPrivate::startAsyncRead() if (readBufferMaxSize && bytesToRead > (readBufferMaxSize - buffer.size())) { bytesToRead = readBufferMaxSize - buffer.size(); - if (bytesToRead == 0) { + if (bytesToRead <= 0) { // Buffer is full. User must read data from the buffer // before we can read more from the port. return false; -- cgit v1.2.1 From 4c465d90c79ab4a9d6f031143cddd0f148d4101b Mon Sep 17 00:00:00 2001 From: Alex Trotsenko Date: Thu, 4 May 2017 19:10:08 +0300 Subject: QSPP::startAsyncRead(): set a correct type for variable 'bytesToRead' takes the result of signed 64-bit computation which could be negative. So, its type should be qint64. Change-Id: Ib51129143fcb70475ad383df417ae4282c858e41 Reviewed-by: Oswald Buddenhagen --- src/serialport/qserialport_win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp index 0494889..87f9e7b 100644 --- a/src/serialport/qserialport_win.cpp +++ b/src/serialport/qserialport_win.cpp @@ -541,7 +541,7 @@ bool QSerialPortPrivate::startAsyncRead() if (readStarted) return true; - DWORD bytesToRead = ReadChunkSize; + qint64 bytesToRead = ReadChunkSize; if (readBufferMaxSize && bytesToRead > (readBufferMaxSize - buffer.size())) { bytesToRead = readBufferMaxSize - buffer.size(); -- cgit v1.2.1