QModbusRtuSerialServer 類

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

頭: #include <QModbusRtuSerialServer>
CMake: find_package(Qt6 REQUIRED COMPONENTS SerialBus)
target_link_libraries(mytarget PRIVATE Qt6::SerialBus)
qmake: QT += serialbus
Since: Qt 6.2
繼承: QModbusServer

公共函數

QModbusRtuSerialServer (QObject * parent = nullptr)
virtual ~QModbusRtuSerialServer ()
(從 6.2 起) int interFrameDelay () const
(從 6.2 起) void setInterFrameDelay (int microseconds )

重實現公共函數

virtual bool processesBroadcast () const override

重實現保護函數

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

詳細描述

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 ().

成員函數文檔編製

[explicit] QModbusRtuSerialServer:: QModbusRtuSerialServer ( QObject * parent = nullptr)

構造 QModbusRtuSerialServer 采用指定 parent serverAddress 預置為 1 .

[virtual noexcept] QModbusRtuSerialServer:: ~QModbusRtuSerialServer ()

銷毀 QModbusRtuSerialServer 實例。

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

重實現: QModbusDevice::close ().

[since 6.2] int QModbusRtuSerialServer:: interFrameDelay () const

Returns the amount of microseconds for the silent interval between two consecutive Modbus messages.

該函數在 Qt 6.2 引入。

另請參閱 setInterFrameDelay ().

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

重實現: QModbusDevice::open ().

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

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

重實現: QModbusServer::processRequest (const QModbusPdu &request).

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 server will be answered with a Modbus exception response with the exception code QModbusExceptionResponse::IllegalFunction.

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

重實現: QModbusServer::processesBroadcast () const.

[since 6.2] void QModbusRtuSerialServer:: setInterFrameDelay ( int microseconds )

Sets the amount of microseconds for the silent interval between two consecutive Modbus messages. By default, the class implementation will use a pre-calculated value according to the Modbus specification. A active or running connection is not affected by such delay changes.

注意: microseconds 被設為 -1 或 microseconds is less than the pre-calculated delay then this pre-calculated value is used as frame delay.

該函數在 Qt 6.2 引入。

另請參閱 interFrameDelay ().