From a3610d28ba8c9ccfa7bdfc441f2b12c9a76ceaba Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Thu, 8 Jul 2021 12:32:24 +0200 Subject: [PATCH] contd file system handler --- bsp_q7s/memory/FileSystemHandler.cpp | 44 ++++++++++++++++++++++++++++ bsp_q7s/memory/FileSystemHandler.h | 5 +++- 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/bsp_q7s/memory/FileSystemHandler.cpp b/bsp_q7s/memory/FileSystemHandler.cpp index 7adb59fe..8dc3422b 100644 --- a/bsp_q7s/memory/FileSystemHandler.cpp +++ b/bsp_q7s/memory/FileSystemHandler.cpp @@ -1,16 +1,60 @@ #include "FileSystemHandler.h" #include "fsfw/tasks/TaskFactory.h" +#include "fsfw/memory/GenericFileSystemMessage.h" +#include "fsfw/ipc/QueueFactory.h" FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler): SystemObject(fileSystemHandler) { + mq = QueueFactory::instance()->createMessageQueue(50); +} + +FileSystemHandler::~FileSystemHandler() { + QueueFactory::instance()->deleteMessageQueue(mq); } ReturnValue_t FileSystemHandler::performOperation(uint8_t unsignedChar) { while(true) { + CommandMessage filemsg; + ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; + while(true) { + result = mq->receiveMessage(&filemsg); + if(result == MessageQueueIF::EMPTY) { + break; + } + else if(result != HasReturnvaluesIF::RETURN_FAILED) { + sif::warning << "FileSystemHandler::performOperation: Message reception failed!" + << std::endl; + break; + } + Command_t command = filemsg.getCommand(); + switch(command) { + + } + } + // This task will have a low priority and will run permanently in the background // so we will just run in a permanent loop here and check file system // messages permanently TaskFactory::instance()->delayTask(1000); } } + +MessageQueueId_t FileSystemHandler::getCommandQueue() const { + return mq->getId(); +} + +ReturnValue_t FileSystemHandler::appendToFile(const char *repositoryPath, const char *filename, + const uint8_t *data, size_t size, uint16_t packetNumber, void *args) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemHandler::createFile(const char *repositoryPath, const char *filename, + const uint8_t *data, size_t size, void *args) { + return HasReturnvaluesIF::RETURN_OK; +} + +ReturnValue_t FileSystemHandler::deleteFile(const char *repositoryPath, const char *filename, + void *args) { + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/bsp_q7s/memory/FileSystemHandler.h b/bsp_q7s/memory/FileSystemHandler.h index c45bbd5e..04cea3dc 100644 --- a/bsp_q7s/memory/FileSystemHandler.h +++ b/bsp_q7s/memory/FileSystemHandler.h @@ -1,6 +1,7 @@ #ifndef BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_ #define BSP_Q7S_MEMORY_FILESYSTEMHANDLER_H_ +#include "fsfw/ipc/MessageQueueIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/memory/HasFileSystemIF.h" @@ -10,6 +11,7 @@ class FileSystemHandler: public SystemObject, public HasFileSystemIF { public: FileSystemHandler(object_id_t fileSystemHandler); + virtual~ FileSystemHandler(); ReturnValue_t performOperation(uint8_t) override; @@ -17,9 +19,10 @@ public: * Function to get the MessageQueueId_t of the implementing object * @return MessageQueueId_t of the object */ - virtual MessageQueueId_t getCommandQueue() const = 0; + MessageQueueId_t getCommandQueue() const override; private: + MessageQueueIF* mq = nullptr; ReturnValue_t appendToFile(const char* repositoryPath, const char* filename, const uint8_t* data, size_t size,