PySide6.QtSerialBus.QCanBus¶
- class QCanBus¶
- The - QCanBusclass handles registration and creation of bus plugins.- Details- QCanBusloads Qt CAN Bus plugins at runtime. The ownership of serial bus plugins is transferred to the loader.- Synopsis¶- Methods¶
- def - createDevice()
- def - plugins()
 - Static functions¶- def - instance()
 - Note - This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE - availableDevices()¶
- Return type:
- tuple 
 
 - Returns the available devices for all plugins, i.e. all available CAN interfaces. - In case of failure, the optional parameter - errorMessagereturns a textual error description.- The function returns a tuple of (device_list, error_string). - availableDevices(plugin)
- Parameters:
- plugin – str 
- Return type:
- tuple 
 
 - Returns the available interfaces for - plugin. In case of failure, the optional parameter- errorMessagereturns a textual error description.- Note - Some plugins might not or only partially support this function. - For example, the following call returns a list of all available SocketCAN interfaces (which can be used for - createDevice()):- QString errorString; const QList<QCanBusDeviceInfo> devices = QCanBus::instance()->availableDevices( QStringLiteral("socketcan"), &errorString); if (!errorString.isEmpty()) qDebug() << errorString;- See also - Python Language Note - The function returns a tuple of (device_list, error_string). - createDevice(plugin, interfaceName)¶
- Parameters:
- plugin – str 
- interfaceName – str 
 
- Return type:
- tuple 
 
 - Creates a CAN bus device. - pluginis the name of the plugin as returned by the- plugins()method.- interfaceNameis the CAN bus interface name. In case of failure, the optional parameter- errorMessagereturns a textual error description.- Ownership of the returned plugin is transferred to the caller. Returns - nullptrif no suitable device can be found.- For example, the following call would connect to the SocketCAN interface vcan0: - QString errorString; QCanBusDevice *device = QCanBus::instance()->createDevice( QStringLiteral("socketcan"), QStringLiteral("vcan0"), &errorString); if (!device) qDebug() << errorString; else device->connectDevice();- Note - The - interfaceNameis plugin-dependent. See the corresponding plugin documentation for more information: CAN Bus Plugins . To get a list of available interfaces,- availableDevices()can be used.- See also - Python Language Note - The function returns a tuple of (device, error_string). - Returns a pointer to the - QCanBusclass. The object is loaded if necessary.- QCanBususes the singleton design pattern.- plugins()¶
- Return type:
- list of strings 
 
 - Returns a list of identifiers for all loaded plugins.