summaryrefslogtreecommitdiff
path: root/src/serialport/qserialport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/serialport/qserialport.cpp')
-rw-r--r--src/serialport/qserialport.cpp34
1 files changed, 28 insertions, 6 deletions
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)
{