Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QModbusTcpClient - More than one Modbus ID query in TCP Package
Forum Update on Monday, May 27th 2025

QModbusTcpClient - More than one Modbus ID query in TCP Package

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 1.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mr.Pfiff
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mr.Pfiff
        wrote on last edited by
        #3

        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 adding

        QLoggingCategory::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.

        1 Reply Last reply
        3

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved