66 MessageException::MessageException(
const char *msg,
enum errors ex_type)
86 memcpy(
data, input, msg_len);
98 uint32_t timestamp, uint8_t flags, uint8_t version) :
135 for (
int i = 0; i < 2; ++i)
156 CPR_WARN() <<
"Bad checksum twice in a row." << endl;
223 size_t new_total_len = len + 3;
307 if (whyNot) { strncpy(whyNot,
"SOH is not present.", strLen); }
313 if (whyNot) { strncpy(whyNot,
"STX is not present.", strLen); }
319 if (whyNot) { strncpy(whyNot,
"Length does not match complement.", strLen); }
325 if (whyNot) { strncpy(whyNot,
"Length is wrong.", strLen); }
331 if (whyNot) { strncpy(whyNot,
"CRC is wrong.", strLen); }
352 stream <<
"Message" << endl;
353 stream <<
"=======" << endl;
354 stream <<
"Length : " << (int) (
getLength()) << endl;
356 stream <<
"Version : " << (int) (
getVersion()) << endl;
357 stream <<
"Flags : " << hex << (int) (
getFlags()) << endl;
358 stream <<
"Timestamp: " << dec <<
getTimestamp() << endl;
359 stream <<
"Type : " << hex << (int) (
getType()) << endl;
360 stream <<
"Checksum : " << hex << (int) (
getChecksum()) << endl;
369 stream << hex << uppercase;
370 for (
unsigned int i = 0; i <
total_len; i++)
372 stream << static_cast<short>(
data[i]) <<
" ";
422 return new DataEcho(input, msg_len);
482 return new Message(input, msg_len);
void setFlags(uint8_t flags)
uint8_t data[MAX_MSG_LENGTH]
void utob(void *dest, size_t dest_len, uint64_t src)
enum clearpath::BadAckException::ackFlags ack_flag
static Transport & instance()
static Message * waitNext(double timeout=0.0)
static Message * factory(void *input, size_t msg_len)
uint64_t btou(void *src, size_t src_len)
void setType(uint16_t type)
size_t toBytes(void *buf, size_t buf_size)
size_t getPayload(void *buf, size_t max_size)
virtual std::ostream & printMessage(std::ostream &stream=std::cout)
Message * waitNext(double timeout=0.0)
void setTimestamp(uint32_t timestamp)
static Message * popNext()
std::ostream & operator<<(std::ostream &stream, clearpath::Message &msg)
uint8_t * getPayloadPointer(size_t offset=0)
static const size_t CRC_LENGTH
void setPayload(void *buf, size_t buf_size)
void printRaw(std::ostream &stream=std::cout)
static const uint16_t CRC_INIT_VAL
uint16_t crc16(int size, int init_val, uint8_t *data)
void setVersion(uint8_t version)
void setLength(uint8_t len)
static const size_t MAX_MSG_LENGTH
void setPayloadLength(uint8_t len)
bool isValid(char *whyNot=NULL, size_t strLen=0)
size_t getPayloadLength()
static const size_t HEADER_LENGTH