SW tweaks #112

Merged
meierj merged 11 commits from mueller/sw-tweaks into develop 2021-11-26 09:14:04 +01:00
8 changed files with 52 additions and 46 deletions
Showing only changes of commit c1be4a1e83 - Show all commits

View File

@ -227,7 +227,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {
// Lambda for common code // Lambda for common code
auto createNonEmptyTmpDir = [&]() { auto createNonEmptyTmpDir = [&]() {
if(not std::filesystem::exists("/tmp/test")) { 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) { if(result != HasReturnvaluesIF::RETURN_OK) {
return result; return result;
} }
@ -278,7 +278,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {
cfg.useMountPrefix = false; cfg.useMountPrefix = false;
sif::info << "Creating empty file in /tmp folder" << std::endl; sif::info << "Creating empty file in /tmp folder" << std::endl;
// Do not delete file, user can check existence in shell // 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) { if(result == HasReturnvaluesIF::RETURN_OK) {
sif::info << "Directory created successfully" << std::endl; 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 // No mount prefix, cause file is created in tmp
cfg.useMountPrefix = false; cfg.useMountPrefix = false;
if(not std::filesystem::exists("/tmp/test")) { if(not std::filesystem::exists("/tmp/test")) {
result = fsHandler->createDirectory("/tmp/test", &cfg); result = fsHandler->createDirectory("/tmp", "test", false, &cfg);
} }
else { else {
// Delete any leftover files to regular dir removal works // Delete any leftover files to regular dir removal works
std::remove("/tmp/test/*"); std::remove("/tmp/test/*");
} }
result = fsHandler->removeDirectory("/tmp/test", false, &cfg); result = fsHandler->removeDirectory("/tmp", "test", false, &cfg);
if(result == HasReturnvaluesIF::RETURN_OK) { if(result == HasReturnvaluesIF::RETURN_OK) {
sif::info << "Directory removed successfully" << std::endl; sif::info << "Directory removed successfully" << std::endl;
} }
@ -311,7 +311,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
return; return;
} }
result = fsHandler->removeDirectory("/tmp/test", true, &cfg); result = fsHandler->removeDirectory("/tmp", "test", true, &cfg);
if(result == HasReturnvaluesIF::RETURN_OK) { if(result == HasReturnvaluesIF::RETURN_OK) {
sif::info << "Directory removed recursively successfully" << std::endl; sif::info << "Directory removed recursively successfully" << std::endl;
} }
@ -325,7 +325,7 @@ void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
return; return;
} }
result = fsHandler->removeDirectory("/tmp/test", false, &cfg); result = fsHandler->removeDirectory("/tmp", "test", false, &cfg);
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
sif::info << "Directory removal attempt failed as expected" << std::endl; sif::info << "Directory removal attempt failed as expected" << std::endl;
} }

View File

