Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-103867

User suggestion: Shrink data to the calculated size before it is compared against MaxPduDataSize

    XMLWordPrintable

Details

    • Windows

    Description

      User contacted Qt Support about following suggestion:

      QModbusPduPrivate::pduFromStream() drops large responses for modbus function EncapsulatedInterfaceTransport

      I am developing ambedded device for modbus tcp that can handle the modbus function EncapsulatedInterfaceTransport and Mei Type 13 ( canOpen general reference ).

      I am using Qt to develop a windows Modbus tcp client for that device and now I have got a problem.

      1) Some background infos:
      The maximun modbus PDU size is 253 so an modbus response can have 252 bytes of data. The canOpen general referenc Header is between 11 and 15 bytes long so there should be 239 to 241 bytes left for payload.

      2) The bug.
      I have installed my own DataSizeCalculator with QModbusResponse::registerDataSizeCalculator() for the function QModbusPdu::EncapsulatedInterfaceTransport because the default implementation cannot handle that function.

      When a response with more than 131 bytes of paylod is received, QModbusPduPrivate::pduFromStream() will drop the response.

      Here is the original debug output :
      qt.modbus: (TCP client) Connected to QHostAddress("172.16.12.163") on port 502
      qt.modbus.lowlevel: (TCP client) Sent TCP ADU: "00000000000d012b0d00000103eb00000000f0"
      qt.modbus: (TCP client) Sent TCP PDU: 0x2b0d00000103eb00000000f0 with tId: 0
      qt.modbus.lowlevel: (TCP client) Response buffer: "0000000000fd012b0d00000103eb00000000f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
      qt.modbus: (TCP client) tid: 0 size: fd server address: 1
      qt.modbus: (TCP client) Received PDU: 0 ""

      So I took a look at the function QModbusPduPrivate::pduFromStream() in qmodbuspdu.cpp. And I saw this.
      - Line 146 : Up to MaxPduDataSize Byte are taken from the stream with peek(). data now contains the correct data.
      - Line 154: The size is calculated correctly by my installed function.
      - Line 180: The calculated size is ignored and the data is resized to the stream length -1. This size is larger than MaxPduDataSize.
      - Line 189 : Because data.size() is larger than MaxPduDataSize the response is not handled.

      My Suggestion: Shrink data to the calculated size before it is compared against MaxPduDataSize .

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            heimrich Karsten Heimrich
            tero.pelkonen Tero Pelkonen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes