Libsockcanpp
A complete C++ wrapper around socketcan.
Public Member Functions | Private Attributes
sockcanpp::CanMessage Class Reference

Represents a CAN message that was received. More...

#include <CanMessage.hpp>

Collaboration diagram for sockcanpp::CanMessage:
Collaboration graph
[legend]

Public Member Functions

 CanMessage (const struct can_frame frame)
 
 CanMessage (const CanId canId, const string frameData)
 
virtual ~CanMessage ()
 
const CanId getCanId () const
 
const string getFrameData () const
 
const can_frame getRawFrame () const
 

Private Attributes

CanId _canIdentifier
 
string _frameData
 
struct can_frame _rawFrame
 

Detailed Description

Represents a CAN message that was received.

Definition at line 55 of file CanMessage.hpp.

Constructor & Destructor Documentation

◆ CanMessage() [1/2]

sockcanpp::CanMessage::CanMessage ( const struct can_frame  frame)
inline

Definition at line 57 of file CanMessage.hpp.

57 :
58 _canIdentifier(frame.can_id), _frameData((const char*)frame.data, frame.can_dlc), _rawFrame(frame) { }
struct can_frame _rawFrame
Definition: CanMessage.hpp:85

References _canIdentifier, _frameData, _rawFrame, and sockcanpp::CanId::CanId().

Referenced by sockcanpp::CanDriver::readMessageLock().

◆ CanMessage() [2/2]

sockcanpp::CanMessage::CanMessage ( const CanId  canId,
const string  frameData 
)
inline

Definition at line 60 of file CanMessage.hpp.

60 : _canIdentifier(canId), _frameData(frameData) {
61 if (frameData.size() > 8) {
62 throw system_error(error_code(0xbadd1c, generic_category()), "Payload too big!");
63 }
64
65 struct can_frame rawFrame;
66 rawFrame.can_id = canId;
67 memcpy(rawFrame.data, frameData.data(), frameData.size());
68 rawFrame.can_dlc = frameData.size();
69
70 _rawFrame = rawFrame;
71 }

References _canIdentifier, _frameData, _rawFrame, and sockcanpp::CanId::CanId().

◆ ~CanMessage()

virtual sockcanpp::CanMessage::~CanMessage ( )
inlinevirtual

Definition at line 73 of file CanMessage.hpp.

73{}

Member Function Documentation

◆ getCanId()

const CanId sockcanpp::CanMessage::getCanId ( ) const
inline

Definition at line 76 of file CanMessage.hpp.

76{ return this->_canIdentifier; }

References _canIdentifier.

Referenced by sockcanpp::CanDriver::sendMessage().

◆ getFrameData()

const string sockcanpp::CanMessage::getFrameData ( ) const
inline

Definition at line 77 of file CanMessage.hpp.

77{ return this->_frameData; }

References _frameData.

Referenced by sockcanpp::CanDriver::sendMessage().

◆ getRawFrame()

const can_frame sockcanpp::CanMessage::getRawFrame ( ) const
inline

Definition at line 78 of file CanMessage.hpp.

78{ return this->_rawFrame; }

References _rawFrame.

Referenced by sockcanpp::CanDriver::sendMessage().

Field Documentation

◆ _canIdentifier

CanId sockcanpp::CanMessage::_canIdentifier
private

Definition at line 81 of file CanMessage.hpp.

Referenced by CanMessage(), and getCanId().

◆ _frameData

string sockcanpp::CanMessage::_frameData
private

Definition at line 83 of file CanMessage.hpp.

Referenced by CanMessage(), and getFrameData().

◆ _rawFrame

struct can_frame sockcanpp::CanMessage::_rawFrame
private

Definition at line 85 of file CanMessage.hpp.

Referenced by CanMessage(), and getRawFrame().


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