#include <Message.h>
Public Member Functions | |
uint16_t | getChecksum () |
uint8_t | getFlags () |
uint8_t | getLength () |
uint8_t | getLengthComp () |
size_t | getPayload (void *buf, size_t max_size) |
size_t | getPayloadLength () |
uint32_t | getTimestamp () |
size_t | getTotalLength () |
uint16_t | getType () |
uint8_t | getVersion () |
bool | isCommand () |
bool | isData () |
bool | isRequest () |
bool | isValid (char *whyNot=NULL, size_t strLen=0) |
Message () | |
Message (void *input, size_t msg_len) | |
Message (const Message &other) | |
Message (uint16_t type, uint8_t *payload, size_t payload_len, uint32_t timestamp=0, uint8_t flags=0, uint8_t version=0) | |
virtual std::ostream & | printMessage (std::ostream &stream=std::cout) |
void | printRaw (std::ostream &stream=std::cout) |
void | send () |
size_t | toBytes (void *buf, size_t buf_size) |
virtual | ~Message () |
Static Public Member Functions | |
static Message * | factory (void *input, size_t msg_len) |
static Message * | popNext () |
static Message * | waitNext (double timeout=0.0) |
Static Public Attributes | |
static const size_t | MAX_MSG_LENGTH = 256 |
static const size_t | MIN_MSG_LENGTH = HEADER_LENGTH + CRC_LENGTH |
static const uint8_t | SOH = 0xAA |
static const uint8_t | STX = 0x55 |
Protected Types | |
enum | dataOffsets { SOH_OFST = 0, LENGTH_OFST, LENGTH_COMP_OFST, VERSION_OFST, TIMESTAMP_OFST, FLAGS_OFST = 8, TYPE_OFST, STX_OFST = 11, PAYLOAD_OFST } |
Protected Member Functions | |
size_t | crcOffset () |
uint8_t * | getPayloadPointer (size_t offset=0) |
void | makeValid () |
void | setFlags (uint8_t flags) |
void | setLength (uint8_t len) |
void | setPayload (void *buf, size_t buf_size) |
void | setPayloadLength (uint8_t len) |
void | setTimestamp (uint32_t timestamp) |
void | setType (uint16_t type) |
void | setVersion (uint8_t version) |
Protected Attributes | |
uint8_t | data [MAX_MSG_LENGTH] |
bool | is_sent |
size_t | total_len |
Static Protected Attributes | |
static const uint16_t | CRC_INIT_VAL = 0xFFFF |
static const size_t | CRC_LENGTH = 2 |
static const size_t | HEADER_LENGTH = 12 |
Friends | |
class | Transport |
enum clearpath::Message::dataOffsets [protected] |
Definition at line 74 of file Message.cpp.
clearpath::Message::Message | ( | void * | input, |
size_t | msg_len | ||
) |
Definition at line 81 of file Message.cpp.
clearpath::Message::Message | ( | const Message & | other | ) |
Definition at line 89 of file Message.cpp.
clearpath::Message::Message | ( | uint16_t | type, |
uint8_t * | payload, | ||
size_t | payload_len, | ||
uint32_t | timestamp = 0 , |
||
uint8_t | flags = 0 , |
||
uint8_t | version = 0 |
||
) |
Definition at line 97 of file Message.cpp.
clearpath::Message::~Message | ( | ) | [virtual] |
Definition at line 127 of file Message.cpp.
size_t clearpath::Message::crcOffset | ( | ) | [inline, protected] |
Message * clearpath::Message::factory | ( | void * | input, |
size_t | msg_len | ||
) | [static] |
Instantiates the Message subclass corresponding to the type field in raw message data.
input | The raw message data to instantiate from |
msg_len | The length of input. |
Definition at line 385 of file Message.cpp.
uint16_t clearpath::Message::getChecksum | ( | ) |
Definition at line 216 of file Message.cpp.
uint8_t clearpath::Message::getFlags | ( | ) |
Reimplemented in clearpath::DataSafetySystemStatus.
Definition at line 206 of file Message.cpp.
uint8_t clearpath::Message::getLength | ( | ) |
Definition at line 186 of file Message.cpp.
uint8_t clearpath::Message::getLengthComp | ( | ) |
Definition at line 191 of file Message.cpp.
size_t clearpath::Message::getPayload | ( | void * | buf, |
size_t | buf_size | ||
) |
Copies message payload into a provided buffer.
buf | The buffer to fill |
buf_size | Maximum length of buf |
Definition at line 167 of file Message.cpp.
size_t clearpath::Message::getPayloadLength | ( | ) | [inline] |
uint8_t * clearpath::Message::getPayloadPointer | ( | size_t | offset = 0 | ) | [protected] |
Get a pointer to the payload withing this Message's internal storage.
offset | The offset from the beginning of the payload. |
Definition at line 181 of file Message.cpp.
uint32_t clearpath::Message::getTimestamp | ( | ) |
Definition at line 201 of file Message.cpp.
size_t clearpath::Message::getTotalLength | ( | ) | [inline] |
uint16_t clearpath::Message::getType | ( | ) |
Definition at line 211 of file Message.cpp.
uint8_t clearpath::Message::getVersion | ( | ) |
Definition at line 196 of file Message.cpp.
bool clearpath::Message::isCommand | ( | ) | [inline] |
bool clearpath::Message::isData | ( | ) | [inline] |
bool clearpath::Message::isRequest | ( | ) | [inline] |
bool clearpath::Message::isValid | ( | char * | whyNot = NULL , |
size_t | strLen = 0 |
||
) |
Checks the consistency of this message.
whyNot | Optionally, a reason for validation failure will be written here. |
strLen | Length of the optional whyNot string |
Definition at line 302 of file Message.cpp.
void clearpath::Message::makeValid | ( | ) | [protected] |
Sets SOH, STX, length, and checksum so that this message becomes valid.
Definition at line 340 of file Message.cpp.
Message * clearpath::Message::popNext | ( | ) | [static] |
Reimplemented in clearpath::DataVelocity, clearpath::DataSystemStatus, clearpath::DataSafetySystemStatus, clearpath::DataRawVoltage, clearpath::DataRawTemperature, clearpath::DataRawOrientation, clearpath::DataRawMagnetometer, clearpath::DataRawGyro, clearpath::DataRawCurrent, clearpath::DataRawAcceleration, clearpath::DataRangefinderTimings, clearpath::DataRangefinders, clearpath::DataProcessorStatus, clearpath::DataPowerSystem, clearpath::DataPlatformRotation, clearpath::DataPlatformOrientation, clearpath::DataPlatformMagnetometer, clearpath::DataPlatformName, clearpath::DataPlatformInfo, clearpath::DataPlatformAcceleration, clearpath::DataMaxSpeed, clearpath::DataMaxAcceleration, clearpath::DataGear, clearpath::DataFirmwareInfo, clearpath::DataEncodersRaw, clearpath::DataEncoders, clearpath::DataEcho, clearpath::DataDifferentialSpeed, clearpath::DataDifferentialOutput, clearpath::DataDifferentialControl, and clearpath::DataAckermannOutput.
Definition at line 486 of file Message.cpp.
std::ostream & clearpath::Message::printMessage | ( | std::ostream & | stream = std::cout | ) | [virtual] |
Reimplemented in clearpath::DataVelocity, clearpath::DataSystemStatus, clearpath::DataSafetySystemStatus, clearpath::DataRawVoltage, clearpath::DataRawTemperature, clearpath::DataRawOrientation, clearpath::DataRawMagnetometer, clearpath::DataRawGyro, clearpath::DataRawCurrent, clearpath::DataRawAcceleration, clearpath::DataRangefinderTimings, clearpath::DataRangefinders, clearpath::DataProcessorStatus, clearpath::DataPowerSystem, clearpath::DataPlatformRotation, clearpath::DataPlatformOrientation, clearpath::DataPlatformMagnetometer, clearpath::DataPlatformName, clearpath::DataPlatformInfo, clearpath::DataPlatformAcceleration, clearpath::DataMaxSpeed, clearpath::DataMaxAcceleration, clearpath::DataGear, clearpath::DataFirmwareInfo, clearpath::DataEncodersRaw, clearpath::DataEncoders, clearpath::DataEcho, clearpath::DataDifferentialSpeed, clearpath::DataDifferentialOutput, clearpath::DataDifferentialControl, and clearpath::DataAckermannOutput.
Definition at line 350 of file Message.cpp.
void clearpath::Message::printRaw | ( | std::ostream & | stream = std::cout | ) |
Definition at line 367 of file Message.cpp.
void clearpath::Message::send | ( | ) |
Definition at line 132 of file Message.cpp.
void clearpath::Message::setFlags | ( | uint8_t | flags | ) | [protected] |
Definition at line 240 of file Message.cpp.
void clearpath::Message::setLength | ( | uint8_t | len | ) | [protected] |
Definition at line 221 of file Message.cpp.
void clearpath::Message::setPayload | ( | void * | buf, |
size_t | buf_size | ||
) | [protected] |
Set the payload of this message. Modifies the length of the message as necessary, as per setPayloadLength.
buf | Buffer containing the new payload. |
buf_size | Length of buf. |
Definition at line 270 of file Message.cpp.
void clearpath::Message::setPayloadLength | ( | uint8_t | len | ) | [protected] |
Changes the payload length of the packet. Does not update packet len/~len fields or the checksum. Call makeValid() to update these fields.
len | The new payload length |
Definition at line 256 of file Message.cpp.
void clearpath::Message::setTimestamp | ( | uint32_t | timestamp | ) | [protected] |
Definition at line 235 of file Message.cpp.
void clearpath::Message::setType | ( | uint16_t | type | ) | [protected] |
Definition at line 245 of file Message.cpp.
void clearpath::Message::setVersion | ( | uint8_t | version | ) | [protected] |
Definition at line 230 of file Message.cpp.
size_t clearpath::Message::toBytes | ( | void * | buf, |
size_t | buf_size | ||
) |
Copy the complete raw content of this message to a buffer.
buf | The buffer to copy to |
buf_size | The maximum length of buf |
Definition at line 284 of file Message.cpp.
Message * clearpath::Message::waitNext | ( | double | timeout = 0.0 | ) | [static] |
Reimplemented in clearpath::DataVelocity, clearpath::DataSystemStatus, clearpath::DataSafetySystemStatus, clearpath::DataRawVoltage, clearpath::DataRawTemperature, clearpath::DataRawOrientation, clearpath::DataRawMagnetometer, clearpath::DataRawGyro, clearpath::DataRawCurrent, clearpath::DataRawAcceleration, clearpath::DataRangefinderTimings, clearpath::DataRangefinders, clearpath::DataProcessorStatus, clearpath::DataPowerSystem, clearpath::DataPlatformRotation, clearpath::DataPlatformOrientation, clearpath::DataPlatformMagnetometer, clearpath::DataPlatformName, clearpath::DataPlatformInfo, clearpath::DataPlatformAcceleration, clearpath::DataMaxSpeed, clearpath::DataMaxAcceleration, clearpath::DataGear, clearpath::DataFirmwareInfo, clearpath::DataEncodersRaw, clearpath::DataEncoders, clearpath::DataEcho, clearpath::DataDifferentialSpeed, clearpath::DataDifferentialOutput, clearpath::DataDifferentialControl, and clearpath::DataAckermannOutput.
Definition at line 491 of file Message.cpp.
const uint16_t clearpath::Message::CRC_INIT_VAL = 0xFFFF [static, protected] |
const size_t clearpath::Message::CRC_LENGTH = 2 [static, protected] |
uint8_t clearpath::Message::data[MAX_MSG_LENGTH] [protected] |
const size_t clearpath::Message::HEADER_LENGTH = 12 [static, protected] |
bool clearpath::Message::is_sent [protected] |
const size_t clearpath::Message::MAX_MSG_LENGTH = 256 [static] |
const size_t clearpath::Message::MIN_MSG_LENGTH = HEADER_LENGTH + CRC_LENGTH [static] |
const uint8_t clearpath::Message::SOH = 0xAA [static] |
const uint8_t clearpath::Message::STX = 0x55 [static] |
size_t clearpath::Message::total_len [protected] |