@ -133,8 +133,9 @@ ReturnValue_t FileSystemHandler::initialize() {
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
ReturnValue_t FileSystemHandler::appendToFile(const char *repositoryPath, const char *filename, ReturnValue_t FileSystemHandler::appendToFile(const char* repositoryPath,
const uint8_t *data, size_t size, uint16_t packetNumber, void *args) { 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 // 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 fullPath = currentMountPrefix + std::string(repositoryPath) + "/" +
std::string(filename); std::string(filename);
@ -149,8 +150,8 @@ ReturnValue_t FileSystemHandler::appendToFile(const char *repositoryPath, const
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
ReturnValue_t FileSystemHandler::createFile(const char *repositoryPath, const char *filename, ReturnValue_t FileSystemHandler::createFile(const char* repositoryPath,
const uint8_t *data, size_t size, void *args) { const char* filename, const uint8_t* data, size_t size, FileSystemArgsIF* args) {
std::string fullPath; std::string fullPath;
bool useMountPrefix = true; bool useMountPrefix = true;
parseCfg(reinterpret_cast<FsCommandCfg*>(args), useMountPrefix); parseCfg(reinterpret_cast<FsCommandCfg*>(args), useMountPrefix);
@ -171,8 +172,8 @@ ReturnValue_t FileSystemHandler::createFile(const char *repositoryPath, const ch
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }
ReturnValue_t FileSystemHandler::removeFile(const char *repositoryPath, const char *filename, ReturnValue_t FileSystemHandler::removeFile(const char* repositoryPath,
void *args) { const char* filename, FileSystemArgsIF* args) {
std::string fullPath; std::string fullPath;
bool useMountPrefix = true; bool useMountPrefix = true;
parseCfg(reinterpret_cast<FsCommandCfg*>(args), useMountPrefix); parseCfg(reinterpret_cast<FsCommandCfg*>(args), useMountPrefix);
@ -193,7 +194,8 @@ ReturnValue_t FileSystemHandler::removeFile(const char *repositoryPath, const ch
return HasReturnvaluesIF::RETURN_OK; 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; std::string fullPath;
bool useMountPrefix = true; bool useMountPrefix = true;
parseCfg(reinterpret_cast<FsCommandCfg*>(args), useMountPrefix); parseCfg(reinterpret_cast<FsCommandCfg*>(args), useMountPrefix);
@ -202,6 +204,7 @@ ReturnValue_t FileSystemHandler::createDirectory(const char *repositoryPath, voi
} }
fullPath += std::string(repositoryPath); fullPath += std::string(repositoryPath);
fullPath += "/" + std::string(dirname);
if(std::filesystem::exists(fullPath)) { if(std::filesystem::exists(fullPath)) {
return DIRECTORY_ALREADY_EXISTS; return DIRECTORY_ALREADY_EXISTS;
} }
@ -212,8 +215,8 @@ ReturnValue_t FileSystemHandler::createDirectory(const char *repositoryPath, voi
return GENERIC_FILE_ERROR; return GENERIC_FILE_ERROR;
} }
ReturnValue_t FileSystemHandler::removeDirectory(const char *repositoryPath, ReturnValue_t FileSystemHandler::removeDirectory(const char* repositoryPath, const char* dirname,
bool deleteRecurively, void *args) { bool deleteRecurively, FileSystemArgsIF* args) {
std::string fullPath; std::string fullPath;
bool useMountPrefix = true; bool useMountPrefix = true;
parseCfg(reinterpret_cast<FsCommandCfg*>(args), useMountPrefix); parseCfg(reinterpret_cast<FsCommandCfg*>(args), useMountPrefix);
@ -222,6 +225,7 @@ ReturnValue_t FileSystemHandler::removeDirectory(const char *repositoryPath,
} }
fullPath += std::string(repositoryPath); fullPath += std::string(repositoryPath);
fullPath += "/" + std::string(dirname);
if(not std::filesystem::exists(fullPath)) { if(not std::filesystem::exists(fullPath)) {
return DIRECTORY_DOES_NOT_EXIST; return DIRECTORY_DOES_NOT_EXIST;
} }
@ -268,3 +272,9 @@ void FileSystemHandler::parseCfg(FsCommandCfg *cfg, bool& useMountPrefix) {
useMountPrefix = cfg->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;
}

View File

@ -17,7 +17,7 @@ class FileSystemHandler: public SystemObject,
public ExecutableObjectIF, public ExecutableObjectIF,
public HasFileSystemIF { public HasFileSystemIF {
public: public:
struct FsCommandCfg { struct FsCommandCfg: public FileSystemArgsIF {
// Can be used to automatically use mount prefix of active SD card. // 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. // Otherwise, the operator has to specify the full path to the mounted SD card as well.
bool useMountPrefix = false; bool useMountPrefix = false;
@ -35,18 +35,20 @@ public:
* @return MessageQueueId_t of the object * @return MessageQueueId_t of the object
*/ */
MessageQueueId_t getCommandQueue() const override; MessageQueueId_t getCommandQueue() const override;
ReturnValue_t appendToFile(const char* repositoryPath, ReturnValue_t appendToFile(const char* repositoryPath,
const char* filename, const uint8_t* data, size_t size, 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, ReturnValue_t createFile(const char* repositoryPath,
const char* filename, const uint8_t* data = nullptr, 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, ReturnValue_t removeFile(const char* repositoryPath,
const char* filename, void* args = nullptr) override; const char* filename, FileSystemArgsIF* args = nullptr) override;
ReturnValue_t createDirectory(const char* repositoryPath, void* args = nullptr) override; ReturnValue_t createDirectory(const char* repositoryPath, const char* dirname,
ReturnValue_t removeDirectory(const char* repositoryPath, bool deleteRecurively = false, bool createParentDirs, FileSystemArgsIF* args = nullptr) override;
void* 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: private:
CoreController* coreCtrl = nullptr; CoreController* coreCtrl = nullptr;

2
fsfw

@ -1 +1 @@
Subproject commit 190848d00e32274eb844e0f930669b65ffe7eb4e Subproject commit 5d719d0aeb2d4e2089f5106a03c0bbf9caee4381

View File

@ -18,10 +18,10 @@
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="run"/> <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_START_MODE" value="run"/>
<booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/> <booleanAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN" value="true"/>
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/> <stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build-Debug-Unittest/eive-unittest"/> <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="fsfw/build-Unittest/fsfw-tests"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="eive-obsw"/> <stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="eive-obsw"/>
<booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/> <booleanAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_AUTO_ATTR" value="false"/>
<stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="cdt.managedbuild.toolchain.gnu.mingw.base.1455833186.1840876443.2117915473.775472168"/> <stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value=""/>
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS"> <listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
<listEntry value="/eive-obsw"/> <listEntry value="/eive-obsw"/>
</listAttribute> </listAttribute>

View File

@ -11,15 +11,14 @@
#include <cstring> #include <cstring>
TestTask::TestTask(object_id_t objectId_): EiveTestTask::EiveTestTask(object_id_t objectId_): TestTask(objectId_), testMode(testModes::A) {
SystemObject(objectId_), testMode(testModes::A) {
IPCStore = ObjectManager::instance()->get<StorageManagerIF>(objects::IPC_STORE); IPCStore = ObjectManager::instance()->get<StorageManagerIF>(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; ReturnValue_t result = RETURN_OK;
if(oneShotAction) { 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" "$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"; "$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 #if OBSW_ADD_TEST_CODE == 1
//performLwgpsTest(); //performLwgpsTest();
#endif #endif
@ -82,24 +81,24 @@ ReturnValue_t TestTask::performOneShotAction() {
} }
ReturnValue_t TestTask::performPeriodicAction() { ReturnValue_t EiveTestTask::performPeriodicAction() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
return result; return result;
} }
ReturnValue_t TestTask::performActionA() { ReturnValue_t EiveTestTask::performActionA() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
/* Add periodically executed code here */ /* Add periodically executed code here */
return result; return result;
} }
ReturnValue_t TestTask::performActionB() { ReturnValue_t EiveTestTask::performActionB() {
ReturnValue_t result = RETURN_OK; ReturnValue_t result = RETURN_OK;
/* Add periodically executed code here */ /* Add periodically executed code here */
return result; return result;
} }
void TestTask::performLwgpsTest() { void EiveTestTask::performLwgpsTest() {
/* Everything here will only be performed once. */ /* Everything here will only be performed once. */
sif::info << "Processing sample GPS output.." << std::endl; sif::info << "Processing sample GPS output.." << std::endl;

View File

@ -1,13 +1,10 @@
#ifndef TEST_TESTTASK_H_ #ifndef TEST_TESTTASK_H_
#define TEST_TESTTASK_H_ #define TEST_TESTTASK_H_
#include <fsfw/tasks/ExecutableObjectIF.h>
#include <fsfw/objectmanager/SystemObject.h>
#include <fsfw/parameters/HasParametersIF.h>
#include <fsfw/serialize/SerialBufferAdapter.h> #include <fsfw/serialize/SerialBufferAdapter.h>
#include <fsfw/serialize/SerializeElement.h> #include <fsfw/serialize/SerializeElement.h>
#include <fsfw/serialize/SerialLinkedListAdapter.h> #include <fsfw/serialize/SerialLinkedListAdapter.h>
#include <fsfw/storagemanager/StorageManagerIF.h> #include "fsfw_tests/integration/task/TestTask.h"
#include <cstddef> #include <cstddef>
@ -18,13 +15,11 @@
* Should not be used for board specific * Should not be used for board specific
* tests. Instead, a derived board test class should be used. * tests. Instead, a derived board test class should be used.
*/ */
class TestTask : public SystemObject, class EiveTestTask : public TestTask {
public ExecutableObjectIF,
public HasReturnvaluesIF {
public: public:
TestTask(object_id_t objectId); EiveTestTask(object_id_t objectId);
virtual ~TestTask(); virtual ~EiveTestTask();
virtual ReturnValue_t performOperation(uint8_t operationCode = 0); virtual ReturnValue_t performOperation(uint8_t operationCode = 0) override;
protected: protected:
virtual ReturnValue_t performOneShotAction(); virtual ReturnValue_t performOneShotAction();

2
tmtc

@ -1 +1 @@
Subproject commit 28082dca885e35641fda85be765ff10c16c3ebe8 Subproject commit 9068ebbfc07fe2d58d8c41eed133e758729ca9b6