form improvements

This commit is contained in:
Robin Müller 2020-08-25 18:09:05 +02:00
parent 6afbeb8423
commit da3b2b2500
11 changed files with 125 additions and 157 deletions

View File

@ -1,5 +1,5 @@
#include "../ipc/CommandMessage.h" #include "CommandMessage.h"
#include "../ipc/CommandMessageCleaner.h" #include "CommandMessageCleaner.h"
#include <cstring> #include <cstring>
CommandMessage::CommandMessage() { CommandMessage::CommandMessage() {

View File

@ -1,9 +1,9 @@
#ifndef FRAMEWORK_IPC_COMMANDMESSAGE_H_ #ifndef FSFW_IPC_COMMANDMESSAGE_H_
#define FRAMEWORK_IPC_COMMANDMESSAGE_H_ #define FSFW_IPC_COMMANDMESSAGE_H_
#include "../ipc/CommandMessageIF.h" #include "CommandMessageIF.h"
#include "../ipc/MessageQueueMessage.h" #include "MessageQueueMessage.h"
#include "../ipc/FwMessageTypes.h" #include "FwMessageTypes.h"
/** /**
* @brief Default command message used to pass command messages between tasks. * @brief Default command message used to pass command messages between tasks.
@ -126,4 +126,4 @@ public:
size_t getMinimumMessageSize() const override; size_t getMinimumMessageSize() const override;
}; };
#endif /* COMMANDMESSAGE_H_ */ #endif /* FSFW_IPC_COMMANDMESSAGE_H_ */

View File

@ -1,8 +1,8 @@
#ifndef FRAMEWORK_IPC_COMMANDMESSAGEIF_H_ #ifndef FSFW_IPC_COMMANDMESSAGEIF_H_
#define FRAMEWORK_IPC_COMMANDMESSAGEIF_H_ #define FSFW_IPC_COMMANDMESSAGEIF_H_
#include "../ipc/MessageQueueMessageIF.h" #include "MessageQueueMessageIF.h"
#include "../ipc/FwMessageTypes.h" #include "FwMessageTypes.h"
#include "../returnvalues/HasReturnvaluesIF.h" #include "../returnvalues/HasReturnvaluesIF.h"
#define MAKE_COMMAND_ID( number ) ((MESSAGE_ID << 8) + (number)) #define MAKE_COMMAND_ID( number ) ((MESSAGE_ID << 8) + (number))
@ -70,4 +70,4 @@ public:
}; };
#endif /* FRAMEWORK_IPC_COMMANDMESSAGEIF_H_ */ #endif /* FSFW_IPC_COMMANDMESSAGEIF_H_ */

View File

