thoughts on message queuee message
new interface. What if there are MQ messages with different sizes? -> generic interface furthermore, maybe command message should be refactored to operate on a mq message instead of implementing it
This commit is contained in:
@ -28,7 +28,8 @@ public:
|
||||
static const Command_t REPLY_REJECTED = MAKE_COMMAND_ID( 0xD1 );
|
||||
|
||||
/**
|
||||
* This is the size of a message as it is seen by the MessageQueue
|
||||
* This is the size of a message as it is seen by the MessageQueue.
|
||||
* 14 of the 24 available MessageQueueMessage bytes are used.
|
||||
*/
|
||||
static const size_t COMMAND_MESSAGE_SIZE = HEADER_SIZE
|
||||
+ sizeof(Command_t) + 2 * sizeof(uint32_t);
|
||||
|
@ -1,6 +1,7 @@
|
||||
#ifndef MESSAGEQUEUEMESSAGE_H_
|
||||
#define MESSAGEQUEUEMESSAGE_H_
|
||||
|
||||
#include <framework/ipc/MessageQueueMessageIF.h>
|
||||
#include <framework/ipc/MessageQueueSenderIF.h>
|
||||
#include <stddef.h>
|
||||
|
||||
@ -23,7 +24,7 @@
|
||||
* receive messages from other tasks.
|
||||
* @ingroup message_queue
|
||||
*/
|
||||
class MessageQueueMessage {
|
||||
class MessageQueueMessage: public MessageQueueMessageIF {
|
||||
public:
|
||||
/**
|
||||
* @brief The class is initialized empty with this constructor.
|
||||
@ -43,6 +44,7 @@ public:
|
||||
* MAX_MESSAGE_SIZE and larger than MIN_MESSAGE_SIZE.
|
||||
*/
|
||||
MessageQueueMessage(uint8_t* data, size_t size);
|
||||
|
||||
/**
|
||||
* @brief The size information of each message is stored in this attribute.
|
||||
* @details
|
||||
|
44
ipc/MessageQueueMessageIF.h
Normal file
44
ipc/MessageQueueMessageIF.h
Normal file
@ -0,0 +1,44 @@
|
||||
#ifndef FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_
|
||||
#define FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_
|
||||
#include <framework/ipc/MessageQueueSenderIF.h>
|
||||
#include <cstddef>
|
||||
|
||||
class MessageQueueMessageIF {
|
||||
public:
|
||||
virtual ~MessageQueueMessageIF() {};
|
||||
|
||||
/**
|
||||
* @brief With this method, the whole content and the message
|
||||
* size is set to zero.
|
||||
*/
|
||||
virtual void clear() = 0;
|
||||
/**
|
||||
* @brief This is a debug method that prints the content
|
||||
* (till messageSize) to the debug output.
|
||||
*/
|
||||
virtual void print() = 0;
|
||||
virtual const uint8_t* getBuffer() const = 0;
|
||||
/**
|
||||
* @brief This method is used to get the complete data of the message.
|
||||
*/
|
||||
virtual uint8_t* getBuffer() = 0;
|
||||
/**
|
||||
* @brief This method is used to set the sender's message queue id
|
||||
* information prior to sending the message.
|
||||
* @param setId The message queue id that identifies the sending message queue.
|
||||
*/
|
||||
virtual void setSender(MessageQueueId_t setId) = 0;
|
||||
/**
|
||||
* @brief This helper function is used by the MessageQueue class to
|
||||
* check the size of an incoming message.
|
||||
* @details
|
||||
* The method must be overwritten by child classes if size checks shall
|
||||
* be more strict.
|
||||
* @return The default implementation returns HEADER_SIZE.
|
||||
*/
|
||||
virtual size_t getMinimumMessageSize() = 0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif /* FRAMEWORK_IPC_MESSAGEQUEUEMESSAGEIF_H_ */
|
Reference in New Issue
Block a user