summaryrefslogtreecommitdiff
path: root/src/serialport/qserialport_p.h
diff options
context:
space:
mode:
authorDenis Shienkov <denis.shienkov@gmail.com>2015-06-26 16:40:44 +0300
committerDenis Shienkov <denis.shienkov@gmail.com>2015-07-08 13:22:25 +0000
commit8919ea86c80001be7e826f5363f1b7548c7a8091 (patch)
tree14d8b27710aec73d50d579849616353e1e0a007e /src/serialport/qserialport_p.h
parent1eaa42c99d8442a40718b8560903b0bfeb401a0e (diff)
downloadqtserialport-8919ea86c80001be7e826f5363f1b7548c7a8091.tar.gz
Improve the processing of errors
Sometimes the error string would contain a wrong description which did not correspond to the system error code. The reason was qt_error_string() being called too late, when the system error might have already been overwritten. The error processing is now in QSPP::getSystemError(), which returns both the error code and the error description as soon as possible. * Now the QSPP::getSystemError() returns the new class QSerialPortErrorInfo which contains all necessary fields. * The new method QSPP::setError() which accepts the QSerialPortErrorInfo as input parameter is used. * The old private method QSP::setError() is removed, because it is not used anywhere. Change-Id: Ia7e4d617b863e2131175c52812cdf426ed963795 Reviewed-by: Sergey Belyashov <Sergey.Belyashov@gmail.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Diffstat (limited to 'src/serialport/qserialport_p.h')
-rw-r--r--src/serialport/qserialport_p.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/serialport/qserialport_p.h b/src/serialport/qserialport_p.h
index a39bc22..571b0de 100644
--- a/src/serialport/qserialport_p.h
+++ b/src/serialport/qserialport_p.h
@@ -106,6 +106,19 @@ class QSocketNotifier;
QString serialPortLockFilePath(const QString &portName);
#endif
+class QSerialPortErrorInfo
+{
+public:
+ explicit QSerialPortErrorInfo(QSerialPort::SerialPortError errorCode = QSerialPort::UnknownError,
+ const QString &errorString = QString())
+ : errorCode(errorCode)
+ , errorString(errorString)
+ {
+ }
+ QSerialPort::SerialPortError errorCode;
+ QString errorString;
+};
+
class QSerialPortPrivate : public QIODevicePrivate
{
Q_DECLARE_PUBLIC(QSerialPort)
@@ -144,7 +157,9 @@ public:
bool setFlowControl(QSerialPort::FlowControl flowControl);
bool setDataErrorPolicy(QSerialPort::DataErrorPolicy policy);
- QSerialPort::SerialPortError decodeSystemError(int systemErrorCode = -1) const;
+ QSerialPortErrorInfo getSystemError(int systemErrorCode = -1) const;
+
+ void setError(const QSerialPortErrorInfo &errorInfo);
qint64 writeData(const char *data, qint64 maxSize);
@@ -237,11 +252,11 @@ public:
bool initialize(QIODevice::OpenMode mode);
bool updateTermios();
- QSerialPort::SerialPortError setBaudRate_helper(qint32 baudRate,
+ QSerialPortErrorInfo setBaudRate_helper(qint32 baudRate,
QSerialPort::Directions directions);
- QSerialPort::SerialPortError setCustomBaudRate(qint32 baudRate,
+ QSerialPortErrorInfo setCustomBaudRate(qint32 baudRate,
QSerialPort::Directions directions);
- QSerialPort::SerialPortError setStandardBaudRate(qint32 baudRate,
+ QSerialPortErrorInfo setStandardBaudRate(qint32 baudRate,
QSerialPort::Directions directions);
bool isReadNotificationEnabled() const;