Merge branch 'development' into mueller/thermal-handler
This commit is contained in:
commit
9784d5123b
@ -64,9 +64,8 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
|
|||||||
return MessageQueueIF::EMPTY;
|
return MessageQueueIF::EMPTY;
|
||||||
}
|
}
|
||||||
MutexGuard mutexLock(queueLock, MutexIF::TimeoutType::WAITING, 20);
|
MutexGuard mutexLock(queueLock, MutexIF::TimeoutType::WAITING, 20);
|
||||||
MessageQueueMessage* currentMessage = &messageQueue.front();
|
std::copy(messageQueue.front().data(), messageQueue.front().data() + messageSize,
|
||||||
std::copy(currentMessage->getBuffer(),
|
message->getBuffer());
|
||||||
currentMessage->getBuffer() + messageSize, message->getBuffer());
|
|
||||||
messageQueue.pop();
|
messageQueue.pop();
|
||||||
// The last partner is the first uint32_t field in the message
|
// The last partner is the first uint32_t field in the message
|
||||||
this->lastPartner = message->getSender();
|
this->lastPartner = message->getSender();
|
||||||
@ -80,7 +79,7 @@ MessageQueueId_t MessageQueue::getLastPartner() const {
|
|||||||
ReturnValue_t MessageQueue::flush(uint32_t* count) {
|
ReturnValue_t MessageQueue::flush(uint32_t* count) {
|
||||||
*count = messageQueue.size();
|
*count = messageQueue.size();
|
||||||
// Clears the queue.
|
// Clears the queue.
|
||||||
messageQueue = std::queue<MessageQueueMessage>();
|
messageQueue = std::queue<std::vector<uint8_t>>();
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,6 +105,9 @@ bool MessageQueue::isDefaultDestinationSet() const {
|
|||||||
ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||||
MessageQueueMessageIF* message, MessageQueueId_t sentFrom,
|
MessageQueueMessageIF* message, MessageQueueId_t sentFrom,
|
||||||
bool ignoreFault) {
|
bool ignoreFault) {
|
||||||
|
if(message == nullptr) {
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
message->setSender(sentFrom);
|
message->setSender(sentFrom);
|
||||||
if(message->getMessageSize() > message->getMaximumMessageSize()) {
|
if(message->getMessageSize() > message->getMaximumMessageSize()) {
|
||||||
// Actually, this should never happen or an error will be emitted
|
// Actually, this should never happen or an error will be emitted
|
||||||
@ -128,21 +130,10 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
|||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
if(targetQueue->messageQueue.size() < targetQueue->messageDepth) {
|
if(targetQueue->messageQueue.size() < targetQueue->messageDepth) {
|
||||||
MutexGuard mutexLock(targetQueue->queueLock,
|
MutexGuard mutexLock(targetQueue->queueLock, MutexIF::TimeoutType::WAITING, 20);
|
||||||
MutexIF::TimeoutType::WAITING, 20);
|
targetQueue->messageQueue.push(std::vector<uint8_t>(message->getMaximumMessageSize()));
|
||||||
// not ideal, works for now though.
|
memcpy(targetQueue->messageQueue.back().data(), message->getBuffer(),
|
||||||
MessageQueueMessage* mqmMessage =
|
message->getMaximumMessageSize());
|
||||||
dynamic_cast<MessageQueueMessage*>(message);
|
|
||||||
if(message != nullptr) {
|
|
||||||
targetQueue->messageQueue.push(*mqmMessage);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
#if FSFW_CPP_OSTREAM_ENABLED == 1
|
|
||||||
sif::error << "MessageQueue::sendMessageFromMessageQueue: Message"
|
|
||||||
"is not MessageQueueMessage!" << std::endl;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return MessageQueueIF::FULL;
|
return MessageQueueIF::FULL;
|
||||||
|
@ -212,7 +212,7 @@ protected:
|
|||||||
//static ReturnValue_t handleSendResult(BaseType_t result, bool ignoreFault);
|
//static ReturnValue_t handleSendResult(BaseType_t result, bool ignoreFault);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::queue<MessageQueueMessage> messageQueue;
|
std::queue<std::vector<uint8_t>> messageQueue;
|
||||||
/**
|
/**
|
||||||
* @brief The class stores the queue id it got assigned.
|
* @brief The class stores the queue id it got assigned.
|
||||||
* If initialization fails, the queue id is set to zero.
|
* If initialization fails, the queue id is set to zero.
|
||||||
|
Loading…
Reference in New Issue
Block a user