Solved QModbusTcpClient - More than one Modbus ID query in TCP Package
-
Hello dear all,
currently I'm using the class QModbusTcpClient. I want to read sequentially values from different Modbus addresses. In a thread I'm calling the following function via signal slot.
void BModbus::requestRequiredSlot(BModbusData *data) { QModbusDataUnit du(QModbusDataUnit::HoldingRegisters, data->address(), data->datatype().second); QModbusReply *reply = c->sendReadRequest(du,255); connect(reply,&QModbusReply::finished,this,&BModbus::readyReadSlot); }
Everything is working fine if I poll one Modbus address.
The Wireshark Protocol says that only one query is placed in one TCP-package.If I query more than one modbus address, then there are all modbus queries in one
TCP-package (also logged with Wireshark). And my device only sends an answer to the last ID in the package.Can anyone help me so that the QModbusTcpClient packs every Modbus ID into a seperate TCP-package instead of all in one?
Thanks for your help!
-
Hi,
The QtSerialBus being a pretty new module, I'd recommend posting this question on the interest mailing list. You'll find there QtSerialBus developers/maintainers. This forum is more user oriented.
-
Thanks to the Qt interest mailing list. I could solve my problem.
The problem wasn't the amount of Modbus packages within one TCP package. It seems like that in Wireshark. But the problem was the timeout value which was preset to low.
To solve my problem I've got the following hints:
1.) You can enable more detailed logging output by addingQLoggingCategory::setFilterRules(QStringLiteral("qt.modbus* = true"));
As first line to your main() function.
2.) The relevant code for your use case is in qmodbustcpclient_p.h. enqueueRequest() is the function that ultimately creates the ADU/PDU. There you can see the relevant logging output.