QModbusRtuSerialSlave Class

The QModbusRtuSerialSlave class represents a Modbus server that uses a serial port for its communication with the Modbus client. More...

Header: #include <QModbusRtuSerialSlave>
qmake: QT += serialbus
Since: Qt 5.8
Inherits: QModbusServer

Public Functions

QModbusRtuSerialSlave(QObject *parent = nullptr)

Reimplemented Public Functions

virtual bool processesBroadcast() const override

Reimplemented Protected Functions

virtual void close() override
virtual bool open() override
virtual QModbusResponse processRequest(const QModbusPdu &request) override

Additional Inherited Members

Detailed Description

The QModbusRtuSerialSlave class represents a Modbus server that uses a serial port for its communication with the Modbus client.

Communication via Modbus requires the interaction between a single Modbus client instance and multiple Modbus server. This class provides the Modbus server implementation via a serial port.

Since multiple Modbus server instances can interact with a Modbus client at the same time (using a serial bus), servers are identified by their serverAddress().

Member Function Documentation

QModbusRtuSerialSlave::QModbusRtuSerialSlave(QObject *parent = nullptr)

Constructs a QModbusRtuSerialSlave with the specified parent. The serverAddress preset is 1.


Destroys the QModbusRtuSerialSlave instance.

[override virtual protected] void QModbusRtuSerialSlave::close()

Reimplemented from QModbusDevice::close().

[override virtual protected] bool QModbusRtuSerialSlave::open()

Reimplemented from QModbusDevice::open().

Note: When calling this function, existing buffered data is removed from the serial port.

[override virtual protected] QModbusResponse QModbusRtuSerialSlave::processRequest(const QModbusPdu &request)

Reimplemented from QModbusServer::processRequest().

Processes the Modbus client request specified by request and returns a Modbus response.

The Modbus function QModbusRequest::EncapsulatedInterfaceTransport with MEI Type 13 (0x0D) CANopen General Reference is filtered out because it is usually Modbus TCP or Modbus serial ASCII only.

A request to the RTU serial slave will be answered with a Modbus exception response with the exception code QModbusExceptionResponse::IllegalFunction.

[override virtual] bool QModbusRtuSerialSlave::processesBroadcast() const

Reimplemented from QModbusServer::processesBroadcast().

© 2017 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.