summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIvan Solovev <ivan.solovev@qt.io>2022-06-15 11:02:03 +0200
committerIvan Solovev <ivan.solovev@qt.io>2022-06-20 09:49:58 +0200
commit048659a68a98e416d8190eae327cc6d2d48dc58b (patch)
tree1c1f019651a20c3d8b9106172d908cbab1433140
parent8360fcd497bcf6e52412629cd4e29f1ef05a93d6 (diff)
QModbusDevice: introduce an InvalidResponseError error code
[ChangeLog][QModbusDevice] Introduce a new InvalidResponseError error code. Use this code instead of UnknownError when QModbusClient fails to parse the response. Task-number: QTBUG-103879 Pick-to: 6.4 Change-Id: Ie4bd1d3c988590a851062a553103733e4a0f5d1c Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com> Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
-rw-r--r--src/serialbus/qmodbusclient.cpp2
-rw-r--r--src/serialbus/qmodbusdevice.cpp15
-rw-r--r--src/serialbus/qmodbusdevice.h3
3 files changed, 11 insertions, 9 deletions
diff --git a/src/serialbus/qmodbusclient.cpp b/src/serialbus/qmodbusclient.cpp
index 6f1335e..eca713c 100644
--- a/src/serialbus/qmodbusclient.cpp
+++ b/src/serialbus/qmodbusclient.cpp
@@ -336,7 +336,7 @@ void QModbusClientPrivate::processQueueElement(const QModbusResponse &pdu,
QModbusDataUnit unit = element.unit;
if (!q_func()->processResponse(pdu, &unit)) {
- element.reply->setError(QModbusDevice::UnknownError,
+ element.reply->setError(QModbusDevice::InvalidResponseError,
QModbusClient::tr("An invalid response has been received."));
return;
}
diff --git a/src/serialbus/qmodbusdevice.cpp b/src/serialbus/qmodbusdevice.cpp
index e7b891f..d43f3b3 100644
--- a/src/serialbus/qmodbusdevice.cpp
+++ b/src/serialbus/qmodbusdevice.cpp
@@ -166,13 +166,14 @@ void QModbusDevice::setConnectionParameter(ConnectionParameter parameter, const
\value ReplyAbortedError The reply was aborted due to a disconnection of
the device.
\value UnknownError An unknown error occurred.
-
- \note An UnknownError can also indicate that the received
- \l {QModbusPdu::}{FunctionCode} is not supported in the current
- implementation. In this case custom Modbus client implementations need to
- override the \l {QModbusClient::}{processResponse()} and
- \l {QModbusClient::}{processPrivateResponse()} methods to provide support
- for needed functions.
+ \value [since 6.4] InvalidResponseError An error occurred while parsing the
+ response, or the \l {QModbusPdu::}{FunctionCode}
+ is not supported by the current implementation.
+ In the latter case custom Modbus client
+ implementation can override the
+ \l {QModbusClient::}{processResponse()} and
+ \l {QModbusClient::}{processPrivateResponse()}
+ methods to provide support for needed functions.
*/
/*!
diff --git a/src/serialbus/qmodbusdevice.h b/src/serialbus/qmodbusdevice.h
index e10555e..878e3db 100644
--- a/src/serialbus/qmodbusdevice.h
+++ b/src/serialbus/qmodbusdevice.h
@@ -26,7 +26,8 @@ public:
TimeoutError,
ProtocolError,
ReplyAbortedError,
- UnknownError
+ UnknownError,
+ InvalidResponseError
};
Q_ENUM(Error)