From c1be4a1e834ed302feeab57236a63c45c4795dcf Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 19 Nov 2021 13:22:20 +0100 Subject: [PATCH] changes for updated fsfw --- bsp_q7s/boardtest/Q7STestTask.cpp | 12 ++++---- bsp_q7s/memory/FileSystemHandler.cpp | 28 +++++++++++++------ bsp_q7s/memory/FileSystemHandler.h | 18 ++++++------ fsfw | 2 +- .../Host/eive-linux-host-unittest.launch | 4 +-- test/testtasks/TestTask.cpp | 17 ++++++----- test/testtasks/TestTask.h | 15 ++++------ tmtc | 2 +- 8 files changed, 52 insertions(+), 46 deletions(-) diff --git a/bsp_q7s/boardtest/Q7STestTask.cpp b/bsp_q7s/boardtest/Q7STestTask.cpp index 18baf124..7681ef09 100644 --- a/bsp_q7s/boardtest/Q7STestTask.cpp +++ b/bsp_q7s/boardtest/Q7STestTask.cpp @@ -227,7 +227,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { // Lambda for common code auto createNonEmptyTmpDir = [&]() { if(not std::filesystem::exists("/tmp/test")) { - result = fsHandler->createDirectory("/tmp/test", &cfg); + result = fsHandler->createDirectory("/tmp", "test", false, &cfg); if(result != HasReturnvaluesIF::RETURN_OK) { return result; } @@ -278,7 +278,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { cfg.useMountPrefix = false; sif::info << "Creating empty file in /tmp folder" << std::endl; // Do not delete file, user can check existence in shell - ReturnValue_t result = fsHandler->createDirectory("/tmp/test", &cfg); + ReturnValue_t result = fsHandler->createDirectory("/tmp", "test", false, &cfg); if(result == HasReturnvaluesIF::RETURN_OK) { sif::info << "Directory created successfully" << std::endl; } @@ -291,13 +291,13 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { // No mount prefix, cause file is created in tmp cfg.useMountPrefix = false; if(not std::filesystem::exists("/tmp/test")) { - result = fsHandler->createDirectory("/tmp/test", &cfg); + result = fsHandler->createDirectory("/tmp", "test", false, &cfg); } else { // Delete any leftover files to regular dir removal works std::remove("/tmp/test/*"); } - result = fsHandler->removeDirectory("/tmp/test", false, &cfg); + result = fsHandler->removeDirectory("/tmp", "test", false, &cfg); if(result == HasReturnvaluesIF::RETURN_OK) { sif::info << "Directory removed successfully" << std::endl; } @@ -311,7 +311,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { if(result != HasReturnvaluesIF::RETURN_OK) { return; } - result = fsHandler->removeDirectory("/tmp/test", true, &cfg); + result = fsHandler->removeDirectory("/tmp", "test", true, &cfg); if(result == HasReturnvaluesIF::RETURN_OK) { sif::info << "Directory removed recursively successfully" << std::endl; } @@ -325,7 +325,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) { if(result != HasReturnvaluesIF::RETURN_OK) { return; } - result = fsHandler->removeDirectory("/tmp/test", false, &cfg); + result = fsHandler->removeDirectory("/tmp", "test", false, &cfg); if(result != HasReturnvaluesIF::RETURN_OK) { sif::info << "Directory removal attempt failed as expected" << std::endl; } diff --git a/bsp_q7s/memory/FileSystemHandler.cpp b/bsp_q7s/memory/FileSystemHandler.cpp index ad8ec137..2943875a 100644 --- a/bsp_q7s/memory/FileSystemHandler.cpp +++ b/bsp_q7s/memory/FileSystemHandler.cpp @@ -133,8 +133,9 @@ ReturnValue_t FileSystemHandler::initialize() { return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemHandler::appendToFile(const char *repositoryPath, const char *filename, - const uint8_t *data, size_t size, uint16_t packetNumber, void *args) { +ReturnValue_t FileSystemHandler::appendToFile(const char* repositoryPath, + const char* filename, const uint8_t* data, size_t size, + uint16_t packetNumber, FileSystemArgsIF* args) { // A double slash between repo and filename should not be an issue, so add it in any case std::string fullPath = currentMountPrefix + std::string(repositoryPath) + "/" + std::string(filename); @@ -149,8 +150,8 @@ ReturnValue_t FileSystemHandler::appendToFile(const char *repositoryPath, const return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemHandler::createFile(const char *repositoryPath, const char *filename, - const uint8_t *data, size_t size, void *args) { +ReturnValue_t FileSystemHandler::createFile(const char* repositoryPath, + const char* filename, const uint8_t* data, size_t size, FileSystemArgsIF* args) { std::string fullPath; bool useMountPrefix = true; parseCfg(reinterpret_cast(args), useMountPrefix); @@ -171,8 +172,8 @@ ReturnValue_t FileSystemHandler::createFile(const char *repositoryPath, const ch return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemHandler::removeFile(const char *repositoryPath, const char *filename, - void *args) { +ReturnValue_t FileSystemHandler::removeFile(const char* repositoryPath, + const char* filename, FileSystemArgsIF* args) { std::string fullPath; bool useMountPrefix = true; parseCfg(reinterpret_cast(args), useMountPrefix); @@ -193,7 +194,8 @@ ReturnValue_t FileSystemHandler::removeFile(const char *repositoryPath, const ch return HasReturnvaluesIF::RETURN_OK; } -ReturnValue_t FileSystemHandler::createDirectory(const char *repositoryPath, void *args) { +ReturnValue_t FileSystemHandler:: createDirectory(const char* repositoryPath, const char* dirname, + bool createParentDirs, FileSystemArgsIF* args) { std::string fullPath; bool useMountPrefix = true; parseCfg(reinterpret_cast(args), useMountPrefix); @@ -202,6 +204,7 @@ ReturnValue_t FileSystemHandler::createDirectory(const char *repositoryPath, voi } fullPath += std::string(repositoryPath); + fullPath += "/" + std::string(dirname); if(std::filesystem::exists(fullPath)) { return DIRECTORY_ALREADY_EXISTS; } @@ -212,8 +215,8 @@ ReturnValue_t FileSystemHandler::createDirectory(const char *repositoryPath, voi return GENERIC_FILE_ERROR; } -ReturnValue_t FileSystemHandler::removeDirectory(const char *repositoryPath, - bool deleteRecurively, void *args) { +ReturnValue_t FileSystemHandler::removeDirectory(const char* repositoryPath, const char* dirname, + bool deleteRecurively, FileSystemArgsIF* args) { std::string fullPath; bool useMountPrefix = true; parseCfg(reinterpret_cast(args), useMountPrefix); @@ -222,6 +225,7 @@ ReturnValue_t FileSystemHandler::removeDirectory(const char *repositoryPath, } fullPath += std::string(repositoryPath); + fullPath += "/" + std::string(dirname); if(not std::filesystem::exists(fullPath)) { return DIRECTORY_DOES_NOT_EXIST; } @@ -268,3 +272,9 @@ void FileSystemHandler::parseCfg(FsCommandCfg *cfg, bool& useMountPrefix) { useMountPrefix = cfg->useMountPrefix; } } + +ReturnValue_t FileSystemHandler::renameFile(const char *repositoryPath, const char *oldFilename, + const char *newFilename, FileSystemArgsIF *args) { + // TODO: Implement + return HasReturnvaluesIF::RETURN_OK; +} diff --git a/bsp_q7s/memory/FileSystemHandler.h b/bsp_q7s/memory/FileSystemHandler.h index 1ff5d7c9..8fdebd05 100644 --- a/bsp_q7s/memory/FileSystemHandler.h +++ b/bsp_q7s/memory/FileSystemHandler.h @@ -17,7 +17,7 @@ class FileSystemHandler: public SystemObject, public ExecutableObjectIF, public HasFileSystemIF { public: - struct FsCommandCfg { + 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; @@ -35,18 +35,20 @@ public: * @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, void* args = nullptr) override; + 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, void* args = nullptr) override; + size_t size = 0, FileSystemArgsIF* args = nullptr) override; ReturnValue_t removeFile(const char* repositoryPath, - const char* filename, void* args = nullptr) override; - ReturnValue_t createDirectory(const char* repositoryPath, void* args = nullptr) override; - ReturnValue_t removeDirectory(const char* repositoryPath, bool deleteRecurively = false, - void* args = nullptr) override; + 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; private: CoreController* coreCtrl = nullptr; diff --git a/fsfw b/fsfw index 190848d0..5d719d0a 160000 --- a/fsfw +++ b/fsfw @@ -1 +1 @@ -Subproject commit 190848d00e32274eb844e0f930669b65ffe7eb4e +Subproject commit 5d719d0aeb2d4e2089f5106a03c0bbf9caee4381 diff --git a/misc/eclipse/Host/eive-linux-host-unittest.launch b/misc/eclipse/Host/eive-linux-host-unittest.launch index 85d54281..68c1747f 100644 --- a/misc/eclipse/Host/eive-linux-host-unittest.launch +++ b/misc/eclipse/Host/eive-linux-host-unittest.launch @@ -18,10 +18,10 @@ - + - + diff --git a/test/testtasks/TestTask.cpp b/test/testtasks/TestTask.cpp index cb185b4a..6a90cc08 100644 --- a/test/testtasks/TestTask.cpp +++ b/test/testtasks/TestTask.cpp @@ -11,15 +11,14 @@ #include -TestTask::TestTask(object_id_t objectId_): -SystemObject(objectId_), testMode(testModes::A) { +EiveTestTask::EiveTestTask(object_id_t objectId_): TestTask(objectId_), testMode(testModes::A) { IPCStore = ObjectManager::instance()->get(objects::IPC_STORE); } -TestTask::~TestTask() { +EiveTestTask::~EiveTestTask() { } -ReturnValue_t TestTask::performOperation(uint8_t operationCode) { +ReturnValue_t EiveTestTask::performOperation(uint8_t operationCode) { ReturnValue_t result = RETURN_OK; if(oneShotAction) { @@ -74,7 +73,7 @@ const char hyperion_gps_data[] = "" "$GNVTG,040.7,T,,M,000.0,N,000.0,K,A*10\r\n" "$GNZDA,173225.998892,27,02,2021,00,00*75\r\n"; -ReturnValue_t TestTask::performOneShotAction() { +ReturnValue_t EiveTestTask::performOneShotAction() { #if OBSW_ADD_TEST_CODE == 1 //performLwgpsTest(); #endif @@ -82,24 +81,24 @@ ReturnValue_t TestTask::performOneShotAction() { } -ReturnValue_t TestTask::performPeriodicAction() { +ReturnValue_t EiveTestTask::performPeriodicAction() { ReturnValue_t result = RETURN_OK; return result; } -ReturnValue_t TestTask::performActionA() { +ReturnValue_t EiveTestTask::performActionA() { ReturnValue_t result = RETURN_OK; /* Add periodically executed code here */ return result; } -ReturnValue_t TestTask::performActionB() { +ReturnValue_t EiveTestTask::performActionB() { ReturnValue_t result = RETURN_OK; /* Add periodically executed code here */ return result; } -void TestTask::performLwgpsTest() { +void EiveTestTask::performLwgpsTest() { /* Everything here will only be performed once. */ sif::info << "Processing sample GPS output.." << std::endl; diff --git a/test/testtasks/TestTask.h b/test/testtasks/TestTask.h index e2e8db48..c2b8c8ed 100644 --- a/test/testtasks/TestTask.h +++ b/test/testtasks/TestTask.h @@ -1,13 +1,10 @@ #ifndef TEST_TESTTASK_H_ #define TEST_TESTTASK_H_ -#include -#include -#include #include #include #include -#include +#include "fsfw_tests/integration/task/TestTask.h" #include @@ -18,13 +15,11 @@ * Should not be used for board specific * tests. Instead, a derived board test class should be used. */ -class TestTask : public SystemObject, - public ExecutableObjectIF, - public HasReturnvaluesIF { +class EiveTestTask : public TestTask { public: - TestTask(object_id_t objectId); - virtual ~TestTask(); - virtual ReturnValue_t performOperation(uint8_t operationCode = 0); + EiveTestTask(object_id_t objectId); + virtual ~EiveTestTask(); + virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override; protected: virtual ReturnValue_t performOneShotAction(); diff --git a/tmtc b/tmtc index 28082dca..9068ebbf 160000 --- a/tmtc +++ b/tmtc @@ -1 +1 @@ -Subproject commit 28082dca885e35641fda85be765ff10c16c3ebe8 +Subproject commit 9068ebbfc07fe2d58d8c41eed133e758729ca9b6