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. QModbusDataUnit startAddress offset
Forum Updated to NodeBB v4.3 + New Features

QModbusDataUnit startAddress offset

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 256 Views 1 Watching
  • 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
    Mark81
    wrote on last edited by
    #1

    Referring to the manufacturer modbus' register table, I noticed I have to pass to the startAddress parameter a value with offset -1. Example:

    QModbusDataUnit readRequest()
    {
        return QModbusDataUnit(QModbusDataUnit::HoldingRegisters, 49, 2); // <--- actually is 50
    }
    
    void read()
    {
        if (auto *reply = _device->sendReadRequest(readRequest(), 1))
        {
            if (!reply->isFinished()) QObject::connect(reply, &QModbusReply::finished, [reply]()
            {
            // .....
    }
    

    In that table the actual address is 50. If I use, say, modpoll I pass 50 as start address. But with QModbusDataUnit I have to pass 49!

    Is this offset documented anywhere?

    J.HilkJ 1 Reply Last reply
    0
    • M Mark81

      Referring to the manufacturer modbus' register table, I noticed I have to pass to the startAddress parameter a value with offset -1. Example:

      QModbusDataUnit readRequest()
      {
          return QModbusDataUnit(QModbusDataUnit::HoldingRegisters, 49, 2); // <--- actually is 50
      }
      
      void read()
      {
          if (auto *reply = _device->sendReadRequest(readRequest(), 1))
          {
              if (!reply->isFinished()) QObject::connect(reply, &QModbusReply::finished, [reply]()
              {
              // .....
      }
      

      In that table the actual address is 50. If I use, say, modpoll I pass 50 as start address. But with QModbusDataUnit I have to pass 49!

      Is this offset documented anywhere?

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @Mark81 seems like modpoll is starting its counting by 1 instead of 0.
      Which is the incorrect way, since register 0 is defined as a valid register in the standard


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      M 1 Reply Last reply
      3
      • J.HilkJ J.Hilk

        @Mark81 seems like modpoll is starting its counting by 1 instead of 0.
        Which is the incorrect way, since register 0 is defined as a valid register in the standard

        M Offline
        M Offline
        Mark81
        wrote on last edited by
        #3

        @J-Hilk got it, that would mean also the manufacturer modbus table is wrong, because the addresses in the table match with the modpoll "convention".

        1 Reply Last reply
        0

        • Login

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