override processRequest in QModbusTcpServer
-
Hi
We are trying to delay the response time for a modbusTcpServer connection. We want to do this in order to not get flooded by requests from any client that connects to our device. The idea we have is to simply delay the response from our device. What we are doing is subclassing the QModbusTcpServer class and overriding the processRequest function. However, our override does not seem to be called at all (based on no debug code being shown). In the subclass header we have
protected:
QModbusResponse processRequest(const QModbusPdu &request) override;and
QModbusResponse ModbusTcpServer::processRequest(const QModbusPdu &request)
{
qDebug() << Q_FUNC_INFO;
.
// code to delay return so as to slow down response to client
.
return QModbusTcpServer::processRequest(request);
}The entire modbus code is running in a separate thread and is working fine with the exception that the override is not be called.
-
Please use the code formatting tags provided in the composition widnow to format your code. Makes it so much easier to read and saves the time of volunteers trying to help you.
The override syntax is correct. Virtual dispatch gets skipped in the class constructor. That could be one reason. Another reason could be, that the object isn't a
ModbusTcpServer
. Put some moreqDebug() << Q_FUNC_INFO;
e.g. in the class constructor.
You could also make the override public and see what happens when you call it directly.