Qt World Summit: Submit your Presentation

Limitation in QModbusTcpClient's data size

  • The story behind: Using a QModbusTcpClient I am trying to read the content from a device connected to a Modbus/TCP network. For that purpose I have written a Windows program (tested on 7 and 10) in Qt C++ (Qt version 5.7.0) which essentially calls QModbusClient::sendReadRequest with QModbusDataUnit::QModbusDataUnit(RegisterType type, int address, quint16 size) as a parameter, where type is HoldingRegisters, address equals to 1000 (could be another address, it is not important for this particular issue) and size is the length of the desired data to be read from the device.

    The issue: Everything works well when size is less or equal to 63 registers. Every attempt to go beyond this value results in an error, which depends on the device I am testing the program with, but generally says invalid request.


    I have tested this with several real devices and with a Modbus/TCP simulator obtaining the same results, i.e. size <= 63 -> okay; size > 63 -> error
    Modpoll from another side allows me to read a data chunk from the same devices and simulator with a size greater than 63 registers

    Some research: Here it is stated, that there is indeed a limitation, but it is 256 bytes, which equals to 128 16-bit registers, in other words - way above the limit of my read attempts.

    My suspicion: It appears that QModbusTcpClient does not allow reading more than a 63 registers.

    Question: Have anyone experienced such an issue using QModbusTcpClient and is there a way to overcome this limitation, apart from reading the data on two passes?

  • Moderators

    @peter-li Hi and welcome,

    I've ran into that issue as well. It's not always limited to the Qt Side, the ModbusMaster can also limit the max size of the requested registers.

    And no, besides splitting the request, I know of no other way to deal with the issue

  • @j-hilk thanks for your reply, i will try that you said

Log in to reply