summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.qmake.conf2
-rw-r--r--src/serialport/qserialport.cpp34
-rw-r--r--src/serialport/qserialport.h7
-rw-r--r--src/serialport/qserialport_p.h2
-rw-r--r--src/serialport/serialport-lib.pri2
-rw-r--r--tests/auto/auto.pro2
6 files changed, 36 insertions, 13 deletions
diff --git a/.qmake.conf b/.qmake.conf
index a2a0d41..aefa1e7 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1,3 +1,3 @@
load(qt_build_config)
-MODULE_VERSION = 5.7.1
+MODULE_VERSION = 5.8.0
diff --git a/src/serialport/qserialport.cpp b/src/serialport/qserialport.cpp
index b2b6a94..d23e3b6 100644
--- a/src/serialport/qserialport.cpp
+++ b/src/serialport/qserialport.cpp
@@ -88,7 +88,6 @@ QSerialPortErrorInfo::QSerialPortErrorInfo(QSerialPort::SerialPortError newError
QSerialPortPrivate::QSerialPortPrivate()
: readBufferMaxSize(0)
- , writeBuffer(InitialBufferSize)
, error(QSerialPort::NoError)
, inputBaudRate(9600)
, outputBaudRate(9600)
@@ -123,6 +122,7 @@ QSerialPortPrivate::QSerialPortPrivate()
, writeSequenceStarted(false)
#endif
{
+ writeBufferChunkSize = InitialBufferSize;
}
void QSerialPortPrivate::setError(const QSerialPortErrorInfo &errorInfo)
@@ -131,6 +131,7 @@ void QSerialPortPrivate::setError(const QSerialPortErrorInfo &errorInfo)
error = errorInfo.errorCode;
q->setErrorString(errorInfo.errorString);
+ emit q->errorOccurred(error);
emit q->error(error);
}
@@ -211,6 +212,10 @@ void QSerialPortPrivate::setError(const QSerialPortErrorInfo &errorInfo)
If \l{QIODevice::}{waitForReadyRead()} returns false, the
connection has been closed or an error has occurred.
+ If an error occurs at any point in time, QSerialPort will emit the
+ errorOccurred() signal. You can also call error() to find the type of
+ error that occurred last.
+
Programming with a blocking serial port is radically different from
programming with a non-blocking serial port. A blocking serial port
does not require an event loop and typically leads to simpler code.
@@ -1180,9 +1185,17 @@ void QSerialPort::clearError()
/*!
\fn void QSerialPort::error(SerialPortError error)
+ \obsolete
+
+ Use errorOccurred() instead.
+*/
- This signal is emitted after the error has been changed. The new error
- is passed as \a error.
+/*!
+ \fn void QSerialPort::errorOccurred(SerialPortError error)
+ \since 5.8
+
+ This signal is emitted when an error occurs in the serial port.
+ The specified \a error describes the type of error that occurred.
\sa QSerialPort::error
*/
@@ -1283,10 +1296,11 @@ bool QSerialPort::canReadLine() const
This function blocks until new data is available for reading and the
\l{QIODevice::}{readyRead()} signal has been emitted. The function
- will timeout after \a msecs milliseconds.
+ will timeout after \a msecs milliseconds; the default timeout is
+ 30000 milliseconds.
- The function returns true if the readyRead() signal is emitted and
- there is new data available for reading; otherwise it returns false
+ The function returns \c true if the readyRead() signal is emitted and
+ there is new data available for reading; otherwise it returns \c false
(if an error occurred or the operation timed out).
\sa waitForBytesWritten()
@@ -1311,6 +1325,14 @@ bool QSerialPort::waitForReadyRead(int msecs)
/*!
\reimp
+
+ This function blocks until at least one byte has been written to the serial
+ port and the \l{QIODevice::}{bytesWritten()} signal has been emitted. The
+ function will timeout after \a msecs milliseconds; the default timeout is
+ 30000 milliseconds.
+
+ The function returns \c true if the bytesWritten() signal is emitted; otherwise
+ it returns \c false (if an error occurred or the operation timed out).
*/
bool QSerialPort::waitForBytesWritten(int msecs)
{
diff --git a/src/serialport/qserialport.h b/src/serialport/qserialport.h
index 3289ca1..e4a61ed 100644
--- a/src/serialport/qserialport.h
+++ b/src/serialport/qserialport.h
@@ -262,8 +262,8 @@ public:
qint64 bytesToWrite() const Q_DECL_OVERRIDE;
bool canReadLine() const Q_DECL_OVERRIDE;
- bool waitForReadyRead(int msecs) Q_DECL_OVERRIDE;
- bool waitForBytesWritten(int msecs) Q_DECL_OVERRIDE;
+ bool waitForReadyRead(int msecs = 30000) Q_DECL_OVERRIDE;
+ bool waitForBytesWritten(int msecs = 30000) Q_DECL_OVERRIDE;
#if QT_DEPRECATED_SINCE(5, 5)
QT_DEPRECATED bool sendBreak(int duration = 0);
@@ -284,7 +284,10 @@ Q_SIGNALS:
#endif
void dataTerminalReadyChanged(bool set);
void requestToSendChanged(bool set);
+#if QT_DEPRECATED_SINCE(5, 8)
void error(QSerialPort::SerialPortError serialPortError);
+#endif
+ void errorOccurred(QSerialPort::SerialPortError error);
#if QT_DEPRECATED_SINCE(5, 5)
QT_DEPRECATED void settingsRestoredOnCloseChanged(bool restore);
#endif
diff --git a/src/serialport/qserialport_p.h b/src/serialport/qserialport_p.h
index e240798..10fda34 100644
--- a/src/serialport/qserialport_p.h
+++ b/src/serialport/qserialport_p.h
@@ -55,7 +55,6 @@
#include "qserialport.h"
-#include <private/qringbuffer_p.h>
#include <private/qiodevice_p.h>
#if defined(Q_OS_WIN32)
@@ -169,7 +168,6 @@ public:
static QList<qint32> standardBaudRates();
qint64 readBufferMaxSize;
- QRingBuffer writeBuffer;
QSerialPort::SerialPortError error;
QString systemLocation;
qint32 inputBaudRate;
diff --git a/src/serialport/serialport-lib.pri b/src/serialport/serialport-lib.pri
index 02dc3e5..9f83989 100644
--- a/src/serialport/serialport-lib.pri
+++ b/src/serialport/serialport-lib.pri
@@ -1,6 +1,6 @@
INCLUDEPATH += $$PWD
-unix:contains(QT_CONFIG, libudev) {
+unix:qtConfig(libudev) {
DEFINES += LINK_LIBUDEV
INCLUDEPATH += $$QMAKE_INCDIR_LIBUDEV
LIBS_PRIVATE += $$QMAKE_LIBS_LIBUDEV
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index 2fa03f0..6c0bcec 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -1,5 +1,5 @@
TEMPLATE = subdirs
SUBDIRS += qserialport qserialportinfo qserialportinfoprivate cmake
-!contains(QT_CONFIG, private_tests): SUBDIRS -= \
+!qtConfig(private_tests): SUBDIRS -= \
qserialportinfoprivate