2020-11-17 19:35:37 +01:00
|
|
|
#ifndef FSFW_OSAL_RTEMS_MESSAGEQUEUE_H_
|
|
|
|
#define FSFW_OSAL_RTEMS_MESSAGEQUEUE_H_
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2022-04-11 11:19:38 +02:00
|
|
|
#include <fsfw/ipc/MessageQueueBase.h>
|
2022-02-02 10:29:30 +01:00
|
|
|
#include "RtemsBasic.h"
|
2021-07-16 12:22:14 +02:00
|
|
|
#include "fsfw/internalerror/InternalErrorReporterIF.h"
|
|
|
|
#include "fsfw/ipc/MessageQueueIF.h"
|
|
|
|
#include "fsfw/ipc/MessageQueueMessage.h"
|
2022-03-22 17:49:22 +01:00
|
|
|
#include "fsfw/ipc/definitions.h"
|
2016-06-15 23:48:41 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief This class manages sending and receiving of message queue messages.
|
|
|
|
*
|
|
|
|
* @details Message queues are used to pass asynchronous messages between processes.
|
2022-02-02 10:29:30 +01:00
|
|
|
* They work like post boxes, where all incoming messages are stored in
|
|
|
|
*FIFO order. This class creates a new receiving queue and provides methods to fetch received
|
|
|
|
*messages. Being a child of MessageQueueSender, this class also provides methods to send a message
|
|
|
|
*to a user-defined or a default destination. In addition it also provides a reply method to answer
|
|
|
|
*to the queue it received its last message from. The MessageQueue should be used as "post box" for
|
|
|
|
*a single owning object. So all message queue communication is "n-to-one". For creating the queue,
|
|
|
|
*as well as sending and receiving messages, the class makes use of the operating system calls
|
|
|
|
*provided. \ingroup message_queue
|
2016-06-15 23:48:41 +02:00
|
|
|
*/
|
2022-04-11 11:19:38 +02:00
|
|
|
class MessageQueue : public MessageQueueBase {
|
2022-02-02 10:29:30 +01:00
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @brief The constructor initializes and configures the message queue.
|
|
|
|
* @details By making use of the according operating system call, a message queue is created
|
|
|
|
* and initialized. The message depth - the maximum number of messages to be
|
|
|
|
* buffered - may be set with the help of a parameter, whereas the message size
|
|
|
|
* is automatically set to the maximum message queue message size. The operating system sets the
|
|
|
|
* message queue id, or i case of failure, it is set to zero.
|
|
|
|
* @param message_depth The number of messages to be buffered before passing an error to the
|
|
|
|
* sender. Default is three.
|
|
|
|
* @param max_message_size With this parameter, the maximum message size can be adjusted.
|
|
|
|
* This should be left default.
|
|
|
|
*/
|
|
|
|
MessageQueue(size_t message_depth = 3,
|
2022-03-22 17:49:22 +01:00
|
|
|
size_t max_message_size = MessageQueueMessage::MAX_MESSAGE_SIZE,
|
|
|
|
MqArgs* args = nullptr);
|
2022-04-11 11:19:38 +02:00
|
|
|
|
|
|
|
/** Copying message queues forbidden */
|
|
|
|
MessageQueue(const MessageQueue&) = delete;
|
|
|
|
MessageQueue& operator=(const MessageQueue&) = delete;
|
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
/**
|
|
|
|
* @brief The destructor deletes the formerly created message queue.
|
|
|
|
* @details This is accomplished by using the delete call provided by the operating system.
|
|
|
|
*/
|
|
|
|
virtual ~MessageQueue();
|
|
|
|
|
2022-04-11 11:19:38 +02:00
|
|
|
// Implement non-generic MessageQueueIF functions not handled by MessageQueueBase
|
|
|
|
ReturnValue_t flush(uint32_t* count) override;
|
|
|
|
ReturnValue_t sendMessageFrom(MessageQueueId_t sendTo, MessageQueueMessageIF* message,
|
2022-02-02 10:29:30 +01:00
|
|
|
MessageQueueId_t sentFrom = NO_QUEUE,
|
2022-04-11 11:19:38 +02:00
|
|
|
bool ignoreFault = false) override;
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
private:
|
|
|
|
/**
|
|
|
|
* \brief This attribute stores a reference to the internal error reporter for reporting full
|
|
|
|
* queues. \details In the event of a full destination queue, the reporter will be notified. The
|
|
|
|
* reference is set by lazy loading
|
|
|
|
*/
|
|
|
|
InternalErrorReporterIF* internalErrorReporter;
|
2018-07-12 16:29:32 +02:00
|
|
|
|
2022-02-02 10:29:30 +01:00
|
|
|
static uint16_t queueCounter;
|
|
|
|
/**
|
|
|
|
* A method to convert an OS-specific return code to the frameworks return value concept.
|
|
|
|
* @param inValue The return code coming from the OS.
|
|
|
|
* @return The converted return value.
|
|
|
|
*/
|
|
|
|
static ReturnValue_t convertReturnCode(rtems_status_code inValue);
|
2016-06-15 23:48:41 +02:00
|
|
|
};
|
|
|
|
|
2020-11-17 19:35:37 +01:00
|
|
|
#endif /* FSFW_OSAL_RTEMS_MESSAGEQUEUE_H_ */
|