Skip to content

CanBusFactory

#include <mrx/can/CanBusFactory.hpp>
class mrx::can::CanBusFactory

Enumerates SocketCAN interfaces and creates caller-owned bus proxies.

The factory validates interface names using Qt SerialBus and never connects a device as part of creation. The returned proxy is owned by its QObject parent, if provided, or by the caller otherwise.

ReturnNameDescription
QStringListavailableInterfaces staticReturns the SocketCAN interface names currently available to Qt.
CanBusProxy*create staticCreates a disconnected proxy for an available SocketCAN interface.

static
static QStringList availableInterfaces(QString* errorMessage = nullptr)

Returns the SocketCAN interface names currently available to Qt.

Available interface names in Qt SerialBus enumeration order.

NameTypeDescription
errorMessageQString*Receives a backend error when enumeration fails.

static
static CanBusProxy* create(const QString& interfaceName, QObject* parent = nullptr, QString* errorMessage = nullptr)

Creates a disconnected proxy for an available SocketCAN interface.

A disconnected proxy, or nullptr if validation or device creation fails.

NameTypeDescription
interfaceNameconst QString&Exact interface name returned by availableInterfaces().
parentQObject*Optional QObject owner for the returned proxy.
errorMessageQString*Receives an explanatory error if creation fails.