QCanBus Class

The QCanBus class handles registration and creation of bus plugins. 更多...

头文件: #include <QCanBus>
qmake: QT += serialbus
开始支持版本: Qt 5.8
基类: QObject

公有函数

QList<QCanBusDeviceInfo> availableDevices(const QString &plugin, QString *errorMessage = nullptr) const
QCanBusDevice *createDevice(const QString &plugin, const QString &interfaceName, QString *errorMessage = nullptr) const
QStringList plugins() const
  • 32 个公有函数继承自 QObject

静态公有成员

QCanBus *instance()
  • 10 个静态公有成员继承自 QObject

其他继承的成员

  • 1 个属性继承自 QObject
  • 1 个公有槽函数继承自 QObject
  • 2 个信号继承自 QObject
  • 1 个公有变量继承自 QObject
  • 9 个受保护的函数继承自 QObject
  • 2 个受保护的变量继承自 QObject

详细描述

The QCanBus class handles registration and creation of bus plugins.

QCanBus loads Qt CAN Bus plugins at runtime. The ownership of serial bus plugins is transferred to the loader.

成员函数

QList<QCanBusDeviceInfo> QCanBus::availableDevices(const QString &plugin, QString *errorMessage = nullptr) const

Returns the available interfaces for plugin. In case of failure, the optional parameter errorMessage returns a textual error description.

Note: Some plugins might not or only partially support this function.

This function was introduced in Qt 5.9.

参见 createDevice().

QCanBusDevice *QCanBus::createDevice(const QString &plugin, const QString &interfaceName, QString *errorMessage = nullptr) const

Creates a CAN bus device. plugin is the name of the plugin as returned by the plugins() method. interfaceName is the CAN bus interface name. In case of failure, the optional parameter errorMessage returns a textual error description.

Ownership of the returned plugin is transferred to the caller. Returns nullptr if no suitable device can be found.

For example, the following call would connect to the SocketCAN interface vcan0:


  QCanBusDevice *device = QCanBus::instance()->createDevice(
      QStringLiteral("socketcan"), QStringLiteral("vcan0"));
  device->connectDevice();

Note: The interfaceName is plugin-dependent. See the corresponding plugin documentation for more information: CAN Bus Plugins. To get a list of available interfaces, availableDevices() can be used.

参见 availableDevices().

[static] QCanBus *QCanBus::instance()

Returns a pointer to the QCanBus class. The object is loaded if necessary. QCanBus uses the singleton design pattern.

QStringList QCanBus::plugins() const

Returns a list of identifiers for all loaded plugins.