本页内容

QModbusExceptionResponse Class

QModbusExceptionResponse 是一个容器类,用于封装 Modbus ADU 中的函数和错误代码。更多内容...

头文件: #include <QModbusExceptionResponse>
CMake: find_package(Qt6 REQUIRED COMPONENTS SerialBus)
target_link_libraries(mytarget PRIVATE Qt6::SerialBus)
qmake: QT += serialbus
继承自: QModbusResponse

公共函数

QModbusExceptionResponse()
QModbusExceptionResponse(const QModbusPdu &pdu)
QModbusExceptionResponse(QModbusPdu::FunctionCode code, QModbusPdu::ExceptionCode ec)
void setExceptionCode(QModbusPdu::ExceptionCode ec)

重新实现的公共函数

virtual void setFunctionCode(QModbusPdu::FunctionCode c) override

详细说明

典型的 QModbusExceptionResponse 响应可能如下所示:

QModbusExceptionResponse exception(QModbusExceptionResponse::ReportServerId,
    QModbusExceptionResponse::ServerDeviceFailure);

成员函数文档

[constexpr noexcept default] QModbusExceptionResponse::QModbusExceptionResponse()

构建了一个无效的 QModbusExceptionResponse。

QModbusExceptionResponse::QModbusExceptionResponse(const QModbusPdu &pdu)

创建pdu 的副本。

QModbusExceptionResponse::QModbusExceptionResponse(QModbusPdu::FunctionCode code, QModbusPdu::ExceptionCode ec)

构建一个 QModbusExceptionResponse 对象,其中功能代码设置为code ,异常错误代码设置为ec 。

void QModbusExceptionResponse::setExceptionCode(QModbusPdu::ExceptionCode ec)

将响应的异常代码设置为ec 。

[override virtual] void QModbusExceptionResponse::setFunctionCode(QModbusPdu::FunctionCode c)

重写自:QModbusPdu::setFunctionCode (QModbusPdu::FunctionCode code)。

将响应的功能代码设置为c 。

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