adapted MessageQueueSenderIF function calls

This commit is contained in:
Robin Müller 2020-06-22 20:18:13 +02:00
parent 5734a0a0e9
commit dadc867d9e
9 changed files with 43 additions and 22 deletions

View File

@ -52,7 +52,8 @@ void EventManager::notifyListeners(EventMessage* message) {
for (auto iter = listenerList.begin(); iter != listenerList.end(); ++iter) {
if (iter->second.match(message)) {
MessageQueueSenderIF::sendMessage(iter->first, message,
message->getSender());
MessageQueueMessage::MAX_MESSAGE_SIZE,
message->getSender());
}
}
unlockMutex();

View File

@ -44,7 +44,8 @@ public:
eventmanagerQueue = eventmanager->getEventReportQueue();
}
}
MessageQueueSenderIF::sendMessage(eventmanagerQueue, message, sentFrom);
MessageQueueSenderIF::sendMessage(eventmanagerQueue, message,
MessageQueueMessage::MAX_MESSAGE_SIZE, sentFrom);
}
};

View File

@ -70,7 +70,8 @@ void HealthHelper::informParent(HasHealthIF::HealthState health,
HealthMessage::setHealthMessage(&information, HealthMessage::HEALTH_INFO,
health, oldHealth);
if (MessageQueueSenderIF::sendMessage(parentQueue, &information,
owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) {
MessageQueueMessage::MAX_MESSAGE_SIZE,
owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) {
sif::debug << "HealthHelper::informParent: sending health reply failed."
<< std::endl;
}
@ -90,7 +91,8 @@ void HealthHelper::handleSetHealthCommand(CommandMessage* command) {
reply.setReplyRejected(result, command->getCommand());
}
if (MessageQueueSenderIF::sendMessage(command->getSender(), &reply,
owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) {
MessageQueueMessage::MAX_MESSAGE_SIZE,
owner->getCommandQueue()) != HasReturnvaluesIF::RETURN_OK) {
sif::debug << "HealthHelper::handleHealthCommand: sending health "
"reply failed." << std::endl;

View File

@ -28,7 +28,8 @@ ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* command) {
if (result != HasReturnvaluesIF::RETURN_OK) {
ModeMessage::cantReachMode(&reply, result);
MessageQueueSenderIF::sendMessage(command->getSender(), &reply,
owner->getCommandQueue());
MessageQueueMessage::MAX_MESSAGE_SIZE,
owner->getCommandQueue());
break;
}
//Free to start transition
@ -50,7 +51,8 @@ ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* command) {
ModeMessage::setModeMessage(&reply, ModeMessage::REPLY_MODE_REPLY, mode,
submode);
MessageQueueSenderIF::sendMessage(command->getSender(), &reply,
owner->getCommandQueue());
MessageQueueMessage::MAX_MESSAGE_SIZE,
owner->getCommandQueue());
}
break;
case ModeMessage::CMD_MODE_ANNOUNCE:
@ -95,7 +97,7 @@ void ModeHelper::sendModeReplyMessage(Mode_t ownerMode,
ownerMode, ownerSubmode);
}
MessageQueueSenderIF::sendMessage(theOneWhoCommandedAMode, &reply,
owner->getCommandQueue());
MessageQueueMessage::MAX_MESSAGE_SIZE, owner->getCommandQueue());
}
}
@ -109,7 +111,8 @@ void ModeHelper::sendModeInfoMessage(Mode_t ownerMode,
ModeMessage::setModeMessage(&reply, ModeMessage::REPLY_MODE_INFO,
ownerMode, ownerSubmode);
MessageQueueSenderIF::sendMessage(parentQueueId, &reply,
owner->getCommandQueue());
MessageQueueMessage::MAX_MESSAGE_SIZE,
owner->getCommandQueue());
}
}

View File

