fsfw/src/fsfw/memory/MemoryHelper.h

46 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_
#include "../ipc/CommandMessage.h"
2022-02-02 10:29:30 +01:00
#include "../ipc/MessageQueueIF.h"
2022-08-16 12:48:22 +02:00
#include "../returnvalues/returnvalue.h"
2020-08-13 20:53:35 +02:00
#include "../storagemanager/StorageManagerIF.h"
2022-02-02 10:29:30 +01:00
#include "AcceptsMemoryMessagesIF.h"
2020-09-26 14:51:00 +02:00
/**
* @brief TODO: documentation.
*/
2022-08-15 20:28:16 +02:00
class MemoryHelper {
2022-02-02 10:29:30 +01:00
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
2022-02-02 10:29:30 +01:00
MemoryHelper(HasMemoryIF* workOnThis, MessageQueueIF* useThisQueue);
~MemoryHelper();
2020-09-26 14:51:00 +02:00
2022-02-02 10:29:30 +01:00
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_);
2020-09-26 14:51:00 +02:00
2022-02-02 10:29:30 +01:00
private:
HasMemoryIF* workOnThis;
MessageQueueIF* queueToUse;
StorageManagerIF* ipcStore = nullptr;
store_address_t ipcAddress;
Command_t lastCommand;
MessageQueueId_t lastSender = MessageQueueIF::NO_QUEUE;
uint8_t* reservedSpaceInIPC = nullptr;
bool busy;
void handleMemoryLoad(CommandMessage* message);
void handleMemoryCheckOrDump(CommandMessage* message);
ReturnValue_t initialize();
};
2020-09-26 14:51:00 +02:00
#endif /* FSFW_MEMORY_MEMORYHELPER_H_ */