MDF Lib 2.2
Interface against MDF 3/4 files
Loading...
Searching...
No Matches
mdf::CanMessage Class Reference

Helper class when logging CAN and CAN FD messages. More...

#include <canmessage.h>

Public Member Functions

void MessageId (uint32_t msg_id)
 CAN message ID. Note that bit 31 indicate extended ID.
 
uint32_t MessageId () const
 CAN message ID. Note that bit 31 indicate extended ID.
 
uint32_t CanId () const
 29/11 bit CAN message ID. Note that bit 31 is not used.
 
void ExtendedId (bool extended)
 Sets the extended CAN ID bit.
 
bool ExtendedId () const
 Returns the extended CAN ID.
 
void Dlc (uint8_t dlc)
 Sets the CAM message data length code.
 
uint8_t Dlc () const
 Returns the CAN message length code.
 
void DataLength (size_t data_length)
 Sets number of data bytes.
 
size_t DataLength () const
 Returns number of data bytes.
 
void DataBytes (const std::vector< uint8_t > &data)
 Sets the payload data bytes.
 
const std::vector< uint8_t > & DataBytes () const
 Returns a reference to the payload data bytes.
 
void DataIndex (uint64_t index)
 Internal function for storing VLSD data offset.
 
uint64_t DataIndex () const
 Internal function for the VLSD data offset.
 
void Dir (bool transmit)
 If set true, the message was transmitted.
 
bool Dir () const
 Returns true if the message was transmitted.
 
void Srr (bool srr)
 Sets the SRR bit. *‍/.
 
bool Srr () const
 Returns the SRR bit.
 
void Edl (bool edl)
 Extended (CAN FD) data length.
 
bool Edl () const
 Extended (CAN FD) data length.
 
void Brs (bool brs)
 Bit rate switch (CAN FD).
 
bool Brs () const
 Bit rate switch (CAN FD).
 
void Esi (bool esi)
 Error state indicator (CAN FD).
 
bool Esi () const
 Error state indicator (CAN FD).
 
void Rtr (bool rtr)
 Sets the RTR bit (remote frame).
 
bool Rtr () const
 Returns the RTR bit.
 
void WakeUp (bool wake_up)
 Indicate a CAN bus wake up status.
 
bool WakeUp () const
 Indicate a CAN bus wake up message.
 
void SingleWire (bool single_wire)
 Indicate a single wire CAN bus.
 
bool SingleWire () const
 Indicate a single wire CAN bus.
 
void BusChannel (uint8_t channel)
 Bus channel.
 
uint8_t BusChannel () const
 Bus channel.
 
void BitPosition (uint8_t position)
 Error bit position (error frame).
 
uint8_t BitPosition () const
 Error bit position.
 
void ErrorType (CanErrorType error_type)
 Type of error.
 
CanErrorType ErrorType () const
 Type of error.
 
void Reset ()
 Reset all flags an payload data buffers.
 
void ToRaw (MessageType msg_type, SampleRecord &sample, size_t max_data_length, bool save_index) const
 Creates an MDF sample record. Used primarily internally.
 

Static Public Member Functions

static size_t DlcToLength (uint8_t dlc)
 Return the data length by DLC.
 

Detailed Description

This class is used when doing bus logging of A CAN or CAN FD bus. The MDF format for CAN logging is a type of standard. Channel naming is common which simplifies the reading of the file.

It is complex task to fix the bit stuffing that minimize number of bytes stored but this class handle most of that complex handling.

Member Function Documentation

◆ DataBytes()

void mdf::CanMessage::DataBytes ( const std::vector< uint8_t > & data)

This function sets the payload data bytes in the message. Note that this function also set the data length and DLC code.

Parameters
data

◆ DataLength()

void mdf::CanMessage::DataLength ( size_t data_length)

The data length is not sent on the bus. Instead is it calculated from the DLC code. Note that the DataBytes() function fix both data length and the DLC code so this function is normally not used.

Parameters
data_lengthNumber of payload data bytes.

◆ Dlc()

void mdf::CanMessage::Dlc ( uint8_t dlc)

Sets the data length code (DLC). The DLC is the same as data length for CAN but not for CAN FD. Note that the DataBytes() function fix both data length and the DLC code so this function is normally not used.

Parameters
dlcData length code. Sets the

The documentation for this class was generated from the following file: