fixed some message queue includes
This commit is contained in:
parent
ad98a63e87
commit
15891b3cf0
@ -1,3 +1,4 @@
|
|||||||
|
#include <fsfw/ipc/MessageQueueSenderIF.h>
|
||||||
#include "ActionHelper.h"
|
#include "ActionHelper.h"
|
||||||
#include "HasActionsIF.h"
|
#include "HasActionsIF.h"
|
||||||
#include "../objectmanager/ObjectManagerIF.h"
|
#include "../objectmanager/ObjectManagerIF.h"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "HasActionsIF.h"
|
#include "HasActionsIF.h"
|
||||||
#include "SimpleActionHelper.h"
|
#include "SimpleActionHelper.h"
|
||||||
|
|
||||||
SimpleActionHelper::SimpleActionHelper(HasActionsIF* setOwner,
|
SimpleActionHelper::SimpleActionHelper(HasActionsIF* setOwner,
|
||||||
MessageQueueIF* useThisQueue) :
|
MessageQueueIF* useThisQueue) :
|
||||||
ActionHelper(setOwner, useThisQueue), isExecuting(false), lastCommander(
|
ActionHelper(setOwner, useThisQueue), isExecuting(false), lastCommander(
|
||||||
|
@ -122,7 +122,7 @@ uint32_t CommunicationMessage::getUint32Data() const{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CommunicationMessage::setDataByte(uint8_t byte, uint8_t position) {
|
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));
|
memcpy(getData() + 3 * sizeof(uint32_t) + position * sizeof(uint8_t), &byte, sizeof(byte));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -131,7 +131,7 @@ void CommunicationMessage::setDataByte(uint8_t byte, uint8_t position) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t CommunicationMessage::getDataByte(uint8_t position) const {
|
uint8_t CommunicationMessage::getDataByte(uint8_t position) const {
|
||||||
if(0 <= position && position <= 3) {
|
if(position <= 3) {
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
memcpy(&byte, getData() + 3 * sizeof(uint32_t) + position * sizeof(uint8_t), sizeof(byte));
|
memcpy(&byte, getData() + 3 * sizeof(uint32_t) + position * sizeof(uint8_t), sizeof(byte));
|
||||||
return byte;
|
return byte;
|
||||||
|
@ -71,7 +71,7 @@ void HealthHelper::setHealth(HasHealthIF::HealthState health) {
|
|||||||
|
|
||||||
void HealthHelper::informParent(HasHealthIF::HealthState health,
|
void HealthHelper::informParent(HasHealthIF::HealthState health,
|
||||||
HasHealthIF::HealthState oldHealth) {
|
HasHealthIF::HealthState oldHealth) {
|
||||||
if (parentQueue == MessageQueueMessageIF::NO_QUEUE) {
|
if (parentQueue == MessageQueueIF::NO_QUEUE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CommandMessage information;
|
CommandMessage information;
|
||||||
@ -86,7 +86,7 @@ void HealthHelper::informParent(HasHealthIF::HealthState health,
|
|||||||
|
|
||||||
void HealthHelper::handleSetHealthCommand(CommandMessage* command) {
|
void HealthHelper::handleSetHealthCommand(CommandMessage* command) {
|
||||||
ReturnValue_t result = owner->setHealth(HealthMessage::getHealth(command));
|
ReturnValue_t result = owner->setHealth(HealthMessage::getHealth(command));
|
||||||
if (command->getSender() == MessageQueueMessageIF::NO_QUEUE) {
|
if (command->getSender() == MessageQueueIF::NO_QUEUE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CommandMessage reply;
|
CommandMessage reply;
|
||||||
|
@ -1,21 +1,23 @@
|
|||||||
#ifndef FSFW_IPC_MESSAGEQUEUEIF_H_
|
#ifndef FSFW_IPC_MESSAGEQUEUEIF_H_
|
||||||
#define 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
|
// COULDDO: We could support blocking calls
|
||||||
// semaphores are being implemented, which makes this idea even more iteresting.
|
// semaphores are being implemented, which makes this idea even more iteresting.
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup message_queue Message Queue
|
* @defgroup message_queue Message Queue
|
||||||
* @brief Message Queue related software components
|
* @brief Message Queue related software components
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "../ipc/MessageQueueMessage.h"
|
|
||||||
#include "../ipc/MessageQueueSenderIF.h"
|
|
||||||
#include "../returnvalues/HasReturnvaluesIF.h"
|
|
||||||
class MessageQueueIF {
|
class MessageQueueIF {
|
||||||
public:
|
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;
|
static const uint8_t INTERFACE_ID = CLASS_ID::MESSAGE_QUEUE_IF;
|
||||||
//! No new messages on the queue
|
//! No new messages on the queue
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
#define FSFW_IPC_MESSAGEQUEUEMESSAGE_H_
|
#define FSFW_IPC_MESSAGEQUEUEMESSAGE_H_
|
||||||
|
|
||||||
#include "../ipc/MessageQueueMessageIF.h"
|
#include "../ipc/MessageQueueMessageIF.h"
|
||||||
#include "../ipc/MessageQueueSenderIF.h"
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,24 +1,13 @@
|
|||||||
#ifndef FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_
|
#ifndef FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_
|
||||||
#define FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_
|
#define FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_
|
||||||
|
|
||||||
|
#include "messageQueueDefintions.h"
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#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 {
|
class MessageQueueMessageIF {
|
||||||
public:
|
public:
|
||||||
static const MessageQueueId_t NO_QUEUE = -1;
|
|
||||||
/**
|
/**
|
||||||
* @brief This constants defines the size of the header,
|
* @brief This constants defines the size of the header,
|
||||||
* which is added to every message.
|
* which is added to every message.
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef FRAMEWORK_IPC_MESSAGEQUEUESENDERIF_H_
|
#ifndef FRAMEWORK_IPC_MESSAGEQUEUESENDERIF_H_
|
||||||
#define FRAMEWORK_IPC_MESSAGEQUEUESENDERIF_H_
|
#define FRAMEWORK_IPC_MESSAGEQUEUESENDERIF_H_
|
||||||
|
|
||||||
|
#include "../ipc/MessageQueueIF.h"
|
||||||
#include "../ipc/MessageQueueMessageIF.h"
|
#include "../ipc/MessageQueueMessageIF.h"
|
||||||
#include "../objectmanager/ObjectManagerIF.h"
|
#include "../objectmanager/ObjectManagerIF.h"
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
static ReturnValue_t sendMessage(MessageQueueId_t sendTo,
|
static ReturnValue_t sendMessage(MessageQueueId_t sendTo,
|
||||||
MessageQueueMessageIF* message,
|
MessageQueueMessageIF* message,
|
||||||
MessageQueueId_t sentFrom = MessageQueueMessageIF::NO_QUEUE,
|
MessageQueueId_t sentFrom = MessageQueueIF::NO_QUEUE,
|
||||||
bool ignoreFault = false);
|
bool ignoreFault = false);
|
||||||
private:
|
private:
|
||||||
MessageQueueSenderIF() {}
|
MessageQueueSenderIF() {}
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
#define FRAMEWORK_IPC_QUEUEFACTORY_H_
|
#define FRAMEWORK_IPC_QUEUEFACTORY_H_
|
||||||
|
|
||||||
#include "MessageQueueIF.h"
|
#include "MessageQueueIF.h"
|
||||||
|
#include "MessageQueueMessage.h"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates message queues.
|
* Creates message queues.
|
||||||
* This class is a "singleton" interface, i.e. it provides an
|
* This class is a "singleton" interface, i.e. it provides an
|
||||||
|
18
ipc/messageQueueDefintions.h
Normal file
18
ipc/messageQueueDefintions.h
Normal 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_ */
|
@ -1,3 +1,4 @@
|
|||||||
|
#include "../ipc/MessageQueueSenderIF.h"
|
||||||
#include "../modes/HasModesIF.h"
|
#include "../modes/HasModesIF.h"
|
||||||
#include "../modes/ModeHelper.h"
|
#include "../modes/ModeHelper.h"
|
||||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||||
@ -35,7 +36,7 @@ ReturnValue_t ModeHelper::handleModeCommand(CommandMessage* command) {
|
|||||||
commandedMode = mode;
|
commandedMode = mode;
|
||||||
commandedSubmode = submode;
|
commandedSubmode = submode;
|
||||||
|
|
||||||
if ((parentQueueId != MessageQueueMessageIF::NO_QUEUE)
|
if ((parentQueueId != MessageQueueIF::NO_QUEUE)
|
||||||
&& (theOneWhoCommandedAMode != parentQueueId)) {
|
&& (theOneWhoCommandedAMode != parentQueueId)) {
|
||||||
owner->setToExternalControl();
|
owner->setToExternalControl();
|
||||||
}
|
}
|
||||||
@ -73,13 +74,13 @@ void ModeHelper::modeChanged(Mode_t ownerMode, Submode_t ownerSubmode) {
|
|||||||
forced = false;
|
forced = false;
|
||||||
sendModeReplyMessage(ownerMode, ownerSubmode);
|
sendModeReplyMessage(ownerMode, ownerSubmode);
|
||||||
sendModeInfoMessage(ownerMode, ownerSubmode);
|
sendModeInfoMessage(ownerMode, ownerSubmode);
|
||||||
theOneWhoCommandedAMode = MessageQueueMessageIF::NO_QUEUE;
|
theOneWhoCommandedAMode = MessageQueueIF::NO_QUEUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModeHelper::sendModeReplyMessage(Mode_t ownerMode,
|
void ModeHelper::sendModeReplyMessage(Mode_t ownerMode,
|
||||||
Submode_t ownerSubmode) {
|
Submode_t ownerSubmode) {
|
||||||
CommandMessage reply;
|
CommandMessage reply;
|
||||||
if (theOneWhoCommandedAMode != MessageQueueMessageIF::NO_QUEUE)
|
if (theOneWhoCommandedAMode != MessageQueueIF::NO_QUEUE)
|
||||||
{
|
{
|
||||||
if (ownerMode != commandedMode or ownerSubmode != commandedSubmode)
|
if (ownerMode != commandedMode or ownerSubmode != commandedSubmode)
|
||||||
{
|
{
|
||||||
@ -101,7 +102,7 @@ void ModeHelper::sendModeInfoMessage(Mode_t ownerMode,
|
|||||||
Submode_t ownerSubmode) {
|
Submode_t ownerSubmode) {
|
||||||
CommandMessage reply;
|
CommandMessage reply;
|
||||||
if (theOneWhoCommandedAMode != parentQueueId
|
if (theOneWhoCommandedAMode != parentQueueId
|
||||||
and parentQueueId != MessageQueueMessageIF::NO_QUEUE)
|
and parentQueueId != MessageQueueIF::NO_QUEUE)
|
||||||
{
|
{
|
||||||
ModeMessage::setModeMessage(&reply, ModeMessage::REPLY_MODE_INFO,
|
ModeMessage::setModeMessage(&reply, ModeMessage::REPLY_MODE_INFO,
|
||||||
ownerMode, ownerSubmode);
|
ownerMode, ownerSubmode);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include "MessageQueue.h"
|
#include "MessageQueue.h"
|
||||||
|
#include "../../objectmanager/ObjectManagerIF.h"
|
||||||
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
#include "../../serviceinterface/ServiceInterfaceStream.h"
|
||||||
|
|
||||||
// TODO I guess we should have a way of checking if we are in an ISR and then
|
// 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) {
|
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());
|
return sendMessageFrom(this->lastPartner, message, this->getId());
|
||||||
} else {
|
} else {
|
||||||
return NO_REPLY_PARTNER;
|
return NO_REPLY_PARTNER;
|
||||||
@ -58,8 +58,8 @@ ReturnValue_t MessageQueue::sendMessageFrom(MessageQueueId_t sendTo,
|
|||||||
ReturnValue_t MessageQueue::handleSendResult(BaseType_t result, bool ignoreFault) {
|
ReturnValue_t MessageQueue::handleSendResult(BaseType_t result, bool ignoreFault) {
|
||||||
if (result != pdPASS) {
|
if (result != pdPASS) {
|
||||||
if (not ignoreFault) {
|
if (not ignoreFault) {
|
||||||
InternalErrorReporterIF* internalErrorReporter =
|
InternalErrorReporterIF* internalErrorReporter = objectManager->
|
||||||
objectManager->get<InternalErrorReporterIF>(
|
get<InternalErrorReporterIF>(
|
||||||
objects::INTERNAL_ERROR_REPORTER);
|
objects::INTERNAL_ERROR_REPORTER);
|
||||||
if (internalErrorReporter != nullptr) {
|
if (internalErrorReporter != nullptr) {
|
||||||
internalErrorReporter->queueMessageNotSent();
|
internalErrorReporter->queueMessageNotSent();
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include <freertos/FreeRTOS.h>
|
#include <freertos/FreeRTOS.h>
|
||||||
#include <freertos/queue.h>
|
#include <freertos/queue.h>
|
||||||
|
#include <fsfw/ipc/MessageQueueMessage.h>
|
||||||
|
|
||||||
// TODO: this class assumes that MessageQueueId_t is the same size as void*
|
// 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
|
// (the FreeRTOS handle type), compiler will catch this but it might be nice
|
||||||
@ -139,8 +140,8 @@ protected:
|
|||||||
private:
|
private:
|
||||||
bool defaultDestinationSet = false;
|
bool defaultDestinationSet = false;
|
||||||
QueueHandle_t handle;
|
QueueHandle_t handle;
|
||||||
MessageQueueId_t defaultDestination = 0;
|
MessageQueueId_t defaultDestination = MessageQueueIF::NO_QUEUE;
|
||||||
MessageQueueId_t lastPartner = 0;
|
MessageQueueId_t lastPartner = MessageQueueIF::NO_QUEUE;
|
||||||
const size_t maxMessageSize;
|
const size_t maxMessageSize;
|
||||||
//! Stores the current system context
|
//! Stores the current system context
|
||||||
CallContext callContext = CallContext::TASK;
|
CallContext callContext = CallContext::TASK;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include "../../ipc/MessageQueueSenderIF.h"
|
||||||
#include "../../ipc/QueueFactory.h"
|
#include "../../ipc/QueueFactory.h"
|
||||||
|
|
||||||
#include "../../osal/FreeRTOS/MessageQueue.h"
|
#include "../../osal/FreeRTOS/MessageQueue.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user