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

Using a scattered register map breaks QModbusServer

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • P2: Important
    • None
    • 5.10.0
    • SerialBus: MOD Bus
    • None

    Description

      QModbusServer only supports subsequent data unit register addresses. If one tries to add multiple ranges of values, the current implementation breaks and fails to read/write data units.

      My current workaround: Sub-class QModbusServer and implement separate data unit storages, one for each register type. I've introduced a new method called initDataUnit(), which I use iso. setMap(). I'd suggest implementing something similar in Qt in order to support scattered register maps.

      typedef QMap<int, QModbusDataUnit> RegisterMap;
      
      class MyModbusServer : public QModbusServer {
      {
      //...
      
      public:
          bool setMap(...) { return false; }
      
          void initDataUnit(const QModbusDataUnit &dataUnit) { /* add unit to one of the maps */ }
      
      protected:
          bool writeData(...) { ... }
          bool readData(...) { ... }
       
      
      private:
          RegisterMap m_coils;
          RegisterMap m_discrete_input;
          RegisterMap m_input_registers;
          RegisterMap m_holding_registers;
      }

      Attachments

        1. modbusserver.cpp
          3 kB
        2. modbusserver.h
          1.0 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            heimrich Karsten Heimrich
            erlendaasland Erlend Egeberg Aasland
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes