QModbusRtuSerialClient Class

QModbusRtuSerialClient 类表示使用串行总线与 Modbus 服务器通信的 Modbus 客户端。更多

头文件: #include <QModbusRtuSerialClient>
CMake: find_package(Qt6 REQUIRED COMPONENTS SerialBus)
target_link_libraries(mytarget PRIVATE Qt6::SerialBus)
qmake: QT += serialbus
Qt 6.2
继承: QModbusClient

公共函数

QModbusRtuSerialClient(QObject *parent = nullptr)
int interFrameDelay() const
void setInterFrameDelay(int microseconds)
void setTurnaroundDelay(int turnaroundDelay)
int turnaroundDelay() const

重新实现的保护函数

virtual void close() override
virtual bool open() override

详细说明

通过 Modbus 进行通信需要在单个 Modbus 客户实例和多个 Modbus 服务器之间进行交互。该类通过串行端口提供客户端实现。

成员函数文档

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

使用指定的parent 构建串行 Modbus 客户端。

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

重新实现:QModbusDevice::close().

int QModbusRtuSerialClient::interFrameDelay() const

返回两个连续 Modbus 报文之间静默间隔的微秒数。

另请参阅 setInterFrameDelay()。

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

重新实现:QModbusDevice::open().

注意: 调用该函数时,现有的缓冲数据将从串行端口移除。

void QModbusRtuSerialClient::setInterFrameDelay(int microseconds)

设置两个连续 Modbus 信息之间的静默间隔时间microseconds 。默认情况下,类实现将使用根据 Modbus 规范预先计算的值。活动或运行中的连接不会受到这种延迟变化的影响。

注: 如果microseconds 设置为-1 或microseconds 小于预先计算的延迟值,则该预先计算值将用作帧延迟。

另请参阅 interFrameDelay()。

void QModbusRtuSerialClient::setTurnaroundDelay(int turnaroundDelay)

将 Modbus 广播和连续 Modbus 报文之间的静默间隔毫秒数设置为turnaroundDelay 。通常,周转延迟的范围为100200 毫秒。

另请参阅 turnaroundDelay() 。

int QModbusRtuSerialClient::turnaroundDelay() const

返回 Modbus 广播和连续 Modbus 报文之间静默间隔的毫秒数。默认值为100 毫秒。

另请参阅 setTurnaroundDelay()。

© 2025 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.