Woman, Life, Freedom


OBD-II Emulator
Linux ODB-II Emulator public and protected interfaces documentation
ObdEmulator::CanFrame Class Reference

CAN transmission packet frame. More...

#include <can_frame.h>

Public Member Functions

 CanFrame (uint32_t id, bool extended, bool remote, const std::vector< uint8_t > &data)
 Constructor. More...
 
uint32_t GetId () const noexcept
 Get frame CAN ID. More...
 
bool IsExtended () const noexcept
 Indicate whether the frame is extended or standard. More...
 
bool IsRemote () const noexcept
 Indicate whether the frame is remote transmission request (RTR) or data. More...
 
size_t GetDataLength () const noexcept
 Get frame data length (DLC) More...
 
const std::array< uint8_t, cDataLengthMax > & GetData () const noexcept
 Get frame data. More...
 

Static Public Attributes

static const size_t cDataLengthMax {8}
 Maximum CAN frame data length.
 

Detailed Description

CAN transmission packet frame.

Constructor & Destructor Documentation

◆ CanFrame()

ObdEmulator::CanFrame::CanFrame ( uint32_t  id,
bool  extended,
bool  remote,
const std::vector< uint8_t > &  data 
)

Constructor.

Parameters
idCAN frame ID
extendedIndicates whether the frame is extended or standard
remoteIndicates whether the frame is remote transmission request (RTR) or data
dataCAN packet containing data
Exceptions
std::out_of_rangeThrows if the ID is out of range

Member Function Documentation

◆ GetData()

const std::array< uint8_t, cDataLengthMax > & ObdEmulator::CanFrame::GetData ( ) const
noexcept

Get frame data.

Returns
Const reference to the data byte array

◆ GetDataLength()

size_t ObdEmulator::CanFrame::GetDataLength ( ) const
noexcept

Get frame data length (DLC)

Returns
A number between 0 to 8

◆ GetId()

uint32_t ObdEmulator::CanFrame::GetId ( ) const
noexcept

Get frame CAN ID.

Returns
11-bit ID if the frame is standard and 20-bit ID if it is extended
See also
IsExtended

◆ IsExtended()

bool ObdEmulator::CanFrame::IsExtended ( ) const
noexcept

Indicate whether the frame is extended or standard.

Returns
True if the frame is extended, otherwise false

◆ IsRemote()

bool ObdEmulator::CanFrame::IsRemote ( ) const
noexcept

Indicate whether the frame is remote transmission request (RTR) or data.

Returns
True if the frame is RTR, otherwise false