fixed some message queue includes

This commit is contained in:
Robin Müller 2020-09-15 16:42:17 +02:00
parent ad98a63e87
commit 15891b3cf0
14 changed files with 52 additions and 36 deletions

View File

@ -1,3 +1,4 @@
#include <fsfw/ipc/MessageQueueSenderIF.h>
#include "ActionHelper.h"
#include "HasActionsIF.h"
#include "../objectmanager/ObjectManagerIF.h"

View File

@ -1,5 +1,6 @@
#include "HasActionsIF.h"
#include "SimpleActionHelper.h"
SimpleActionHelper::SimpleActionHelper(HasActionsIF* setOwner,
MessageQueueIF* useThisQueue) :
ActionHelper(setOwner, useThisQueue), isExecuting(false), lastCommander(

View File

@ -122,7 +122,7 @@ uint32_t CommunicationMessage::getUint32Data() const{
}
void CommunicationMessage::setDataByte(uint8_t byte, uint8_t position) {
if(0 <= position && position <= 3) {
if(position <= 3) {
memcpy(getData() + 3 * sizeof(uint32_t) + position * sizeof(uint8_t), &byte, sizeof(byte));
}
else {
@ -131,7 +131,7 @@ void CommunicationMessage::setDataByte(uint8_t byte, uint8_t position) {
}
uint8_t CommunicationMessage::getDataByte(uint8_t position) const {
if(0 <= position && position <= 3) {
if(position <= 3) {
uint8_t byte;
memcpy(&byte, getData() + 3 * sizeof(uint32_t) + position * sizeof(uint8_t), sizeof(byte));
return byte;

View File

@ -71,7 +71,7 @@ void HealthHelper::setHealth(HasHealthIF::HealthState health) {
void HealthHelper::informParent(HasHealthIF::HealthState health,
HasHealthIF::HealthState oldHealth) {
if (parentQueue == MessageQueueMessageIF::NO_QUEUE) {
if (parentQueue == MessageQueueIF::NO_QUEUE) {
return;
}
CommandMessage information;
@ -86,7 +86,7 @@ void HealthHelper::informParent(HasHealthIF::HealthState health,
void HealthHelper::handleSetHealthCommand(CommandMessage* command) {
ReturnValue_t result = owner->setHealth(HealthMessage::getHealth(command));
if (command->getSender() == MessageQueueMessageIF::NO_QUEUE) {
if (command->getSender() == MessageQueueIF::NO_QUEUE) {
return;
}
CommandMessage reply;

View File

@ -1,21 +1,23 @@
#ifndef FSFW_IPC_MESSAGEQUEUEIF_H_
#define FSFW_IPC_MESSAGEQUEUEIF_H_
#include "MessageQueueMessageIF.h"
#include "messageQueueDefintions.h"
#include "../returnvalues/HasReturnvaluesIF.h"
#include <cstdint>
// COULDDO: We could support blocking calls
// semaphores are being implemented, which makes this idea even more iteresting.
/**
* @defgroup message_queue Message Queue
* @brief Message Queue related software components
*/
#include "../ipc/MessageQueueMessage.h"
#include "../ipc/MessageQueueSenderIF.h"
#include "../returnvalues/HasReturnvaluesIF.h"
class MessageQueueIF {
public:
static const MessageQueueId_t NO_QUEUE = MessageQueueMessageIF::NO_QUEUE; //!< Ugly hack.
static const MessageQueueId_t NO_QUEUE = 0;
static const uint8_t INTERFACE_ID = CLASS_ID::MESSAGE_QUEUE_IF;
//! No new messages on the queue

View File

@ -2,7 +2,6 @@
#define FSFW_IPC_MESSAGEQUEUEMESSAGE_H_
#include "../ipc/MessageQueueMessageIF.h"
#include "../ipc/MessageQueueSenderIF.h"
#include <cstddef>
/**

View File

@ -1,24 +1,13 @@
#ifndef FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_
#define FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_
#include "messageQueueDefintions.h"
#include <cstddef>
#include <cstdint>
/*
* TODO: Actually, the definition of this ID to be a uint32_t is not ideal and
* breaks layering. However, it is difficult to keep layering, as the ID is
* stored in many places and sent around in MessageQueueMessage.
* Ideally, one would use the (current) object_id_t only, however, doing a
* lookup of queueIDs for every call does not sound ideal.
* In a first step, I'll circumvent the issue by not touching it,
* maybe in a second step. This also influences Interface design
* (getCommandQueue) and some other issues..
*/
typedef uint32_t MessageQueueId_t;
class MessageQueueMessageIF {
public:
static const MessageQueueId_t NO_QUEUE = -1;
/**
* @brief This constants defines the size of the header,
* which is added to every message.

View File

@ -1,6 +1,7 @@
#ifndef FRAMEWORK_IPC_MESSAGEQUEUESENDERIF_H_
#define FRAMEWORK_IPC_MESSAGEQUEUESENDERIF_H_
#include "../ipc/MessageQueueIF.h"
#include "../ipc/MessageQueueMessageIF.h"
#include "../objectmanager/ObjectManagerIF.h"
@ -15,7 +16,7 @@ public:
*/
static ReturnValue_t sendMessage(MessageQueueId_t sendTo,
MessageQueueMessageIF* message,
MessageQueueId_t sentFrom = MessageQueueMessageIF::NO_QUEUE,
MessageQueueId_t sentFrom = MessageQueueIF::NO_QUEUE,
bool ignoreFault = false);
private:
MessageQueueSenderIF() {}

View File

@ -2,7 +2,9 @@
#define FRAMEWORK_IPC_QUEUEFACTORY_H_
#include "MessageQueueIF.h"
#include "MessageQueueMessage.h"
#include <cstdint>
/**
* Creates message queues.
* This class is a "singleton" interface, i.e. it provides an

View File

@ -0,0 +1,18 @@
#ifndef FSFW_IPC_MESSAGEQUEUEDEFINTIONS_H_
#define FSFW_IPC_MESSAGEQUEUEDEFINTIONS_H_
#include <cstdint>
/*
* TODO: Actually, the definition of this ID to be a uint32_t is not ideal and
* breaks layering. However, it is difficult to keep layering, as the ID is
* stored in many places and sent around in MessageQueueMessage.
* Ideally, one would use the (current) object_id_t only, however, doing a
* lookup of queueIDs for every call does not sound ideal.
* In a first step, I'll circumvent the issue by not touching it,
* maybe in a second step. This also influences Interface design
* (getCommandQueue) and some other issues..
*/
using MessageQueueId_t = uint32_t;
#endif /* FSFW_IPC_MESSAGEQUEUEDEFINTIONS_H_ */

View File

@ -1,3 +1,4 @@
#include "../ipc/MessageQueueSenderIF.h"
#include "../modes/HasModesIF.h"
#include "../modes/ModeHelper.h"
#include "../serviceinterface/ServiceInterfaceStream.h"
@ -35,7 +36,7 @@ ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* command) {
commandedMode = mode;
commandedSubmode = submode;
if ((parentQueueId != MessageQueueMessageIF::NO_QUEUE)
if ((parentQueueId != MessageQueueIF::NO_QUEUE)
&& (theOneWhoCommandedAMode != parentQueueId)) {
owner->setToExternalControl();
}
@ -73,13 +74,13 @@ void ModeHelper::modeChanged(Mode_t ownerMode, Submode_t ownerSubmode) {
forced = false;
sendModeReplyMessage(ownerMode, ownerSubmode);
sendModeInfoMessage(ownerMode, ownerSubmode);
theOneWhoCommandedAMode = MessageQueueMessageIF::NO_QUEUE;
theOneWhoCommandedAMode = MessageQueueIF::NO_QUEUE;
}
void ModeHelper::sendModeReplyMessage(Mode_t ownerMode,
Submode_t ownerSubmode) {
CommandMessage reply;
if (theOneWhoCommandedAMode != MessageQueueMessageIF::NO_QUEUE)
if (theOneWhoCommandedAMode != MessageQueueIF::NO_QUEUE)
{
if (ownerMode != commandedMode or ownerSubmode != commandedSubmode)
{
@ -101,7 +102,7 @@ void ModeHelper::sendModeInfoMessage(Mode_t ownerMode,
Submode_t ownerSubmode) {
CommandMessage reply;
if (theOneWhoCommandedAMode != parentQueueId
and parentQueueId != MessageQueueMessageIF::NO_QUEUE)
and parentQueueId != MessageQueueIF::NO_QUEUE)
{
ModeMessage::setModeMessage(&reply, ModeMessage::REPLY_MODE_INFO,
ownerMode, ownerSubmode);

View File

@ -1,5 +1,5 @@
#include "MessageQueue.h"
#include "../../objectmanager/ObjectManagerIF.h"
#include "../../serviceinterface/ServiceInterfaceStream.h"
// TODO I guess we should have a way of checking if we are in an ISR and then
@ -40,7 +40,7 @@ ReturnValue_t MessageQueue::sendToDefaultFrom(MessageQueueMessageIF* message,
}
ReturnValue_t MessageQueue::reply(MessageQueueMessageIF* message) {
if (this->lastPartner != MessageQueueMessageIF::NO_QUEUE) {
if (this->lastPartner != MessageQueueIF::NO_QUEUE) {
return sendMessageFrom(this->lastPartner, message, this->getId());
} else {
return NO_REPLY_PARTNER;
@ -58,8 +58,8 @@ ReturnValue_t MessageQueue::sendMessageFrom(MessageQueueId_t sendTo,
ReturnValue_t MessageQueue::handleSendResult(BaseType_t result, bool ignoreFault) {
if (result != pdPASS) {
if (not ignoreFault) {
InternalErrorReporterIF* internalErrorReporter =
objectManager->get<InternalErrorReporterIF>(
InternalErrorReporterIF* internalErrorReporter = objectManager->
get<InternalErrorReporterIF>(
objects::INTERNAL_ERROR_REPORTER);
if (internalErrorReporter != nullptr) {
internalErrorReporter->queueMessageNotSent();

View File

@ -8,6 +8,7 @@
#include <freertos/FreeRTOS.h>
#include <freertos/queue.h>
#include <fsfw/ipc/MessageQueueMessage.h>
// TODO: this class assumes that MessageQueueId_t is the same size as void*
// (the FreeRTOS handle type), compiler will catch this but it might be nice
@ -139,8 +140,8 @@ protected:
private:
bool defaultDestinationSet = false;
QueueHandle_t handle;
MessageQueueId_t defaultDestination = 0;
MessageQueueId_t lastPartner = 0;
MessageQueueId_t defaultDestination = MessageQueueIF::NO_QUEUE;
MessageQueueId_t lastPartner = MessageQueueIF::NO_QUEUE;
const size_t maxMessageSize;
//! Stores the current system context
CallContext callContext = CallContext::TASK;

View File

@ -1,3 +1,4 @@
#include "../../ipc/MessageQueueSenderIF.h"
#include "../../ipc/QueueFactory.h"
#include "../../osal/FreeRTOS/MessageQueue.h"