Class CanId

Class Documentation

class CanId

A wrapper around can_id_t to make it a little more C++-y WARNING: I’m assuming the 0th bit is the MSB aka the leftmost bit

Public Types

using IdT = uint32_t
using LengthT = uint32_t

Public Functions

CanId() = default
explicit CanId(const IdT raw_id, const uint64_t bus_time, const LengthT data_length = 0U)

Directly set id, blindly taking whatever bytes are given.

CanId(const IdT id, const uint64_t bus_time, FrameType type, StandardFrame_)

Sets ID

Throws:

std::domain_error – if id would get truncated

CanId(const IdT id, const uint64_t bus_time, FrameType type, ExtendedFrame_)

Sets ID

Throws:

std::domain_error – if id would get truncated

CanId &standard() noexcept

Sets bit 31 to 0.

CanId &extended() noexcept

Sets bit 31 to 1.

CanId &error_frame() noexcept

Sets bit 29 to 1, and bit 30 to 0.

CanId &remote_frame() noexcept

Sets bit 29 to 0, and bit 30 to 1.

CanId &data_frame() noexcept

Clears bits 29 and 30 (sets to 0)

CanId &frame_type(const FrameType type)

Sets the type accordingly.

CanId &identifier(const IdT id)

Sets leading bits

Throws:

std::domain_error – If id would get truncated, 11 bits for Standard, 29 bits for Extended

IdT identifier() const noexcept

Get just the can_id bits.

IdT get() const noexcept

Get the whole id value.

bool is_extended() const noexcept

Check if frame is extended.

FrameType frame_type() const

Check frame type

Throws:

std::domain_error – If bits are in an inconsistent state

LengthT length() const noexcept

Get the length of the data; only nonzero on received data.

inline uint64_t get_bus_time()