fsfw/memory/MemoryHelper.h

50 lines
1.7 KiB
C
Raw Normal View History

2020-09-26 14:51:00 +02:00
#ifndef FSFW_MEMORY_MEMORYHELPER_H_
#define FSFW_MEMORY_MEMORYHELPER_H_
2020-08-13 20:53:35 +02:00
#include "AcceptsMemoryMessagesIF.h"
2020-09-26 14:51:00 +02:00
#include "../ipc/CommandMessage.h"
2020-08-13 20:53:35 +02:00
#include "../returnvalues/HasReturnvaluesIF.h"
#include "../storagemanager/StorageManagerIF.h"
#include "../ipc/MessageQueueIF.h"
2020-09-26 14:51:00 +02:00
/**
* @brief TODO: documentation.
*/
class MemoryHelper : public HasReturnvaluesIF {
public:
static const uint8_t INTERFACE_ID = CLASS_ID::MEMORY_HELPER;
static const ReturnValue_t UNKNOWN_CMD = MAKE_RETURN_CODE(0xE0);
static const ReturnValue_t INVALID_ADDRESS = MAKE_RETURN_CODE(0xE1);
static const ReturnValue_t INVALID_SIZE = MAKE_RETURN_CODE(0xE2);
static const ReturnValue_t STATE_MISMATCH = MAKE_RETURN_CODE(0xE3);
2020-09-26 14:51:00 +02:00
MemoryHelper(HasMemoryIF* workOnThis, MessageQueueIF* useThisQueue);
~MemoryHelper();
ReturnValue_t handleMemoryCommand(CommandMessage* message);
void completeLoad(ReturnValue_t errorCode,
const uint8_t* dataToCopy = nullptr, const size_t size = 0,
uint8_t* copyHere = nullptr);
void completeDump(ReturnValue_t errorCode,
const uint8_t* dataToCopy = nullptr, const size_t size = 0);
void swapMatrixCopy(uint8_t *out, const uint8_t *in, size_t totalSize,
uint8_t datatypeSize);
ReturnValue_t initialize(MessageQueueIF* queueToUse_);
private:
HasMemoryIF* workOnThis;
MessageQueueIF* queueToUse;
2020-09-26 14:51:00 +02:00
StorageManagerIF* ipcStore = nullptr;
store_address_t ipcAddress;
Command_t lastCommand;
2020-09-26 14:51:00 +02:00
MessageQueueId_t lastSender = MessageQueueIF::NO_QUEUE;
uint8_t* reservedSpaceInIPC = nullptr;
bool busy;
void handleMemoryLoad(CommandMessage* message);
void handleMemoryCheckOrDump(CommandMessage* message);
2018-07-13 18:28:26 +02:00
ReturnValue_t initialize();
2020-09-26 14:51:00 +02:00
};
2020-09-26 14:51:00 +02:00
#endif /* FSFW_MEMORY_MEMORYHELPER_H_ */