A CAN message containing message sender and message data. More...
#include <CANMessage.hpp>
Public Types | |
typedef unsigned int | ID |
The type for CAN message ids. | |
typedef unsigned int | Flags |
The type for the message flags. | |
typedef unsigned char | Data |
The type for the message Data. | |
typedef double | Seconds |
The type for the message timestamp. | |
Public Member Functions | |
CANMessage () | |
Create an empty CANMessage. | |
CANMessage (CANDeviceInterface *_origin) | |
Create an empty CANMessage with a CANOpen device as origin. | |
CANMessage (CANDeviceInterface *_origin, ID _msgid, Data *_data, unsigned int _length) | |
Create a Standard CANMessage with default flags. | |
void | clear () |
Clear the ID and flags of this CANMessage, except the origin. | |
bool | isRemote () const |
Check the remote flag. | |
void | setRemote () |
Set the remote flag. | |
Data | getData (unsigned int pos) const |
Return data element at position pos, starting from 0. | |
void | setData (unsigned int pos, Data d) |
Set the data element at position pos with value d, starting from 0. | |
void | setDataDLC (Data *_data, unsigned int _length) |
Set the Data and Data Length Code of this CANMessage. | |
unsigned int | getDLC () const |
Get the Data Length Code of this CANMessage. | |
void | setDLC (unsigned int length) |
Set the Data Length Code of this CANMessage. | |
bool | isExtended () const |
bool | isStandard () const |
unsigned int | getStdId () const |
unsigned int | getExtId () const |
void | setStdId (unsigned int id) |
void | setExtId (unsigned int id) |
bool | operator== (CANMessage &other) const |
Compare this CANMessage with another CANMessage. | |
CANMessage & | operator= (const CpStruct_CAN &msg) |
Assign a CANMessage msg to this CANMessage. | |
Static Public Member Functions | |
static CANMessage * | createExtended (CANDeviceInterface *_origin, ID _msgid, Data *_data, unsigned int _length) |
Create an Extended CAN Message with default flags. | |
static CANMessage * | createStandard (CANDeviceInterface *_origin, ID _msgid, Data *_data, unsigned int _length) |
Create a Standard CAN Message with default flags. | |
static CANMessage * | createStdRemote (CANDeviceInterface *_origin, ID _msgid, Data *_data, unsigned int _length) |
Create a Standard CAN Message with the Remote flag set. | |
static CANMessage * | createExtRemote (CANDeviceInterface *_origin, ID _msgid, Data *_data, unsigned int _length) |
Create an Extended CAN Message with the Remote flag set. | |
Public Attributes | |
CANDeviceInterface * | origin |
The sender of this message. | |
Seconds | timestamp |
Timestamp of the moment message is received. | |
_U32 | v_MsgId |
_U32 | v_MsgFlags |
_U08 | v_MsgData [8] |
A CAN message containing message sender and message data.
Definition at line 70 of file CANMessage.hpp.
typedef unsigned int ID |
The type for CAN message ids.
It can be standard or extended
Definition at line 75 of file CANMessage.hpp.
CANMessage | ( | ) | [inline] |
Create an empty CANMessage.
The origin is set to the CANDummyDevice.
Definition at line 94 of file CANMessage.hpp.
References CANMessage::clear().
Referenced by CANMessage::createExtended(), CANMessage::createExtRemote(), CANMessage::createStandard(), and CANMessage::createStdRemote().
CANMessage | ( | CANDeviceInterface * | _origin, | |
ID | _msgid, | |||
Data * | _data, | |||
unsigned int | _length | |||
) | [inline] |
Create a Standard CANMessage with default flags.
_origin | The CANOpen device which created this CANMessage. | |
_msgid | The Standard CAN ID of the message. | |
_data | A pointer to the data to be used (will be copied). | |
_length | The length of the data, the number of items in the data array (max 8) |
Definition at line 118 of file CANMessage.hpp.
References CANMessage::clear(), CANMessage::setData(), and CANMessage::setDLC().
static CANMessage* createExtended | ( | CANDeviceInterface * | _origin, | |
ID | _msgid, | |||
Data * | _data, | |||
unsigned int | _length | |||
) | [inline, static] |
Create an Extended CAN Message with default flags.
_origin | The CANOpen device which created this CANMessage. | |
_msgid | The Extended CAN ID of the message. | |
_data | A pointer to the data to be used (will be copied). | |
_length | The length of the data, the number of items in the data array (max 8) |
Definition at line 136 of file CANMessage.hpp.
References CANMessage::CANMessage().
static CANMessage* createExtRemote | ( | CANDeviceInterface * | _origin, | |
ID | _msgid, | |||
Data * | _data, | |||
unsigned int | _length | |||
) | [inline, static] |
Create an Extended CAN Message with the Remote flag set.
_origin | The CANOpen device which created this CANMessage. | |
_msgid | The Extended CAN ID of the message. | |
_data | A pointer to the data to be used (will be copied). | |
_length | The length of the data, the number of items in the data array (max 8) |
Definition at line 181 of file CANMessage.hpp.
References CANMessage::CANMessage(), and CANMessage::setRemote().
static CANMessage* createStandard | ( | CANDeviceInterface * | _origin, | |
ID | _msgid, | |||
Data * | _data, | |||
unsigned int | _length | |||
) | [inline, static] |
Create a Standard CAN Message with default flags.
_origin | The CANOpen device which created this CANMessage. | |
_msgid | The Standard CAN ID of the message. | |
_data | A pointer to the data to be used (will be copied). | |
_length | The length of the data, the number of items in the data array (max 8) |
Definition at line 152 of file CANMessage.hpp.
References CANMessage::CANMessage().
static CANMessage* createStdRemote | ( | CANDeviceInterface * | _origin, | |
ID | _msgid, | |||
Data * | _data, | |||
unsigned int | _length | |||
) | [inline, static] |
Create a Standard CAN Message with the Remote flag set.
_origin | The CANOpen device which created this CANMessage. | |
_msgid | The Standard CAN ID of the message. | |
_data | A pointer to the data to be used (will be copied). | |
_length | The length of the data, the number of items in the data array (max 8) |
Definition at line 165 of file CANMessage.hpp.
References CANMessage::CANMessage(), and CANMessage::setRemote().
CANMessage& operator= | ( | const CpStruct_CAN & | msg | ) | [inline] |
Assign a CANMessage msg to this CANMessage.
The complete message is copied.
Definition at line 317 of file CANMessage.hpp.
References CpStruct_CAN::v_MsgData, CpStruct_CAN::v_MsgFlags, and CpStruct_CAN::v_MsgId.
bool operator== | ( | CANMessage & | other | ) | const [inline] |
Compare this CANMessage with another CANMessage.
The complete message is compared, except the origin.
Definition at line 291 of file CANMessage.hpp.
References CANMessage::getData(), and CANMessage::getDLC().
_U08 v_MsgData[8] [inherited] |
The data fields contain up to eight bytes for a CAN message. If the data length code is less than 8, the value of the unused data bytes will be undefined.
Definition at line 84 of file cpstruct.h.
Referenced by CANMessage::operator=().
_U32 v_MsgFlags [inherited] |
The message flags field contains the data length code (DLC) of the CAN message and the buffer number when using a FullCAN controller.
The data length code (Bit 0 - Bit 3) contains the number of data bytes which are transmitted by a message. The possible value range for the data length code is from 0 to 8 (bytes).
A FullCAN controller (e.g. AN82527) has more than only one transmit and one receive buffer and offers more sophisticated message filtering. The field message buffer (Bit 4 - Bit 7) specifies the buffer for message transmission or reception.
The high word (Bit 16 - Bit 31) is reserved for user defined data.
Definition at line 78 of file cpstruct.h.
Referenced by CANMessage::operator=().
_U32 v_MsgId [inherited] |
The identifier field may have 11 bits for standard frames (CAN specification 2.0A) or 29 bits for extended frames (CAN specification 2.0B). The three most significant bits are reserved for special functionality (the LSB is Bit 0, the MSB is Bit 31 ).
Definition at line 61 of file cpstruct.h.
Referenced by CANMessage::operator=().