QCanBusDeviceInfo Class

QCanBusDeviceInfo 提供有关 CAN 总线接口的信息。更多

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

公共函数

QCanBusDeviceInfo(const QCanBusDeviceInfo &other)
~QCanBusDeviceInfo()
(since 6.0) QString alias() const
int channel() const
QString description() const
bool hasFlexibleDataRate() const
bool isVirtual() const
QString name() const
(since 6.2) QString plugin() const
QString serialNumber() const
void swap(QCanBusDeviceInfo &other)
QCanBusDeviceInfo &operator=(QCanBusDeviceInfo &&other)
QCanBusDeviceInfo &operator=(const QCanBusDeviceInfo &other)

详细说明

每个插件可能支持一个或多个具有不同功能的接口。该类提供有关可用函数的信息。

成员函数文档

QCanBusDeviceInfo::QCanBusDeviceInfo(const QCanBusDeviceInfo &other)

构造other 的副本。

[noexcept] QCanBusDeviceInfo::~QCanBusDeviceInfo()

销毁 CAN 总线设备信息。

[since 6.0] QString QCanBusDeviceInfo::alias() const

返回与该 CAN 总线接口相关的用户自定义别名。

某些 CAN 总线接口可以使用用户定义的相关别名。这主要是通过 CAN 硬件供应商的工具实现的。别名可以在以后识别该硬件,尤其是在连接多个接口时。

注意: serialNumber() 不同,别名不保证唯一。

如果 CAN 插件不支持该函数,则返回空字符串。

此函数在 Qt 6.0 中引入。

另请参阅 serialNumber()。

int QCanBusDeviceInfo::channel() const

返回 CAN 总线接口的顺序通道号,从 0 开始。例如,一个双通道 CAN 接口可能有通道 0 和 1。 如果接口只有一个通道或没有通道信息,则返回 0。

QString QCanBusDeviceInfo::description() const

返回 CAN 总线接口的文字说明(如果有)。输出示例:"PCAN USB Pro FD"。如果没有说明,则返回空字符串。

bool QCanBusDeviceInfo::hasFlexibleDataRate() const

如果 CAN 总线接口支持 CAN FD(灵活数据速率),则返回 true。

如果没有此信息,则返回假值。

bool QCanBusDeviceInfo::isVirtual() const

如果 CAN 总线接口是虚拟接口(即未连接到真正的 CAN 硬件),则返回 true。

如果没有此信息,则返回 false。

QString QCanBusDeviceInfo::name() const

返回 CAN 总线接口的接口名称,如 "can0"。

这与QCanBus::createDevice() 的interfaceName 参数相对应。

[since 6.2] QString QCanBusDeviceInfo::plugin() const

返回 CAN 总线接口的插件名称,如 "peakcan"。

这与QCanBus::createDevice() 的plugin 参数相对应。

此函数在 Qt 6.2 中引入。

QString QCanBusDeviceInfo::serialNumber() const

以字符串形式返回 CAN 总线接口的序列号(如果有)。否则返回空字符串。

另请参见 alias()。

[noexcept] void QCanBusDeviceInfo::swap(QCanBusDeviceInfo &other)

将 CAN 总线设备信息与other 互换。该操作速度非常快,从未出现过故障。

[noexcept] QCanBusDeviceInfo &QCanBusDeviceInfo::operator=(QCanBusDeviceInfo &&other)

Move-assignsother 到此QCanBusDeviceInfo 实例。

QCanBusDeviceInfo &QCanBusDeviceInfo::operator=(const QCanBusDeviceInfo &other)

为 CAN 总线设备信息分配other ,并返回 CAN 总线设备信息的引用。

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