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

qmodbusservice returns incorrect register values

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.12.0 Beta 3
    • 5.7.1, 5.9.3, 5.11.0 Alpha
    • SerialBus: MOD Bus
    • None
    • QT 5.9.2 or QT 5.7 compiled with mingw 5.3.0 32bit on windows 10 home edition.
    • 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

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

        Activity

          People

            ablasche Alex Blasche
            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