@ -1,5 +1,5 @@
#ifndef FRAMEWORK_IPC_MESSAGEQUEUEIF_H_ #ifndef FSFW_IPC_MESSAGEQUEUEIF_H_
#define FRAMEWORK_IPC_MESSAGEQUEUEIF_H_ #define FSFW_IPC_MESSAGEQUEUEIF_H_
// 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.
@ -30,21 +30,28 @@ public:
virtual ~MessageQueueIF() {} virtual ~MessageQueueIF() {}
/** /**
* @brief This operation sends a message to the last communication partner. * @brief This operation sends a message to the last communication partner.
* @details This operation simplifies answering an incoming message by using the stored * @details
* lastParnter information as destination. If there was no message received yet * This operation simplifies answering an incoming message by using the
* (i.e. lastPartner is zero), an error code is returned. * stored lastParnter information as destination. If there was no message
* @param message A pointer to a previously created message, which is sent. * received yet (i.e. lastPartner is zero), an error code is returned.
* @return RETURN_OK if ok * @param message
* @return NO_REPLY_PARTNER Should return NO_REPLY_PARTNER if partner was found * A pointer to a previously created message, which is sent.
* @return
* -@c RETURN_OK if ok
* -@c NO_REPLY_PARTNER Should return NO_REPLY_PARTNER if partner was found.
*/ */
virtual ReturnValue_t reply( MessageQueueMessageIF* message ) = 0; virtual ReturnValue_t reply(MessageQueueMessageIF* message) = 0;
/** /**
* @brief This function reads available messages from the message queue and returns the sender. * @brief This function reads available messages from the message queue
* @details It works identically to the other receiveMessage call, but in addition returns the * and returns the sender.
* sender's queue id. * @details
* @param message A pointer to a message in which the received data is stored. * It works identically to the other receiveMessage call, but in addition
* @param receivedFrom A pointer to a queue id in which the sender's id is stored. * returns the sender's queue id.
* @param message
* A pointer to a message in which the received data is stored.
* @param receivedFrom
* A pointer to a queue id in which the sender's id is stored.
*/ */
virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message, virtual ReturnValue_t receiveMessage(MessageQueueMessageIF* message,
MessageQueueId_t *receivedFrom) = 0; MessageQueueId_t *receivedFrom) = 0;
@ -57,7 +64,8 @@ public:
* information is stored in theblastPartner attribute. Else, the lastPartner * information is stored in theblastPartner attribute. Else, the lastPartner
* information remains untouched, the message's content is cleared and the * information remains untouched, the message's content is cleared and the
* function returns immediately. * function returns immediately.
* @param message A pointer to a message in which the received data is stored. * @param message
* A pointer to a message in which the received data is stored.
* @return -@c RETURN_OK on success * @return -@c RETURN_OK on success
* -@c MessageQueueIF::EMPTY if queue is empty * -@c MessageQueueIF::EMPTY if queue is empty
*/ */
@ -69,24 +77,33 @@ public:
*/ */
virtual ReturnValue_t flush(uint32_t* count) = 0; virtual ReturnValue_t flush(uint32_t* count) = 0;
/** /**
* @brief This method returns the message queue id of the last communication partner. * @brief This method returns the message queue
* id of the last communication partner.
*/ */
virtual MessageQueueId_t getLastPartner() const = 0; virtual MessageQueueId_t getLastPartner() const = 0;
/** /**
* @brief This method returns the message queue id of this class's message queue. * @brief This method returns the message queue
* id of this class's message queue.
*/ */
virtual MessageQueueId_t getId() const = 0; virtual MessageQueueId_t getId() const = 0;
/** /**
* @brief With the sendMessage call, a queue message is sent to a receiving queue. * @brief With the sendMessage call, a queue message
* @details This method takes the message provided, adds the sentFrom information and passes * is sent to a receiving queue.
* it on to the destination provided with an operating system call. The OS's return * @details
* value is returned. * This method takes the message provided, adds the sentFrom information
* @param sendTo This parameter specifies the message queue id to send the message to. * and passes it on to the destination provided with an operating system
* @param message This is a pointer to a previously created message, which is sent. * call. The OS's returnvalue is returned.
* @param sentFrom The sentFrom information can be set to inject the sender's queue id into the message. * @param sendTo
* This variable is set to zero by default. * This parameter specifies the message queue id to send the message to.
* @param ignoreFault If set to true, the internal software fault counter is not incremented if queue is full (if implemented). * @param message
* This is a pointer to a previously created message, which is sent.
* @param sentFrom
* The sentFrom information can be set to inject the sender's queue id
* into the message. This variable is set to zero by default.
* @param ignoreFault
* If set to true, the internal software fault counter is not incremented
* if queue is full (if implemented).
* @return -@c RETURN_OK on success * @return -@c RETURN_OK on success
* -@c MessageQueueIF::FULL if queue is full * -@c MessageQueueIF::FULL if queue is full
*/ */
@ -96,21 +113,31 @@ public:
/** /**
* @brief This operation sends a message to the given destination. * @brief This operation sends a message to the given destination.
* @details It directly uses the sendMessage call of the MessageQueueSender parent, but passes its * @details
* queue id as "sentFrom" parameter. * It directly uses the sendMessage call of the MessageQueueSender parent,
* @param sendTo This parameter specifies the message queue id of the destination message queue. * but passes its queue id as "sentFrom" parameter.
* @param message A pointer to a previously created message, which is sent. * @param sendTo
* @param ignoreFault If set to true, the internal software fault counter is not incremented if queue is full. * This parameter specifies the message queue id of the destination
* message queue.
* @param message
* A pointer to a previously created message, which is sent.
* @param ignoreFault
* If set to true, the internal software fault counter is not incremented
* if queue is full.
*/ */
virtual ReturnValue_t sendMessage( MessageQueueId_t sendTo, virtual ReturnValue_t sendMessage( MessageQueueId_t sendTo,
MessageQueueMessageIF* message, bool ignoreFault = false ) = 0; MessageQueueMessageIF* message, bool ignoreFault = false ) = 0;
/** /**
* @brief The sendToDefaultFrom method sends a queue message to the default destination. * @brief The sendToDefaultFrom method sends a queue message
* @details In all other aspects, it works identical to the sendMessage method. * to the default destination.
* @param message This is a pointer to a previously created message, which is sent. * @details
* @param sentFrom The sentFrom information can be set to inject the sender's queue id into the message. * In all other aspects, it works identical to the sendMessage method.
* This variable is set to zero by default. * @param message
* This is a pointer to a previously created message, which is sent.
* @param sentFrom
* The sentFrom information can be set to inject the sender's queue id
* into the message. This variable is set to zero by default.
* @return -@c RETURN_OK on success * @return -@c RETURN_OK on success
* -@c MessageQueueIF::FULL if queue is full * -@c MessageQueueIF::FULL if queue is full
*/ */
@ -118,19 +145,21 @@ public:
MessageQueueId_t sentFrom, bool ignoreFault = false ) = 0; MessageQueueId_t sentFrom, bool ignoreFault = false ) = 0;
/** /**
* @brief This operation sends a message to the default destination. * @brief This operation sends a message to the default destination.
* @details As in the sendMessage method, this function uses the sendToDefault call of the * @details
* Implementation class and adds its queue id as "sentFrom" information. * As in the sendMessage method, this function uses the sendToDefault
* call of the Implementation class and adds its queue id as
* "sentFrom" information.
* @param message A pointer to a previously created message, which is sent. * @param message A pointer to a previously created message, which is sent.
* @return -@c RETURN_OK on success * @return -@c RETURN_OK on success
* -@c MessageQueueIF::FULL if queue is full * -@c MessageQueueIF::FULL if queue is full
*/ */
virtual ReturnValue_t sendToDefault( MessageQueueMessageIF* message ) = 0; virtual ReturnValue_t sendToDefault( MessageQueueMessageIF* message ) = 0;
/** /**
* \brief This method is a simple setter for the default destination. * @brief This method is a simple setter for the default destination.
*/ */
virtual void setDefaultDestination(MessageQueueId_t defaultDestination) = 0; virtual void setDefaultDestination(MessageQueueId_t defaultDestination) = 0;
/** /**
* \brief This method is a simple getter for the default destination. * @brief This method is a simple getter for the default destination.
*/ */
virtual MessageQueueId_t getDefaultDestination() const = 0; virtual MessageQueueId_t getDefaultDestination() const = 0;
@ -139,4 +168,4 @@ public:
#endif /* FRAMEWORK_IPC_MESSAGEQUEUEIF_H_ */ #endif /* FSFW_IPC_MESSAGEQUEUEIF_H_ */

View File

@ -1,4 +1,4 @@
#include "../ipc/MessageQueueMessage.h" #include "MessageQueueMessage.h"
#include "../serviceinterface/ServiceInterfaceStream.h" #include "../serviceinterface/ServiceInterfaceStream.h"
#include "../globalfunctions/arrayprinter.h" #include "../globalfunctions/arrayprinter.h"
#include <cstring> #include <cstring>

View File

@ -1,5 +1,5 @@
#ifndef FRAMEWORK_IPC_MESSAGEQUEUEMESSAGE_H_ #ifndef FSFW_IPC_MESSAGEQUEUEMESSAGE_H_
#define FRAMEWORK_IPC_MESSAGEQUEUEMESSAGE_H_ #define FSFW_IPC_MESSAGEQUEUEMESSAGE_H_
#include "../ipc/MessageQueueMessageIF.h" #include "../ipc/MessageQueueMessageIF.h"
#include "../ipc/MessageQueueSenderIF.h" #include "../ipc/MessageQueueSenderIF.h"
@ -147,4 +147,4 @@ public:
void print(bool printWholeMessage); void print(bool printWholeMessage);
}; };
#endif /* MESSAGEQUEUEMESSAGE_H_ */ #endif /* FSFW_IPC_MESSAGEQUEUEMESSAGE_H_ */

