2016-06-15 23:48:41 +02:00
|
|
|
#include <framework/ipc/MessageQueueMessage.h>
|
|
|
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
|
|
|
|
2018-07-12 16:29:32 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
2016-06-15 23:48:41 +02:00
|
|
|
MessageQueueMessage::MessageQueueMessage() :
|
|
|
|
messageSize(this->HEADER_SIZE) {
|
|
|
|
memset(this->internalBuffer, 0, sizeof(this->internalBuffer));
|
|
|
|
}
|
|
|
|
|
2020-05-16 20:58:48 +02:00
|
|
|
MessageQueueMessage::MessageQueueMessage(uint8_t* data, size_t size) :
|
|
|
|
messageSize(this->HEADER_SIZE + size) {
|
|
|
|
if (size <= this->MAX_DATA_SIZE) {
|
|
|
|
memcpy(this->getData(), data, size);
|
|
|
|
this->messageSize = this->HEADER_SIZE + size;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sif::warning << "MessageQueueMessage: Passed size larger than maximum"
|
|
|
|
"allowed size! Setting content to 0" << std::endl;
|
|
|
|
memset(this->internalBuffer, 0, sizeof(this->internalBuffer));
|
|
|
|
this->messageSize = this->HEADER_SIZE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-15 23:48:41 +02:00
|
|
|
MessageQueueMessage::~MessageQueueMessage() {
|
|
|
|
}
|
|
|
|
|
|
|
|
const uint8_t* MessageQueueMessage::getBuffer() const {
|
|
|
|
return this->internalBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t* MessageQueueMessage::getBuffer() {
|
|
|
|
return this->internalBuffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
const uint8_t* MessageQueueMessage::getData() const {
|
|
|
|
return this->internalBuffer + this->HEADER_SIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t* MessageQueueMessage::getData() {
|
|
|
|
return this->internalBuffer + this->HEADER_SIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageQueueId_t MessageQueueMessage::getSender() const {
|
|
|
|
MessageQueueId_t temp_id;
|
|
|
|
memcpy(&temp_id, this->internalBuffer, sizeof(MessageQueueId_t));
|
|
|
|
return temp_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessageQueueMessage::setSender(MessageQueueId_t setId) {
|
|
|
|
memcpy(this->internalBuffer, &setId, sizeof(MessageQueueId_t));
|
|
|
|
}
|
|
|
|
|
2020-06-09 02:18:39 +02:00
|
|
|
size_t MessageQueueMessage::getMinimumMessageSize() const {
|
2016-06-15 23:48:41 +02:00
|
|
|
return this->HEADER_SIZE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MessageQueueMessage::print() {
|
2020-05-16 20:58:48 +02:00
|
|
|
sif::debug << "MessageQueueMessage has size: " << this->messageSize <<
|
|
|
|
std::hex << std::endl;
|
2016-06-15 23:48:41 +02:00
|
|
|
for (uint8_t count = 0; count < this->messageSize; count++) {
|
2020-04-23 19:13:18 +02:00
|
|
|
sif::debug << (uint32_t) this->internalBuffer[count] << ":";
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
2020-04-23 19:13:18 +02:00
|
|
|
sif::debug << std::dec << std::endl;
|
2016-06-15 23:48:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void MessageQueueMessage::clear() {
|
|
|
|
memset(this->getBuffer(), 0, this->MAX_MESSAGE_SIZE);
|
|
|
|
}
|
2020-06-11 02:03:18 +02:00
|
|
|
|
|
|
|
size_t MessageQueueMessage::getMessageSize() const {
|
|
|
|
return this->messageSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t MessageQueueMessage::getMaximumMessageSize() const {
|
|
|
|
return this->MAX_MESSAGE_SIZE;
|
|
|
|
}
|
2020-06-12 20:23:39 +02:00
|
|
|
|
|
|
|
void MessageQueueMessage::setMessageSize(size_t messageSize) {
|
|
|
|
this->messageSize = messageSize;
|
|
|
|
}
|