Skip to content

CanUtils

Source locationmrx/can/CanUtils.hpp
#include <mrx/can/CanUtils.hpp>
class mrx::can::CanUtils

Helpers for constructing extended CAN data frames.

ReturnNameDescription
quint32extendedFrameId staticReturns the lower 29 identifier bits, removing all higher bits.
QByteArrayzeroPayload staticReturns a payload of the requested length filled with zero bytes; negative lengths produce an empty payload.
QCanBusFramecreateExtendedFrame staticConstructs an extended data frame with the lower 29 ID bits and the given payload.
QCanBusFramecreateExtendedFrameFromStruct static inlineCopies the complete object representation into an extended data frame.

static
Source locationmrx/can/CanUtils.hpp
static quint32 extendedFrameId(quint32 frameId)

Returns the lower 29 identifier bits, removing all higher bits.


static
Source locationmrx/can/CanUtils.hpp
static QByteArray zeroPayload(int length)

Returns a payload of the requested length filled with zero bytes; negative lengths produce an empty payload.


static
Source locationmrx/can/CanUtils.hpp
static QCanBusFrame createExtendedFrame(quint32 id, const QByteArray& payload)

Constructs an extended data frame with the lower 29 ID bits and the given payload.

The payload is preserved without padding or truncation. Qt determines CAN FD format from the payload length; callers can inspect QCanBusFrame::isValid().


static inline
Source locationmrx/can/CanUtils.hpp
template<typename T> static inline QCanBusFrame createExtendedFrameFromStruct(quint32 id, const T& payload)

Copies the complete object representation into an extended data frame.

T must be trivially copyable. This is a byte copy, not serialization: the caller is responsible for padding, initialization, byte order and protocol compatibility. The payload length is exactly sizeof(T).