View File

@ -29,8 +29,10 @@ public:
/** /**
* @brief With this method, the whole content and the message * @brief With this method, the whole content and the message
* size is set to zero. Implementations should also take care * size is set to zero.
* to clear data which is stored indirectly (e.g. storage data). * @details
* Implementations should also take care to clear data which is stored
* indirectly (e.g. storage data).
*/ */
virtual void clear() = 0; virtual void clear() = 0;

View File

@ -1,7 +1,7 @@
#ifndef FRAMEWORK_IPC_MUTEXHELPER_H_ #ifndef FRAMEWORK_IPC_MUTEXHELPER_H_
#define FRAMEWORK_IPC_MUTEXHELPER_H_ #define FRAMEWORK_IPC_MUTEXHELPER_H_
#include "../ipc/MutexFactory.h" #include "MutexFactory.h"
#include "../serviceinterface/ServiceInterfaceStream.h" #include "../serviceinterface/ServiceInterfaceStream.h"
class MutexHelper { class MutexHelper {
@ -16,8 +16,8 @@ public:
<< timeoutMs << " milliseconds!" << std::endl; << timeoutMs << " milliseconds!" << std::endl;
} }
else if(status != HasReturnvaluesIF::RETURN_OK){ else if(status != HasReturnvaluesIF::RETURN_OK){
sif::error << "MutexHelper: Lock of Mutex failed with code " << sif::error << "MutexHelper: Lock of Mutex failed with code "
status << std::endl; << status << std::endl;
} }
} }

View File

