diff options
author | Karsten Heimrich <karsten.heimrich@qt.io> | 2021-02-24 10:36:25 +0100 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@qt.io> | 2021-03-10 07:00:46 +0000 |
commit | 4e7a1e844b352ca3da4dce7e96814d500d062cd8 (patch) | |
tree | ae036e0266d80601da347e3cbc78977cdc35c01f /src | |
parent | 17ac276e9b4fcde0f2e2b9a68a01ef6cdde31cf5 (diff) |
Fix Modbus custom command response processing
QModbusClient:
Checking for QModbusReply::Common will suppress calling into the
existing and supposed to be called QModbusClient::processPrivateRequest
function, which is to only way to handle a response from a raw request.
QModbusReply:
There was probably a workaround used since the QModbusReply does expose
the response and in case of QModbusReply::Raw the API user could still
get the reply and work their way through. Now you can get the result back,
proccessed by QModbusClient::processPrivateRequest if the user implements
it. The function behavior does not change, as in any case except the
QModbusReply::Common the the returned unit was invalid anyways.
[ChangeLog] Fix Modbus custom command response processing.
Task-number: QTBUG-91214
Change-Id: I09beeef9f236a29ffc0abf4b3dd323c9ce8ba1a4
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
(cherry picked from commit 09927894825d97197ffa656576e6be780371dda0)
Diffstat (limited to 'src')
-rw-r--r-- | src/serialbus/qmodbusclient.cpp | 2 | ||||
-rw-r--r-- | src/serialbus/qmodbusreply.cpp | 10 |
2 files changed, 7 insertions, 5 deletions
diff --git a/src/serialbus/qmodbusclient.cpp b/src/serialbus/qmodbusclient.cpp index 768a59d..a4840f6 100644 --- a/src/serialbus/qmodbusclient.cpp +++ b/src/serialbus/qmodbusclient.cpp @@ -361,7 +361,7 @@ void QModbusClientPrivate::processQueueElement(const QModbusResponse &pdu, return; } - if (element.reply->type() != QModbusReply::Common) { + if (element.reply->type() == QModbusReply::Broadcast) { element.reply->setFinished(true); return; } diff --git a/src/serialbus/qmodbusreply.cpp b/src/serialbus/qmodbusreply.cpp index 771d14c..ca65aac 100644 --- a/src/serialbus/qmodbusreply.cpp +++ b/src/serialbus/qmodbusreply.cpp @@ -147,15 +147,17 @@ void QModbusReply::setFinished(bool isFinished) If the request has not finished, has failed with an error or was a write request then the returned \l QModbusDataUnit instance is invalid. - \note If the \l type() of the reply is \l QModbusReply::Raw, the return - value will always be invalid. + \note If the \l type() of the reply is \l QModbusReply::Broadcast, the + return value will always be invalid. If the l type() of the reply is + \l QModbusReply::Raw, the return value might be invalid depending on the + implementation of \l QModbusClient::processPrivateResponse(). - \sa type(), rawResult() + \sa type(), rawResult(), QModbusClient::processPrivateResponse() */ QModbusDataUnit QModbusReply::result() const { Q_D(const QModbusReply); - if (type() == QModbusReply::Common) + if (type() != QModbusReply::Broadcast) return d->m_unit; return QModbusDataUnit(); } |