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

QModbusClient::processResponse() is never called

    XMLWordPrintable

Details

    • 9695bd15de (qt/qtserialbus/dev) 6e21bc7123 (qt/qtserialbus/6.2) cfd59f57bc (qt/tqtc-qtserialbus/5.15) adb37c4871 (qt/qtserialbus/6.3) 6e21bc7123 (qt/qtserialbus/6.2) 6e21bc7123 (qt/tqtc-qtserialbus/6.2) adb37c4871 (qt/tqtc-qtserialbus/6.3)

    Description

      QModbusServer::processRequest(), QModbusServer::processPrivateRequest(), QModbusClient::processResponse(), and QModbusClient::processPrivateResponse() are virtual methods. The documentation says that the QModbusServer methods are intended to be overridden, e.g.

       

      So let's say we do that... 

      class MyServer : public QModbusTcpServer
      {
          Q_OBJECT
      
      public:
          MyServer(QObject* parent = nullptr) : QModbusTcpServer(parent) {}
      
      protected:
          QModbusResponse processRequest(const QModbusPdu &request) override
          {
              qDebug() << "Processing request:" << request;
              auto result = QModbusTcpServer::processRequest(request);
              qDebug() << "\tResult:" << result;
              return result;
          }
          QModbusResponse processPrivateRequest(const QModbusPdu &request) override
          {
              qDebug() << "Processing private request:" << request;
              auto result = QModbusTcpServer::processPrivateRequest(request);
              qDebug() << "\tResult:" << result;
              return result;
          }
      };
      
      class MyClient : public QModbusTcpClient
      {
          Q_OBJECT
      
      public:
          MyClient(QObject* parent = nullptr) : QModbusTcpClient(parent) {}
      
      protected:
          bool processPrivateResponse(const QModbusResponse &response, QModbusDataUnit *data) override
          {
              qDebug() << "Processing private response:" << response << data;
              bool result = QModbusTcpClient::processPrivateResponse(response, data);
              qDebug() << "\tResult:" << result;
              return result;
          }
      
          bool processResponse(const QModbusResponse &response, QModbusDataUnit *data) override
          {
              qDebug() << "Processing response:" << response << data;
              bool result = QModbusTcpClient::processResponse(response, data);
              qDebug() << "\tResult:" << result;
              return result;
          }
      };
      

      When MyClient sends a request to MyServer, the debug output does show "Processing request: ..." in the server app, but "Processing response: ..." is never shown on the client app.

      It appears that QModbusClientPrivate::processResponse() is called directly instead.

      Thus, overriding the QModbusClient methods does nothing.

      Attachments

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

        Activity

          People

            heimrich Karsten Heimrich
            skoh-qt Sze Howe Koh
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes