CARMA C++
carma::canbus::Message Class Reference

Class to encapsulate a CAN message. More...

#include <carma/canbus/Message.h>

Public Member Functions

::std::string dump (bool abbreviate, bool ascii) const
 Dump everything we know about this message in CARMAesque. More...
 
carma::canbus::busIdType getBusId () const
 Get CAN bus Id. More...
 
DataVector getData () const
 Get the data as a vector of up to 8 bytes. More...
 
carma::canbus::idType getId () const
 Get CAN message id. More...
 
double getRxMjd () const
 Return the Rx MJD time. More...
 
bool isSimulated () const
 Return simulated flag. More...
 
 Message ()
 Default constructor. More...
 
 Message (carma::canbus::idType id, carma::canbus::busIdType busId)
 Create an extended message with specified id and busId. More...
 
 Message (carma::canbus::idType id, const DataVector &data, carma::canbus::busIdType busId)
 Create an extended message with the specified ids and data. More...
 
 Message (const Message &other)
 Copy constructor. More...
 
bool operator!= (const Message &other)
 Returns false if the id's, busId's or data differs (including length). More...
 
carma::canbus::Messageoperator<< (unsigned char rvalue)
 Add an unsigned char to CAN message data. More...
 
carma::canbus::Messageoperator<< (unsigned short rvalue)
 Add an unsigned short to CAN message data. More...
 
carma::canbus::Messageoperator<< (short rvalue)
 Add a signed short to CAN message data. More...
 
carma::canbus::Messageoperator<< (unsigned long int rvalue)
 Add an unsigned long integer to CAN message data. More...
 
carma::canbus::Messageoperator<< (long int rvalue)
 Add a long integer to CAN message data. More...
 
carma::canbus::Messageoperator<< (float rvalue)
 Add an IEEE 754-1990 float to CAN message data. More...
 
carma::canbus::Messageoperator<< (double rvalue)
 Add an IEEE 754-1990 double float to CAN message data. More...
 
Messageoperator= (const Message &other)
 Assignment operator. More...
 
bool operator== (const Message &other)
 Returns true if the id's, data and busId's are identical (including data length). More...
 
void setBusId (carma::canbus::busIdType busId)
 Set bus Id. More...
 
void setData (const carma::canbus::DataVector &data)
 Set the data. More...
 
void setId (carma::canbus::idType id)
 Set CAN message id. More...
 
void setRxMjd (double mjd)
 Set the rxMjd time. More...
 
void setSimFlag (bool sim)
 Set the simulated flag. More...
 

Detailed Description

Class to encapsulate a CAN message.

Definition at line 21 of file Message.h.

Constructor & Destructor Documentation

carma::canbus::Message::Message ( )

Default constructor.

Creates a Message with an id of 0, busId 0, and no data.

carma::canbus::Message::Message ( carma::canbus::idType  id,
carma::canbus::busIdType  busId 
)

Create an extended message with specified id and busId.

Exceptions
CAN::Errorif the id is illegal (more than 29 bits).
carma::canbus::Message::Message ( carma::canbus::idType  id,
const DataVector data,
carma::canbus::busIdType  busId 
)

Create an extended message with the specified ids and data.

Exceptions
CAN::Errorif the id is illegal or the data contains more than 8 bytes.
carma::canbus::Message::Message ( const Message other)

Copy constructor.

Member Function Documentation

::std::string carma::canbus::Message::dump ( bool  abbreviate,
bool  ascii 
) const

Dump everything we know about this message in CARMAesque.

Prints the bus, api and node (or board type and serial number), message id, whether it was intended for the host or nodes and the raw data in hex.

Parameters
abbreviateOnly output data if true.
asciiOutput data as ascii text if true.
Returns
string containing dumped data.
carma::canbus::busIdType carma::canbus::Message::getBusId ( ) const

Get CAN bus Id.

DataVector carma::canbus::Message::getData ( ) const

Get the data as a vector of up to 8 bytes.

carma::canbus::idType carma::canbus::Message::getId ( ) const

Get CAN message id.

Returns
CAN message id.
double carma::canbus::Message::getRxMjd ( ) const

Return the Rx MJD time.

bool carma::canbus::Message::isSimulated ( ) const

Return simulated flag.

This method should be used to determine if the Message was artificially constructed for simulation purposes (i.e. not retrieved from or posted to a CAN bus).

Returns
True if message is simulated, false otherwise.
bool carma::canbus::Message::operator!= ( const Message other)

Returns false if the id's, busId's or data differs (including length).

carma::canbus::Message& carma::canbus::Message::operator<< ( unsigned char  rvalue)

Add an unsigned char to CAN message data.

Exceptions
carma::canbus::BadDataSizeExceptionif resulting data size is > 8 bytes.
carma::canbus::Message& carma::canbus::Message::operator<< ( unsigned short  rvalue)

Add an unsigned short to CAN message data.

Exceptions
carma::canbus::BadDataSizeExceptionif resulting data size is > 8 bytes.
carma::canbus::Message& carma::canbus::Message::operator<< ( short  rvalue)

Add a signed short to CAN message data.

Exceptions
carma::canbus::BadDataSizeExceptionif resulting data size is > 8 bytes.
carma::canbus::Message& carma::canbus::Message::operator<< ( unsigned long int  rvalue)

Add an unsigned long integer to CAN message data.

Exceptions
carma::canbus::BadDataSizeExceptionif resulting data size is > 8 bytes.
carma::canbus::Message& carma::canbus::Message::operator<< ( long int  rvalue)

Add a long integer to CAN message data.

Exceptions
carma::canbus::BadDataSizeExceptionif resulting data size is > 8 bytes.
carma::canbus::Message& carma::canbus::Message::operator<< ( float  rvalue)

Add an IEEE 754-1990 float to CAN message data.

Exceptions
carma::canbus::BadDataSizeExceptionif resulting data size is > 8 bytes.
carma::canbus::Message& carma::canbus::Message::operator<< ( double  rvalue)

Add an IEEE 754-1990 double float to CAN message data.

Exceptions
carma::canbus::BadDataSizeExceptionif resulting data size is > 8 bytes.
Message& carma::canbus::Message::operator= ( const Message other)

Assignment operator.

bool carma::canbus::Message::operator== ( const Message other)

Returns true if the id's, data and busId's are identical (including data length).

void carma::canbus::Message::setBusId ( carma::canbus::busIdType  busId)

Set bus Id.

void carma::canbus::Message::setData ( const carma::canbus::DataVector data)

Set the data.

Exceptions
carma::canbus::BadDataSizeExceptionif the data contains more than 8 bytes.
void carma::canbus::Message::setId ( carma::canbus::idType  id)

Set CAN message id.

Exceptions
carma::canbus::BadParameterExceptionif id is illegal (more than 29 bits).
void carma::canbus::Message::setRxMjd ( double  mjd)

Set the rxMjd time.

void carma::canbus::Message::setSimFlag ( bool  sim)

Set the simulated flag.

This flag should be set if the message is being artificially created for simulation purposes (i.e. it isn't actually retrieved from or sent to the CAN bus). For the most part, it is set internally by the canbus::Master class.

Parameters
simTrue if message is simulated, false if not.

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