Struct Message

Struct Documentation

struct Message

CAN message with message counter, CRC byte and signals.

Public Functions

template<typename FrameData>
void encode(FrameData &frame)

Encode signals into frame bits.

Parameters:

frame – Frame byte array

template<typename FrameData>
void validate(FrameData &frame)

Validate frame by setting CRC and increasing message counter.

Parameters:

frame – Frame byte array

template<typename FrameData>
bool decode(const FrameData &frame)

Decode frame bits into signals.

Parameters:

frame – Frame byte array

Returns:

False if decoding is invalid (CRC, message counter, length), true otherwise

template<typename FrameData>
bool valid(const FrameData &frame)

Check frame by comparing length, CRC and message counter difference.

Parameters:

frame – Frame byte array

Returns:

False if array length not equal to message length, wrong CRC or message counter, true otherwise

template<typename FrameData>
uint8_t calculate_crc(const FrameData &frame)

Compute CRC.

Parameters:

frame – Frame byte array

Returns:

CRC value

template<>
uint8_t calculate_crc(const ros2_socketcan_msgs::msg::FdFrame::_data_type &frame)

Public Members

std::string name
uint8_t length = {8}
std::optional<uint8_t> crc_index = {7}
std::optional<MessageCounter> message_counter = {std::nullopt}
std::unordered_map<std::string, Signal> signals