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"
|
2016-06-15 23:48:41 +02:00
|
|
|
|
2020-09-26 14:51:00 +02:00
|
|
|
/**
|
|
|
|
* @brief TODO: documentation.
|
|
|
|
*/
|
2016-06-15 23:48:41 +02:00
|
|
|
class MemoryHelper : public HasReturnvaluesIF {
|
|
|
|
public:
|
2018-07-12 16:29:32 +02:00
|
|
|
static const uint8_t INTERFACE_ID = CLASS_ID::MEMORY_HELPER;
|
2016-06-15 23:48:41 +02:00
|
|
|
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_);
|
|
|
|
|
2016-06-15 23:48:41 +02:00
|
|
|
private:
|
|
|
|
HasMemoryIF* workOnThis;
|
2018-07-12 16:29:32 +02:00
|
|
|
MessageQueueIF* queueToUse;
|
2020-09-26 14:51:00 +02:00
|
|
|
StorageManagerIF* ipcStore = nullptr;
|
2016-06-15 23:48:41 +02:00
|
|
|
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;
|
2018-07-12 16:29:32 +02:00
|
|
|
bool busy;
|
2016-06-15 23:48:41 +02:00
|
|
|
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
|
|
|
|
2016-06-15 23:48:41 +02:00
|
|
|
};
|
2020-09-26 14:51:00 +02:00
|
|
|
#endif /* FSFW_MEMORY_MEMORYHELPER_H_ */
|