#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 () |
size_t | getTotalLength () |
uint16_t | getType () |
size_t | getType (void *buf, size_t max_size) |
size_t | getTypeLength () |
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 () |
Message * | sendRequest () |
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) |
Public Attributes | |
uint8_t | data [MAX_MSG_LENGTH] |
size_t | total_len |
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, FLAGS_OFST = 4, STX_OFST = 5, TYPE_OFST, PAYLOAD_OFST = 8 } |
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 | setType (uint16_t type) |
void | setVersion (uint8_t version) |
Protected Attributes | |
bool | is_sent |
Static Protected Attributes | |
static const uint16_t | CRC_INIT_VAL = 0xFFFF |
static const size_t | CRC_LENGTH = 2 |
static const size_t | HEADER_LENGTH = 8 |
Friends | |
class | Transport |
enum sawyer::Message::dataOffsets [protected] |
Definition at line 77 of file Message.cpp.
sawyer::Message::Message | ( | void * | input, |
size_t | msg_len | ||
) |
Definition at line 84 of file Message.cpp.
sawyer::Message::Message | ( | const Message & | other | ) |
Definition at line 93 of file Message.cpp.
sawyer::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 101 of file Message.cpp.
sawyer::Message::~Message | ( | ) | [virtual] |
Definition at line 131 of file Message.cpp.
size_t sawyer::Message::crcOffset | ( | ) | [inline, protected] |
Message * sawyer::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 423 of file Message.cpp.
uint16_t sawyer::Message::getChecksum | ( | ) |
Definition at line 248 of file Message.cpp.
uint8_t sawyer::Message::getFlags | ( | ) |
Reimplemented in sawyer::DataSafetySystemStatus.
Definition at line 238 of file Message.cpp.
uint8_t sawyer::Message::getLength | ( | ) |
Definition at line 223 of file Message.cpp.
uint8_t sawyer::Message::getLengthComp | ( | ) |
Definition at line 228 of file Message.cpp.
size_t sawyer::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 204 of file Message.cpp.
size_t sawyer::Message::getPayloadLength | ( | ) | [inline] |
uint8_t * sawyer::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 218 of file Message.cpp.
size_t sawyer::Message::getTotalLength | ( | ) | [inline] |
uint16_t sawyer::Message::getType | ( | ) |
Definition at line 243 of file Message.cpp.
size_t sawyer::Message::getType | ( | void * | buf, |
size_t | max_size | ||
) |
size_t sawyer::Message::getTypeLength | ( | ) | [inline] |
uint8_t sawyer::Message::getVersion | ( | ) |
Definition at line 233 of file Message.cpp.
bool sawyer::Message::isCommand | ( | ) | [inline] |
bool sawyer::Message::isData | ( | ) | [inline] |
bool sawyer::Message::isRequest | ( | ) | [inline] |
bool sawyer::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 329 of file Message.cpp.
void sawyer::Message::makeValid | ( | ) | [protected] |
Sets SOH, STX, length, and checksum so that this message becomes valid.
Definition at line 372 of file Message.cpp.
Message * sawyer::Message::popNext | ( | ) | [static] |
Reimplemented in sawyer::DataVelocity, sawyer::DataSystemStatus, sawyer::DataSafetySystemStatus, sawyer::DataRawVoltage, sawyer::DataRawTemperature, sawyer::DataRawOrientation, sawyer::DataXYZData, sawyer::DataRawMagnetometer, sawyer::DataRawGyro, sawyer::DataRawCurrent, sawyer::Data6AxisYaw, sawyer::DataRawAcceleration, sawyer::DataRangefinderTimings, sawyer::DataRangefinders, sawyer::DataProcessorStatus, sawyer::DataPowerSystem, sawyer::DataPlatformRotation, sawyer::DataPlatformOrientation, sawyer::DataPlatformMagnetometer, sawyer::DataPlatformName, sawyer::DataPlatformInfo, sawyer::DataPlatformAcceleration, sawyer::DataMaxSpeed, sawyer::DataMaxAcceleration, sawyer::DataGear, sawyer::DataFirmwareInfo, sawyer::DataEncodersRaw, sawyer::DataEncoders, sawyer::DataEcho, sawyer::DataWheelInfo, sawyer::DataDifferentialSpeed, sawyer::DataDifferentialOutput, sawyer::DataDifferentialControl, and sawyer::DataAckermannOutput.
Definition at line 532 of file Message.cpp.
std::ostream & sawyer::Message::printMessage | ( | std::ostream & | stream = std::cout | ) | [virtual] |
Reimplemented in sawyer::DataVelocity, sawyer::DataSystemStatus, sawyer::DataSafetySystemStatus, sawyer::DataRawVoltage, sawyer::DataRawTemperature, sawyer::DataRawOrientation, sawyer::DataXYZData, sawyer::DataRawMagnetometer, sawyer::DataRawGyro, sawyer::DataRawCurrent, sawyer::Data6AxisYaw, sawyer::DataRawAcceleration, sawyer::DataRangefinderTimings, sawyer::DataRangefinders, sawyer::DataProcessorStatus, sawyer::DataPowerSystem, sawyer::DataPlatformRotation, sawyer::DataPlatformOrientation, sawyer::DataPlatformMagnetometer, sawyer::DataPlatformName, sawyer::DataPlatformInfo, sawyer::DataPlatformAcceleration, sawyer::DataMaxSpeed, sawyer::DataMaxAcceleration, sawyer::DataGear, sawyer::DataFirmwareInfo, sawyer::DataEncodersRaw, sawyer::DataEncoders, sawyer::DataEcho, sawyer::DataWheelInfo, sawyer::DataDifferentialSpeed, sawyer::DataDifferentialOutput, sawyer::DataDifferentialControl, and sawyer::DataAckermannOutput.
Definition at line 389 of file Message.cpp.
void sawyer::Message::printRaw | ( | std::ostream & | stream = std::cout | ) |
Definition at line 405 of file Message.cpp.
void sawyer::Message::send | ( | ) |
Definition at line 136 of file Message.cpp.
Definition at line 168 of file Message.cpp.
void sawyer::Message::setFlags | ( | uint8_t | flags | ) | [protected] |
Definition at line 267 of file Message.cpp.
void sawyer::Message::setLength | ( | uint8_t | len | ) | [protected] |
Definition at line 253 of file Message.cpp.
void sawyer::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 296 of file Message.cpp.
void sawyer::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 282 of file Message.cpp.
void sawyer::Message::setType | ( | uint16_t | type | ) | [protected] |
Definition at line 272 of file Message.cpp.
void sawyer::Message::setVersion | ( | uint8_t | version | ) | [protected] |
Definition at line 262 of file Message.cpp.
size_t sawyer::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 311 of file Message.cpp.
Message * sawyer::Message::waitNext | ( | double | timeout = 0.0 | ) | [static] |
Reimplemented in sawyer::DataVelocity, sawyer::DataSystemStatus, sawyer::DataSafetySystemStatus, sawyer::DataRawVoltage, sawyer::DataRawTemperature, sawyer::DataRawOrientation, sawyer::DataXYZData, sawyer::DataRawMagnetometer, sawyer::DataRawGyro, sawyer::DataRawCurrent, sawyer::Data6AxisYaw, sawyer::DataRawAcceleration, sawyer::DataRangefinderTimings, sawyer::DataRangefinders, sawyer::DataProcessorStatus, sawyer::DataPowerSystem, sawyer::DataPlatformRotation, sawyer::DataPlatformOrientation, sawyer::DataPlatformMagnetometer, sawyer::DataPlatformName, sawyer::DataPlatformInfo, sawyer::DataPlatformAcceleration, sawyer::DataMaxSpeed, sawyer::DataMaxAcceleration, sawyer::DataGear, sawyer::DataFirmwareInfo, sawyer::DataEncodersRaw, sawyer::DataEncoders, sawyer::DataEcho, sawyer::DataWheelInfo, sawyer::DataDifferentialSpeed, sawyer::DataDifferentialOutput, sawyer::DataDifferentialControl, and sawyer::DataAckermannOutput.
Definition at line 537 of file Message.cpp.
const uint16_t sawyer::Message::CRC_INIT_VAL = 0xFFFF [static, protected] |
const size_t sawyer::Message::CRC_LENGTH = 2 [static, protected] |
uint8_t sawyer::Message::data[MAX_MSG_LENGTH] |
const size_t sawyer::Message::HEADER_LENGTH = 8 [static, protected] |
bool sawyer::Message::is_sent [protected] |
const size_t sawyer::Message::MAX_MSG_LENGTH = 256 [static] |
const size_t sawyer::Message::MIN_MSG_LENGTH = HEADER_LENGTH + CRC_LENGTH [static] |
const uint8_t sawyer::Message::SOH = 0xAA [static] |
const uint8_t sawyer::Message::STX = 0x55 [static] |
size_t sawyer::Message::total_len |