@ -1,7 +1,7 @@
#ifndef FRAMEWORK_IPC_QUEUEFACTORY_H_ #ifndef FRAMEWORK_IPC_QUEUEFACTORY_H_
#define FRAMEWORK_IPC_QUEUEFACTORY_H_ #define FRAMEWORK_IPC_QUEUEFACTORY_H_
#include "../ipc/MessageQueueIF.h" #include "MessageQueueIF.h"
#include <cstdint> #include <cstdint>
/** /**
* Creates message queues. * Creates message queues.

View File

@ -1,4 +1,4 @@
#include "../../osal/FreeRTOS/MessageQueue.h" #include "MessageQueue.h"
#include "../../serviceinterface/ServiceInterfaceStream.h" #include "../../serviceinterface/ServiceInterfaceStream.h"
@ -10,13 +10,13 @@
MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize): MessageQueue::MessageQueue(size_t messageDepth, size_t maxMessageSize):
maxMessageSize(maxMessageSize) { maxMessageSize(maxMessageSize) {
handle = xQueueCreate(messageDepth, maxMessageSize); handle = xQueueCreate(messageDepth, maxMessageSize);
if (handle == NULL) { if (handle == nullptr) {
sif::error << "MessageQueue: Creation failed" << std::endl; sif::error << "MessageQueue::MessageQueue Creation failed" << std::endl;
} }
} }
MessageQueue::~MessageQueue() { MessageQueue::~MessageQueue() {
if (handle != NULL) { if (handle != nullptr) {
vQueueDelete(handle); vQueueDelete(handle);
} }
} }
@ -126,7 +126,7 @@ ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
BaseType_t result = pdFALSE; BaseType_t result = pdFALSE;
QueueHandle_t destination = nullptr; QueueHandle_t destination = nullptr;
if(sendTo == MessageQueueIF::NO_QUEUE) { if(sendTo == MessageQueueIF::NO_QUEUE or sendTo == 0x00) {
return MessageQueueIF::DESTINVATION_INVALID; return MessageQueueIF::DESTINVATION_INVALID;
} }
else { else {

View File

@ -1,5 +1,5 @@
#ifndef MESSAGEQUEUE_H_ #ifndef FSFW_OSAL_FREERTOS_MESSAGEQUEUE_H_
#define MESSAGEQUEUE_H_ #define FSFW_OSAL_FREERTOS_MESSAGEQUEUE_H_
#include "../../internalError/InternalErrorReporterIF.h" #include "../../internalError/InternalErrorReporterIF.h"
#include "../../ipc/MessageQueueIF.h" #include "../../ipc/MessageQueueIF.h"
@ -43,11 +43,12 @@ public:
/** /**
* @brief The constructor initializes and configures the message queue. * @brief The constructor initializes and configures the message queue.
* @details * @details
* By making use of the according operating system call, a message queue is created * By making use of the according operating system call, a message queue
* and initialized. The message depth - the maximum number of messages to be * is created and initialized. The message depth - the maximum number of
* buffered - may be set with the help of a parameter, whereas the message size is * messages to be buffered - may be set with the help of a parameter,
* automatically set to the maximum message queue message size. The operating system * whereas the message size is automatically set to the maximum message
* sets the message queue id, or i case of failure, it is set to zero. * queue message size. The operating system sets the message queue id, or
* in case of failure, it is set to zero.
* @param message_depth * @param message_depth
* The number of messages to be buffered before passing an error to the * The number of messages to be buffered before passing an error to the
* sender. Default is three. * sender. Default is three.
@ -76,103 +77,39 @@ public:
*/ */
void switchSystemContext(CallContext callContext); void switchSystemContext(CallContext callContext);
/** /** MessageQueueIF implementation */
* @brief This operation sends a message to the given destination.
* @details It directly uses the sendMessage call of the MessageQueueSender parent, but passes its
* queue id as "sentFrom" parameter.
* @param sendTo This parameter specifies the message queue id of the destination message queue.
* @param message A pointer to a previously created message, which is sent.
* @param ignoreFault If set to true, the internal software fault counter is not incremented if queue is full.
*/
ReturnValue_t sendMessage(MessageQueueId_t sendTo, ReturnValue_t sendMessage(MessageQueueId_t sendTo,
MessageQueueMessageIF* message, bool ignoreFault = false) override; MessageQueueMessageIF* message, bool ignoreFault = false) override;
/**
* @brief This operation sends a message to the default destination.
* @details As in the sendMessage method, this function uses the sendToDefault call of the
* MessageQueueSender parent class and adds its queue id as "sentFrom" information.
* @param message A pointer to a previously created message, which is sent.
*/
ReturnValue_t sendToDefault(MessageQueueMessageIF* message) override;
/**
* @brief This operation sends a message to the last communication partner.
* @details This operation simplifies answering an incoming message by using the stored
* lastParnter information as destination. If there was no message received yet
* (i.e. lastPartner is zero), an error code is returned.
* @param message A pointer to a previously created message, which is sent.
*/
ReturnValue_t reply(MessageQueueMessageIF* message) override;
/** ReturnValue_t sendToDefault(MessageQueueMessageIF* message) override;
* @brief With the sendMessage call, a queue message is sent to a receiving queue.
* @details This method takes the message provided, adds the sentFrom information and passes ReturnValue_t reply(MessageQueueMessageIF* message) override;
* it on to the destination provided with an operating system call. The OS's return
* value is returned.
* @param sendTo This parameter specifies the message queue id to send the message to.
* @param message This is a pointer to a previously created message, which is sent.
* @param sentFrom The sentFrom information can be set to inject the sender's queue id into the message.
* This variable is set to zero by default.
* @param ignoreFault If set to true, the internal software fault counter is not incremented if queue is full.
*/
virtual ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, virtual ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo,
MessageQueueMessageIF* message, MessageQueueMessageIF* message,
MessageQueueId_t sentFrom = NO_QUEUE, MessageQueueId_t sentFrom = NO_QUEUE,
bool ignoreFault = false) override; bool ignoreFault = false) override;
/**
* @brief The sendToDefault method sends a queue message to the default destination.
* @details In all other aspects, it works identical to the sendMessage method.
* @param message This is a pointer to a previously created message, which is sent.
* @param sentFrom The sentFrom information can be set to inject the sender's queue id into the message.
* This variable is set to zero by default.
*/
virtual ReturnValue_t sendToDefaultFrom( MessageQueueMessageIF* message, virtual ReturnValue_t sendToDefaultFrom( MessageQueueMessageIF* message,
MessageQueueId_t sentFrom = NO_QUEUE, MessageQueueId_t sentFrom = NO_QUEUE,
bool ignoreFault = false) override; bool ignoreFault = false) override;
/**
* @brief This function reads available messages from the message queue and returns the sender.
* @details It works identically to the other receiveMessage call, but in addition returns the
* sender's queue id.
* @param message A pointer to a message in which the received data is stored.
* @param receivedFrom A pointer to a queue id in which the sender's id is stored.
*/
ReturnValue_t receiveMessage(MessageQueueMessageIF* message, ReturnValue_t receiveMessage(MessageQueueMessageIF* message,
MessageQueueId_t *receivedFrom) override; MessageQueueId_t *receivedFrom) override;
/**
* @brief This function reads available messages from the message queue.
* @details If data is available it is stored in the passed message pointer. The message's
* original content is overwritten and the sendFrom information is stored in the
* lastPartner attribute. Else, the lastPartner information remains untouched, the
* message's content is cleared and the function returns immediately.
* @param message A pointer to a message in which the received data is stored.
*/
ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override; ReturnValue_t receiveMessage(MessageQueueMessageIF* message) override;
/**
* Deletes all pending messages in the queue.
* @param count The number of flushed messages.
* @return RETURN_OK on success.
*/
ReturnValue_t flush(uint32_t* count);
/**
* @brief This method returns the message queue id of the last communication partner.
*/
MessageQueueId_t getLastPartner() const;
/**
* @brief This method returns the message queue id of this class's message queue.
*/
MessageQueueId_t getId() const;
/** ReturnValue_t flush(uint32_t* count) override;
* @brief This method is a simple setter for the default destination.
*/ MessageQueueId_t getLastPartner() const override;
void setDefaultDestination(MessageQueueId_t defaultDestination);
/** MessageQueueId_t getId() const override;
* @brief This method is a simple getter for the default destination.
*/ void setDefaultDestination(MessageQueueId_t defaultDestination) override;
MessageQueueId_t getDefaultDestination() const;
MessageQueueId_t getDefaultDestination() const override;
bool isDefaultDestinationSet() const override;
bool isDefaultDestinationSet() const;
protected: protected:
/** /**
* @brief Implementation to be called from any send Call within * @brief Implementation to be called from any send Call within
@ -205,8 +142,8 @@ private:
MessageQueueId_t defaultDestination = 0; MessageQueueId_t defaultDestination = 0;
MessageQueueId_t lastPartner = 0; MessageQueueId_t lastPartner = 0;
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;
}; };
#endif /* MESSAGEQUEUE_H_ */ #endif /* FSFW_OSAL_FREERTOS_MESSAGEQUEUE_H_ */