doc for mqm improved
This commit is contained in:
parent
8ff6506ad9
commit
47aa9ddcc3
@ -152,3 +152,11 @@ void CommandMessage::setSender(MessageQueueId_t setId) {
|
||||
const uint8_t* CommandMessage::getBuffer() const {
|
||||
return internalMessage->getBuffer();
|
||||
}
|
||||
|
||||
uint8_t* CommandMessage::getData() {
|
||||
return internalMessage->getData();
|
||||
}
|
||||
|
||||
const uint8_t* CommandMessage::getData() const {
|
||||
return internalMessage->getData();
|
||||
}
|
||||
|
@ -1,16 +1,25 @@
|
||||
#ifndef FRAMEWORK_IPC_COMMANDMESSAGE_H_
|
||||
#define FRAMEWORK_IPC_COMMANDMESSAGE_H_
|
||||
|
||||
#include <framework/ipc/MessageQueueMessage.h>
|
||||
#include <framework/ipc/FwMessageTypes.h>
|
||||
#include <config/ipc/MissionMessageTypes.h>
|
||||
|
||||
#include <framework/ipc/MessageQueueMessage.h>
|
||||
|
||||
|
||||
#define MAKE_COMMAND_ID( number ) ((MESSAGE_ID << 8) + (number))
|
||||
typedef uint16_t Command_t;
|
||||
|
||||
/**
|
||||
* @brief Used to pass command messages between tasks
|
||||
* @brief Used to pass command messages between tasks. Primary message type
|
||||
* for IPC. Contains sender, 2-byte command field, and 2 4-byte
|
||||
* parameters.
|
||||
* @details
|
||||
* It operates on an external memory which is contained inside a
|
||||
* MessageQueueMessage by taking its address.
|
||||
* This allows for a more flexible designs of message implementations.
|
||||
* The pointer can be passed to different message implementations without
|
||||
* the need of unnecessary copying.
|
||||
* @author Bastian Baetz
|
||||
*/
|
||||
class CommandMessage: public MessageQueueMessageIF {
|
||||
@ -53,13 +62,10 @@ public:
|
||||
uint32_t parameter1, uint32_t parameter2);
|
||||
|
||||
/**
|
||||
* Default Destructor
|
||||
* @brief Default Destructor
|
||||
*/
|
||||
virtual ~CommandMessage() {
|
||||
}
|
||||
virtual ~CommandMessage() {}
|
||||
|
||||
uint8_t * getBuffer() override;
|
||||
const uint8_t * getBuffer() const override;
|
||||
/**
|
||||
* Read the DeviceHandlerCommand_t that is stored in the message,
|
||||
* usually used after receiving.
|
||||
@ -68,53 +74,54 @@ public:
|
||||
*/
|
||||
Command_t getCommand() const;
|
||||
|
||||
/**
|
||||
* @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.
|
||||
/*
|
||||
* MessageQueueMessageIF functions, which generally just call the
|
||||
* respective functions of the internal message
|
||||
*/
|
||||
uint8_t * getBuffer() override;
|
||||
const uint8_t * getBuffer() const override;
|
||||
void setSender(MessageQueueId_t setId) override;
|
||||
|
||||
MessageQueueId_t getSender() const override;
|
||||
uint8_t * getData() override;
|
||||
const uint8_t* getData() const override;
|
||||
size_t getMinimumMessageSize() const override;
|
||||
|
||||
/**
|
||||
* Extract message ID, which is the first byte of the command ID.
|
||||
* @return
|
||||
*/
|
||||
uint8_t getMessageType() const;
|
||||
/**
|
||||
* Set the DeviceHandlerCOmmand_t of the message
|
||||
*
|
||||
* Set the command type of the message
|
||||
* @param the Command to be sent
|
||||
*/
|
||||
void setCommand(Command_t command);
|
||||
|
||||
/**
|
||||
* Get the first parameter of the message
|
||||
*
|
||||
* @return the first Parameter of the message
|
||||
*/
|
||||
uint32_t getParameter() const;
|
||||
|
||||
/**
|
||||
* Set the first parameter of the message
|
||||
*
|
||||
* @param the first parameter of the message
|
||||
*/
|
||||
void setParameter(uint32_t parameter1);
|
||||
|
||||
/**
|
||||
* Get the second parameter of the message
|
||||
*
|
||||
* @return the second Parameter of the message
|
||||
*/
|
||||
uint32_t getParameter2() const;
|
||||
|
||||
/**
|
||||
* Set the second parameter of the message
|
||||
*
|
||||
* @param the second parameter of the message
|
||||
*/
|
||||
void setParameter2(uint32_t parameter2);
|
||||
|
||||
void clear() override;
|
||||
|
||||
/**
|
||||
* Set the command to CMD_NONE and try to find
|
||||
* the correct class to handle a more detailed
|
||||
@ -126,6 +133,7 @@ public:
|
||||
*
|
||||
*/
|
||||
void clearCommandMessage();
|
||||
void clear() override;
|
||||
|
||||
/**
|
||||
* check if a message was cleared
|
||||
@ -134,7 +142,6 @@ public:
|
||||
*/
|
||||
bool isClearedCommandMessage();
|
||||
|
||||
|
||||
/**
|
||||
* Sets the command to REPLY_REJECTED with parameter UNKNOWN_COMMAND.
|
||||
* Is needed quite often, so we better code it once only.
|
||||
@ -142,9 +149,14 @@ public:
|
||||
void setToUnknownCommand();
|
||||
void setReplyRejected(ReturnValue_t reason,
|
||||
Command_t initialCommand = CMD_NONE);
|
||||
size_t getMinimumMessageSize() const override;
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Pointer to the message containing the data.
|
||||
* @details
|
||||
* The command message does not actually own the memory containing a
|
||||
* message, it just oprates on it via a pointer to a message queue message.
|
||||
*/
|
||||
MessageQueueMessage* internalMessage;
|
||||
};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#ifndef MESSAGEQUEUEMESSAGE_H_
|
||||
#define MESSAGEQUEUEMESSAGE_H_
|
||||
#ifndef FRAMEWORK_IPC_MESSAGEQUEUEMESSAGE_H_
|
||||
#define FRAMEWORK_IPC_MESSAGEQUEUEMESSAGE_H_
|
||||
|
||||
#include <framework/ipc/MessageQueueMessageIF.h>
|
||||
#include <framework/ipc/MessageQueueSenderIF.h>
|
||||
@ -8,7 +8,6 @@
|
||||
/**
|
||||
* @brief This class is the representation and data organizer
|
||||
* for interprocess messages.
|
||||
*
|
||||
* @details
|
||||
* To facilitate and standardize interprocess communication, this class was
|
||||
* created to handle a lightweight "interprocess message protocol".
|
||||
@ -28,12 +27,14 @@ class MessageQueueMessage: public MessageQueueMessageIF {
|
||||
public:
|
||||
/**
|
||||
* @brief The class is initialized empty with this constructor.
|
||||
* @details The messageSize attribute is set to the header's size and the
|
||||
* whole content is set to zero.
|
||||
* @details
|
||||
* The messageSize attribute is set to the header's size and the whole
|
||||
* content is set to zero.
|
||||
*/
|
||||
MessageQueueMessage();
|
||||
/**
|
||||
* @brief With this constructor the class is initialized with the given content.
|
||||
* @brief With this constructor the class is initialized with
|
||||
* the given content.
|
||||
* @details
|
||||
* If the passed message size fits into the buffer, the passed data is
|
||||
* copied to the internal buffer and the messageSize information is set.
|
||||
@ -46,7 +47,14 @@ public:
|
||||
MessageQueueMessage(uint8_t* data, size_t size);
|
||||
|
||||
/**
|
||||
* @brief The size information of each message is stored in this attribute.
|
||||
* @brief As no memory is allocated in this class,
|
||||
* the destructor is empty.
|
||||
*/
|
||||
virtual ~MessageQueueMessage();
|
||||
|
||||
/**
|
||||
* @brief The size information of each message is stored in
|
||||
* this attribute.
|
||||
* @details
|
||||
* It is public to simplify usage and to allow for passing the size
|
||||
* address as a pointer. Care must be taken when inheriting from this class,
|
||||
@ -59,19 +67,26 @@ public:
|
||||
*/
|
||||
size_t messageSize;
|
||||
/**
|
||||
* @brief This constant defines the maximum size of the data content, excluding the header.
|
||||
* @details It may be changed if necessary, but in general should be kept as small as possible.
|
||||
* @brief This constant defines the maximum size of the data content,
|
||||
* excluding the header.
|
||||
* @details
|
||||
* It may be changed if necessary, but in general should be kept
|
||||
* as small as possible.
|
||||
*/
|
||||
static const size_t MAX_DATA_SIZE = 24;
|
||||
/**
|
||||
* @brief This constants defines the size of the header, which is added to every message.
|
||||
* @brief This constants defines the size of the header,
|
||||
* which is added to every message.
|
||||
*/
|
||||
static const size_t HEADER_SIZE = sizeof(MessageQueueId_t);
|
||||
/**
|
||||
* @brief This constant defines the maximum total size in bytes of a sent message.
|
||||
* @details It is the sum of the maximum data and the header size. Be aware that this constant
|
||||
* is used to define the buffer sizes for every message queue in the system. So, a change
|
||||
* here may have significant impact on the required resources.
|
||||
* @brief This constant defines the maximum total size in bytes
|
||||
* of a sent message.
|
||||
* @details
|
||||
* It is the sum of the maximum data and the header size. Be aware that
|
||||
* this constant is used to define the buffer sizes for every message
|
||||
* queue in the system. So, a change here may have significant impact on
|
||||
* the required resources.
|
||||
*/
|
||||
static const size_t MAX_MESSAGE_SIZE = MAX_DATA_SIZE + HEADER_SIZE;
|
||||
/**
|
||||
@ -81,58 +96,64 @@ public:
|
||||
static const size_t MIN_MESSAGE_SIZE = HEADER_SIZE;
|
||||
private:
|
||||
/**
|
||||
* @brief This is the internal buffer that contains the actual message data.
|
||||
* @brief This is the internal buffer that contains the
|
||||
* actual message data.
|
||||
*/
|
||||
uint8_t internalBuffer[MAX_MESSAGE_SIZE];
|
||||
public:
|
||||
/**
|
||||
* @brief As no memory is allocated in this class, the destructor is empty.
|
||||
* @brief This method is used to get the complete data of the message.
|
||||
*/
|
||||
virtual ~MessageQueueMessage();
|
||||
const uint8_t* getBuffer() const override;
|
||||
/**
|
||||
* @brief This method is used to get the complete data of the message.
|
||||
*/
|
||||
const uint8_t* getBuffer() const;
|
||||
/**
|
||||
* @brief This method is used to get the complete data of the message.
|
||||
*/
|
||||
uint8_t* getBuffer();
|
||||
uint8_t* getBuffer() override;
|
||||
/**
|
||||
* @brief This method is used to fetch the data content of the message.
|
||||
* @details It shall be used by child classes to add data at the right position.
|
||||
* @details
|
||||
* It shall be used by child classes to add data at the right position.
|
||||
*/
|
||||
const uint8_t* getData() const;
|
||||
const uint8_t* getData() const override;
|
||||
/**
|
||||
* @brief This method is used to fetch the data content of the message.
|
||||
* @details It shall be used by child classes to add data at the right position.
|
||||
* @details
|
||||
* It shall be used by child classes to add data at the right position.
|
||||
*/
|
||||
uint8_t* getData();
|
||||
uint8_t* getData() override;
|
||||
/**
|
||||
* @brief This method is used to extract the sender's message queue id information from a
|
||||
* received message.
|
||||
* @brief This method is used to extract the sender's message
|
||||
* queue id information from a received message.
|
||||
*/
|
||||
MessageQueueId_t getSender() const;
|
||||
MessageQueueId_t getSender() const override;
|
||||
/**
|
||||
* @brief With this method, the whole content and the message size is set to zero.
|
||||
* @brief With this method, the whole content
|
||||
* and the message size is set to zero.
|
||||
*/
|
||||
void clear();
|
||||
void clear() override;
|
||||
|
||||
/**
|
||||
* @brief This is a debug method that prints the content (till messageSize) to the debug output.
|
||||
* @brief This method is used to set the sender's message queue id
|
||||
* information prior to ing the message.
|
||||
* @param setId
|
||||
* The message queue id that identifies the sending message queue.
|
||||
*/
|
||||
void print();
|
||||
void setSender(MessageQueueId_t setId) override;
|
||||
/**
|
||||
* @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.
|
||||
*/
|
||||
void setSender(MessageQueueId_t setId);
|
||||
/**
|
||||
* @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.
|
||||
* @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() const;
|
||||
virtual size_t getMinimumMessageSize() const override;
|
||||
|
||||
/**
|
||||
* @brief This is a debug method that prints the content
|
||||
* (till messageSize) to the debug output.
|
||||
*/
|
||||
void print();
|
||||
};
|
||||
|
||||
#endif /* MESSAGEQUEUEMESSAGE_H_ */
|
||||
|
@ -11,7 +11,9 @@
|
||||
* 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.. */
|
||||
* (getCommandQueue) and some other issues..
|
||||
*/
|
||||
|
||||
typedef uint32_t MessageQueueId_t;
|
||||
|
||||
class MessageQueueMessageIF {
|
||||
@ -25,14 +27,9 @@ public:
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* @brief Get read-only pointer to the raw buffer.
|
||||
* @brief Get read-only pointer to the complete data of the message.
|
||||
* @return
|
||||
*/
|
||||
virtual const uint8_t* getBuffer() const = 0;
|
||||
@ -50,8 +47,25 @@ public:
|
||||
*/
|
||||
virtual void setSender(MessageQueueId_t setId) = 0;
|
||||
|
||||
/**
|
||||
* @brief This method is used to extract the sender's message queue id
|
||||
* information from a received message.
|
||||
*/
|
||||
virtual MessageQueueId_t getSender() const = 0;
|
||||
|
||||
/**
|
||||
* @brief This method is used to fetch the data content of the message.
|
||||
* @details
|
||||
* It shall be used by child classes to add data at the right position.
|
||||
*/
|
||||
virtual const uint8_t* getData() const = 0;
|
||||
/**
|
||||
* @brief This method is used to fetch the data content of the message.
|
||||
* @details
|
||||
* It shall be used by child classes to add data at the right position.
|
||||
*/
|
||||
virtual uint8_t* getData() = 0;
|
||||
|
||||
/**
|
||||
* @brief This helper function is used by the MessageQueue class to
|
||||
* check the size of an incoming message.
|
||||
|
Loading…
Reference in New Issue
Block a user