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

qmodbusservice returns incorrect register values

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Done
    • Affects Version/s: 5.7.1, 5.9.3, 5.11.0 Alpha
    • Fix Version/s: 5.12.0 Beta 3
    • Component/s: SerialBus: MOD Bus
    • Labels:
      None
    • Environment:
      QT 5.9.2 or QT 5.7 compiled with mingw 5.3.0 32bit on windows 10 home edition.
    • Commits:
      df179c4c18d8feeef48e38cc76cd2a0395ba5de1 (qt/qtserialbus/5.12)

      Description

      If the register mapping supplied to QModbusService::setMap does not include register 0, the registers values returned by the server in response to a read request will be incorrect. Depending on circumstances the number of register values in the response may also be smaller than the number of requested registers (at the same time the register count in the response frame is correct, hence a incorrect data frame is returned).

      The problem is located in QModbusServer::readData. The second last line reads:

      {{ newData>setValues(current.values().mid(newData>startAddress(), newData->valueCount())); }}

      Proposed change:

      {{ newData>setValues(current.values().mid(newData>startAddress() - current.startAddress(), newData->valueCount())); }}

      The QVector returned by current.values() returns interval register values starting with current.startRegister(). The first register to be copied to newData is newData->startAddress(). This means that the offset between newData and is newData->startAddress() - current.startAddress().

       

        Attachments

        For Gerrit Dashboard: QTBUG-64843
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            ablasche Alex Blasche
            Reporter:
            ejvr Ernst de Vries
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes