Details
-
Bug
-
Resolution: Fixed
-
P3: Somewhat important
-
5.15.8, 6.3.0 Beta2
-
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.
- https://doc.qt.io/qt-6/qmodbusserver.html#processRequest
- https://doc.qt.io/qt-6/qmodbusclient.html#processPrivateResponse
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.