40 #ifdef SIMPLE_MESSAGE_MOTOPLUS
50 namespace simple_message
53 SimpleMessage::SimpleMessage(
void)
57 SimpleMessage::~SimpleMessage(
void)
63 bool SimpleMessage::init(
int msgType,
int commType,
int replyCode)
67 return this->
init(msgType, commType, replyCode, data);
70 bool SimpleMessage::init(
int msgType,
int commType,
int replyCode,
ByteArray & data )
72 LOG_COMM(
"SimpleMessage::init(type: %d, comm: %d, reply: %d, data[%d]...)",
74 this->setMessageType(msgType);
75 this->setCommType(commType);
76 this->setReplyCode(replyCode);
77 this->data_.copyFrom(data);
79 return this->validateMessage();
94 LOG_COMM(
"Unloading data portion of message: %d bytes", dataSize);
95 msg.
unload(this->data_, dataSize);
98 msg.
unload(this->reply_code_);
99 msg.
unload(this->comm_type_);
100 msg.
unload(this->message_type_);
101 LOG_COMM(
"SimpleMessage::init(type: %d, comm: %d, reply: %d, data[%d]...)",
102 this->message_type_, this->comm_type_, this->reply_code_, this->data_.getBufferSize());
103 rtn = this->validateMessage();
117 msg.
load(this->getMessageType());
118 msg.
load(this->getCommType());
119 msg.
load(this->getReplyCode());
120 if (this->data_.getBufferSize() > 0 )
122 msg.
load(this->data_);
130 this->data_.copyFrom(data);
134 bool SimpleMessage::validateMessage()
139 LOG_WARN(
"Invalid message type: %u", this->getMessageType());
145 LOG_WARN(
"Invalid comms. type: %u", this->getCommType());
156 LOG_WARN(
"Invalid reply. Comm type: %u, Reply type: %u",
157 this->getCommType(), this->getReplyCode());