2021-07-08 12:22:41 +02:00
|
|
|
#ifndef BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_
|
|
|
|
#define BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_
|
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
#include <filesystem>
|
|
|
|
#include <string>
|
2021-07-12 16:32:14 +02:00
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
#include "OBSWConfig.h"
|
|
|
|
#include "SdCardManager.h"
|
2021-07-08 12:32:24 +02:00
|
|
|
#include "fsfw/ipc/MessageQueueIF.h"
|
2021-07-08 12:22:41 +02:00
|
|
|
#include "fsfw/memory/HasFileSystemIF.h"
|
2022-01-17 15:58:27 +01:00
|
|
|
#include "fsfw/objectmanager/SystemObject.h"
|
|
|
|
#include "fsfw/tasks/ExecutableObjectIF.h"
|
2021-07-12 16:32:14 +02:00
|
|
|
|
2021-08-06 01:25:36 +02:00
|
|
|
class CoreController;
|
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
class FileSystemHandler : public SystemObject, public ExecutableObjectIF, public HasFileSystemIF {
|
|
|
|
public:
|
|
|
|
struct FsCommandCfg : public FileSystemArgsIF {
|
|
|
|
// Can be used to automatically use mount prefix of active SD card.
|
|
|
|
// Otherwise, the operator has to specify the full path to the mounted SD card as well.
|
|
|
|
bool useMountPrefix = false;
|
|
|
|
};
|
2021-07-19 14:34:03 +02:00
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
FileSystemHandler(object_id_t fileSystemHandler);
|
|
|
|
virtual ~FileSystemHandler();
|
2021-07-08 12:22:41 +02:00
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
ReturnValue_t performOperation(uint8_t) override;
|
2021-07-08 12:22:41 +02:00
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
ReturnValue_t initialize() override;
|
2021-07-12 17:23:32 +02:00
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
/**
|
|
|
|
* Function to get the MessageQueueId_t of the implementing object
|
|
|
|
* @return MessageQueueId_t of the object
|
|
|
|
*/
|
|
|
|
MessageQueueId_t getCommandQueue() const override;
|
|
|
|
ReturnValue_t appendToFile(const char* repositoryPath, const char* filename, const uint8_t* data,
|
|
|
|
size_t size, uint16_t packetNumber,
|
|
|
|
FileSystemArgsIF* args = nullptr) override;
|
|
|
|
ReturnValue_t createFile(const char* repositoryPath, const char* filename,
|
|
|
|
const uint8_t* data = nullptr, size_t size = 0,
|
|
|
|
FileSystemArgsIF* args = nullptr) override;
|
|
|
|
ReturnValue_t removeFile(const char* repositoryPath, const char* filename,
|
|
|
|
FileSystemArgsIF* args = nullptr) override;
|
|
|
|
ReturnValue_t createDirectory(const char* repositoryPath, const char* dirname,
|
|
|
|
bool createParentDirs, FileSystemArgsIF* args = nullptr) override;
|
|
|
|
ReturnValue_t removeDirectory(const char* repositoryPath, const char* dirname,
|
|
|
|
bool deleteRecurively = false,
|
|
|
|
FileSystemArgsIF* args = nullptr) override;
|
|
|
|
ReturnValue_t renameFile(const char* repositoryPath, const char* oldFilename,
|
|
|
|
const char* newFilename, FileSystemArgsIF* args = nullptr) override;
|
2021-07-19 14:34:03 +02:00
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
private:
|
|
|
|
CoreController* coreCtrl = nullptr;
|
|
|
|
MessageQueueIF* mq = nullptr;
|
|
|
|
std::string currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT;
|
|
|
|
static constexpr uint32_t FS_MAX_QUEUE_SIZE = config::OBSW_FILESYSTEM_HANDLER_QUEUE_SIZE;
|
2021-07-19 14:34:03 +02:00
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
SdCardManager* sdcMan = nullptr;
|
|
|
|
uint8_t opCounter = 0;
|
2021-07-19 14:34:03 +02:00
|
|
|
|
2022-01-17 15:58:27 +01:00
|
|
|
void fileSystemHandlerLoop();
|
|
|
|
void fileSystemCheckup();
|
|
|
|
std::filesystem::path getInitPath(FileSystemArgsIF* args);
|
|
|
|
void parseCfg(FsCommandCfg* cfg, bool& useMountPrefix);
|
2021-07-08 12:22:41 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* BSP_Q7S_MEMORY_FILESYSTEMMANAGER_H_ */
|