@ -105,11 +105,14 @@ void FixedTimeslotTask::taskFunctionality() {
//The component for this slot is executed and the next one is chosen.
this->pst.executeAndAdvance();
if (not pst.slotFollowsImmediately()) {
// Get the interval till execution of the next slot.
intervalMs = this->pst.getIntervalToPreviousSlotMs();
interval = pdMS_TO_TICKS(intervalMs);
/* If all operations are finished and the difference of the
* current time minus the last wake time is larger than the
* expected wait period, a deadline was missed. */
if(xTaskGetTickCount() - xLastWakeTime >=
pdMS_TO_TICKS(this->pst.getIntervalToPreviousSlotMs())) {
if(xTaskGetTickCount() - xLastWakeTime >= interval) {
#ifdef DEBUG
sif::warning << "FixedTimeslotTask: " << pcTaskGetName(NULL) <<
" missed deadline!\n" << std::flush;
@ -117,14 +120,9 @@ void FixedTimeslotTask::taskFunctionality() {
if(deadlineMissedFunc != nullptr) {
this->deadlineMissedFunc();
}
// Continue immediately, no need to wait.
continue;
}
// we need to wait before executing the current slot
//this gives us the time to wait:
intervalMs = this->pst.getIntervalToPreviousSlotMs();
interval = pdMS_TO_TICKS(intervalMs);
// Wait for the interval. This exits immediately if a deadline was
// missed while also updating the last wake time.
vTaskDelayUntil(&xLastWakeTime, interval);
}
}

View File

@ -80,6 +80,12 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message,
}
ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
if(message->getMaximumMessageSize() < maxMessageSize) {
sif::error << "MessageQueue::receiveMessage: Message size "
<< message->getMaximumMessageSize() <<
" too small to receive data!" << std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
BaseType_t result = xQueueReceive(handle,reinterpret_cast<void*>(
message->getBuffer()), 0);
if (result == pdPASS){
@ -126,8 +132,10 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
message->setSender(sentFrom);
BaseType_t result;
if(message->getMaximumMessageSize() > maxSize) {
sif::error << "MessageQueue::sendMessageFromMessageQueue: Message size"
"too large for queue!" << std::endl;
sif::error << "MessageQueue::sendMessageFromMessageQueue: Message size "
<< message->getMaximumMessageSize() << " too large for queue"
" with max. message size " << maxSize << "!"
<< std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}

View File

@ -9,6 +9,11 @@ QueueFactory* QueueFactory::factoryInstance = nullptr;
ReturnValue_t MessageQueueSenderIF::sendMessage(MessageQueueId_t sendTo,
MessageQueueMessageIF* message, size_t maxSize,
MessageQueueId_t sentFrom, bool ignoreFault) {
if(maxSize == 0) {
sif::error << "MessageQueueSenderIF::sendMessage: Max Size is 0!"
<< std::endl;
return HasReturnvaluesIF::RETURN_FAILED;
}
return MessageQueue::sendMessageFromMessageQueue(sendTo,message, maxSize,
sentFrom,ignoreFault);
}

View File

@ -107,7 +107,8 @@ ReturnValue_t ParameterHelper::sendParameter(MessageQueueId_t to, uint32_t id,
ParameterMessage::setParameterDumpReply(&reply, id, address);
MessageQueueSenderIF::sendMessage(to, &reply, ownerQueueId);
MessageQueueSenderIF::sendMessage(to, &reply,
MessageQueueMessage::MAX_MESSAGE_SIZE, ownerQueueId);
return HasReturnvaluesIF::RETURN_OK;
}
@ -129,5 +130,6 @@ void ParameterHelper::rejectCommand(MessageQueueId_t to, ReturnValue_t reason,
MessageQueueMessage message;
CommandMessage reply(&message);
reply.setReplyRejected(reason, initialCommand);
MessageQueueSenderIF::sendMessage(to, &reply, ownerQueueId);
MessageQueueSenderIF::sendMessage(to, &reply,
MessageQueueMessage::MAX_MESSAGE_SIZE, ownerQueueId);
}

View File

@ -117,7 +117,8 @@ ReturnValue_t TmPacketStored::sendPacket(MessageQueueId_t destination,
return HasReturnvaluesIF::RETURN_FAILED;
}
TmTcMessage tmMessage(getStoreAddress());
ReturnValue_t result = MessageQueueSenderIF::sendMessage(destination, &tmMessage, sentFrom);
ReturnValue_t result = MessageQueueSenderIF::sendMessage(destination,
&tmMessage, MessageQueueMessage::MAX_MESSAGE_SIZE, sentFrom);
if (result != HasReturnvaluesIF::RETURN_OK) {
deletePacket();
if (doErrorReporting) {