From bd56a7565bfbabb7344025f7c6b622bbcb3ed96f Mon Sep 17 00:00:00 2001 From: Aleksei <35397033+Aleksei521@users.noreply.github.com> Date: Tue, 29 Oct 2019 22:31:59 +0300 Subject: [PATCH] Incorrectly calculated size in response. Incorrectly calculated the number of objects in the response if it does not correspond to the total number of objects. --- src/serialbus/qmodbuspdu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/serialbus/qmodbuspdu.cpp b/src/serialbus/qmodbuspdu.cpp index 9ca90271..7678a0ea 100644 --- a/src/serialbus/qmodbuspdu.cpp +++ b/src/serialbus/qmodbuspdu.cpp @@ -752,7 +752,7 @@ int QModbusResponse::calculateDataSize(const QModbusResponse &response) } const QByteArray data = response.data(); - quint8 numOfObjects = quint8(data[5]); + quint8 numOfObjects = (data[4]==0)? quint8(data[5])-quint8(data[6]) : quint8(data[4])-quint8(data[6]); quint8 objectSize = quint8(data[7]); // 6 byte header size + (2 * n bytes fixed per object) + first object size