fsfw/devicehandlers/CommunicationMessage.h

156 lines
4.4 KiB
C
Raw Normal View History

/**
* @file CommunicationMessage.h
*
* @date 28.02.2020
*/
#ifndef FRAMEWORK_DEVICEHANDLERS_COMMUNICATIONMESSAGE_H_
#define FRAMEWORK_DEVICEHANDLERS_COMMUNICATIONMESSAGE_H_
2020-03-03 21:20:08 +01:00
#include <framework/devicehandlers/CommunicationMessage.h>
#include <framework/ipc/MessageQueueMessage.h>
#include <framework/storagemanager/StorageManagerIF.h>
/**
* @brief Used to pass communication information between tasks
*
* @details
* Can be used to pass information like data pointers and
* data sizes between communication tasks
* like the Device Handler Comm Interfaces and Polling Tasks.
*
* Can also be used to exchange actual data if its not too large
* (e.g. Sensor values).
*
*/
class CommunicationMessage: public MessageQueueMessage {
public:
2020-03-03 21:20:08 +01:00
enum messageType {
SEND_DATA_FROM_POINTER,
SEND_DATA_FROM_IPC_STORE,
SEND_DATA_RAW,
REPLY_DATA_FROM_POINTER,
REPLY_DATA_IPC_STORE,
REPLY_DATA_RAW,
FAULTY,
};
//Add other messageIDs here if necessary.
static const uint8_t COMMUNICATION_MESSAGE_SIZE = HEADER_SIZE + 4 * sizeof(uint32_t);
CommunicationMessage();
virtual ~CommunicationMessage();
/**
* Send requests with pointer to the data to be sent and send data length
2020-03-03 21:20:08 +01:00
* @param address Target Address, first four bytes
* @param dataLen Length of data to send, next four bytes
* @param data Pointer to data to send
*
*/
void setSendRequestFromPointer(uint32_t address, uint32_t dataLen, const uint8_t * data);
/**
* Send requests with a store ID, using the IPC store
* @param address Target Address, first four bytes
* @param storeId Store ID in the IPC store
*
*/
2020-03-03 21:20:08 +01:00
void setSendRequestFromIpcStore(uint32_t address, store_address_t storeId);
/**
* Send requests with data length and data in message (max. 4 bytes)
* @param address Target Address, first four bytes
* @param dataLen Length of data to send, next four bytes
* @param data Pointer to data to send
*
*/
void setSendRequestRaw(uint32_t address, uint32_t length);
/**
* Data message with data stored in IPC store
2020-03-03 21:20:08 +01:00
* @param address Target Address, first four bytes
* @param length
* @param storeId
*/
2020-03-03 21:20:08 +01:00
void setDataReplyFromIpcStore(uint32_t address, store_address_t storeId);
/**
* Data reply with data stored in buffer, passing the pointer to
* the buffer and the data size
* @param address Target Address, first four bytes
* @param dataLen Length of data to send, next four bytes
* @param data Pointer to the data
*/
void setDataReplyFromPointer(uint32_t address, uint32_t dataLen, uint8_t * data);
/**
* Data message with data stored in actual message.
* 4 byte datafield is intialized with 0.
2020-03-03 21:20:08 +01:00
* Set data with specific setter functions below.
* Can also be used to supply information at which position the raw data should be stored
* in a receive buffer.
*/
2020-03-03 21:20:08 +01:00
void setDataReplyRaw(uint32_t address, uint32_t length, uint16_t receiveBufferPosition = 0);
/**
* First four bytes of message data
* @param address
*/
void setAddress(uint32_t address);
/**
* Message Type is stored as the fifth byte of the message data
* @param status
*/
void setMessageType(messageType status);
messageType getMessageType();
void setMessageId(uint8_t messageId);
messageType getMessageId();
2020-03-03 21:20:08 +01:00
/*
* The following functions can be used to
* set the data field (4 bytes possible);
*/
void setDataByte1(uint8_t byte1);
void setDataByte2(uint8_t byte2);
void setDataByte3(uint8_t byte3);
void setDataByte4(uint8_t byte4);
void setDataUINT16_1(uint16_t data1);
void setDataUINT16_2(uint16_t data2);
void setData(uint32_t data);
2020-03-03 21:20:08 +01:00
/**
* Stored in Bytes 13-16 of message data
* @param length
*/
void setDataLen(uint32_t length);
2020-03-03 21:20:08 +01:00
/**
* Stored in last four bytes (Bytes 17-20) of message data
* @param sendData
*/
void setDataPointer(const void * data);
2020-03-03 21:20:08 +01:00
/**
* Buffer Position is stored as the seventh and eigth byte of
* the message, so the receive buffer can't be larger than sizeof(uint16_t) for now.
2020-03-03 21:20:08 +01:00
* @param bufferPosition
*/
void setReceiveBufferPosition(uint16_t bufferPosition);
void setStoreId(store_address_t storeId);
/**
* Clear the message
*/
void clearCommunicationMessage();
private:
2020-03-03 21:20:08 +01:00
bool uninitialized; //!< Could be used to warn if data has not been set.
2020-03-03 21:20:08 +01:00
};
#endif /* FRAMEWORK_DEVICEHANDLERS_COMMUNICATIONMESSAGE_H_ */