fsfw/ipc/CommandMessage.h

99 lines
2.9 KiB
C
Raw Normal View History

2020-06-07 23:38:15 +02:00
#ifndef FRAMEWORK_IPC_COMMANDMESSAGE_H_
#define FRAMEWORK_IPC_COMMANDMESSAGE_H_
#include <framework/ipc/CommandMessageBase.h>
2020-06-09 02:46:19 +02:00
#include <framework/ipc/MessageQueueMessage.h>
#include <framework/ipc/FwMessageTypes.h>
2020-02-27 19:00:51 +01:00
/**
* @brief Default command message used to pass command messages between tasks.
* Primary message type for IPC. Contains sender, 2-byte command ID
* field, and 2 4-byte parameters.
2020-06-09 02:46:19 +02:00
* @details
* It operates on an external memory which is contained inside a
* class implementing MessageQueueMessageIF by taking its address.
2020-06-09 02:46:19 +02:00
* 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.
*
* The command message is based of the generic MessageQueueMessage which
* currently has an internal message size of 28 bytes.
2020-06-07 23:38:15 +02:00
* @author Bastian Baetz
2020-02-27 19:00:51 +01:00
*/
class CommandMessage: public CommandMessageBase {
public:
/**
* This is the size of a message as it is seen by the MessageQueue.
2020-06-14 17:59:14 +02:00
* It can hold the CommandMessage header plus 2 4-byte parameters.
* 14 of the 24 available MessageQueueMessage bytes are used.
*/
static const size_t MINIMUM_COMMAND_MESSAGE_SIZE =
2020-06-14 17:59:14 +02:00
CommandMessageIF::HEADER_SIZE + 2 * sizeof(uint32_t);
/**
* Default Constructor, does not initialize anything.
*
2020-06-07 23:38:15 +02:00
* This constructor should be used when receiving a Message, as the
* content is filled by the MessageQueue.
*/
CommandMessage(MessageQueueMessageIF* receiverMessage);
/**
2020-06-07 23:38:15 +02:00
* This constructor creates a new message with all message content
* initialized
*
* @param command The DeviceHandlerCommand_t that will be sent
* @param parameter1 The first parameter
* @param parameter2 The second parameter
*/
CommandMessage(MessageQueueMessageIF* messageToSet, Command_t command,
uint32_t parameter1, uint32_t parameter2);
/**
2020-06-09 02:46:19 +02:00
* @brief Default Destructor
*/
2020-06-09 02:46:19 +02:00
virtual ~CommandMessage() {}
/** MessageQueueMessageIF functions used for minimum size check. */
2020-06-23 21:03:22 +02:00
//size_t getMinimumMessageSize() const override;
2020-06-09 02:18:39 +02:00
/**
* 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);
/**
* check if a message was cleared
*
* @return if the command is CMD_NONE
*/
bool isClearedCommandMessage();
/**
* Sets the command to REPLY_REJECTED with parameter UNKNOWN_COMMAND.
* Is needed quite often, so we better code it once only.
*/
void setToUnknownCommand();
};
#endif /* COMMANDMESSAGE_H_ */