add very basic test in Q7S Test task for FS helpers
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
This commit is contained in:
parent
26216eca88
commit
547fcf22dd
@ -4,6 +4,7 @@
|
|||||||
#include <bsp_q7s/xadc/Xadc.h>
|
#include <bsp_q7s/xadc/Xadc.h>
|
||||||
#include <fsfw/globalfunctions/arrayprinter.h>
|
#include <fsfw/globalfunctions/arrayprinter.h>
|
||||||
#include <fsfw/objectmanager/ObjectManager.h>
|
#include <fsfw/objectmanager/ObjectManager.h>
|
||||||
|
#include <fsfw_hal/host/HostFilesystem.h>
|
||||||
#include <gps.h>
|
#include <gps.h>
|
||||||
#include <libgpsmm.h>
|
#include <libgpsmm.h>
|
||||||
#include <param/param_string.h>
|
#include <param/param_string.h>
|
||||||
@ -19,11 +20,14 @@
|
|||||||
#include "OBSWConfig.h"
|
#include "OBSWConfig.h"
|
||||||
#include "bsp_q7s/fs/SdCardManager.h"
|
#include "bsp_q7s/fs/SdCardManager.h"
|
||||||
#include "bsp_q7s/memory/scratchApi.h"
|
#include "bsp_q7s/memory/scratchApi.h"
|
||||||
|
#include "bsp_q7s/fs/helpers.h"
|
||||||
#include "fsfw/tasks/TaskFactory.h"
|
#include "fsfw/tasks/TaskFactory.h"
|
||||||
#include "fsfw/timemanager/Stopwatch.h"
|
#include "fsfw/timemanager/Stopwatch.h"
|
||||||
#include "p60pdu.h"
|
#include "p60pdu.h"
|
||||||
#include "test/DummyParameter.h"
|
#include "test/DummyParameter.h"
|
||||||
|
|
||||||
|
using namespace returnvalue;
|
||||||
|
|
||||||
Q7STestTask::Q7STestTask(object_id_t objectId) : TestTask(objectId) {
|
Q7STestTask::Q7STestTask(object_id_t objectId) : TestTask(objectId) {
|
||||||
doTestSdCard = false;
|
doTestSdCard = false;
|
||||||
doTestScratchApi = false;
|
doTestScratchApi = false;
|
||||||
@ -71,7 +75,7 @@ ReturnValue_t Q7STestTask::performOneShotAction() {
|
|||||||
if (doTestProtHandler) {
|
if (doTestProtHandler) {
|
||||||
testProtHandler();
|
testProtHandler();
|
||||||
}
|
}
|
||||||
FsOpCodes opCode = FsOpCodes::APPEND_TO_FILE;
|
FsOpCodes opCode = FsOpCodes::CREATE_EMPTY_FILE_IN_TMP;
|
||||||
testFileSystemHandlerDirect(opCode);
|
testFileSystemHandlerDirect(opCode);
|
||||||
return TestTask::performOneShotAction();
|
return TestTask::performOneShotAction();
|
||||||
}
|
}
|
||||||
@ -365,7 +369,26 @@ void Q7STestTask::testGpsDaemonSocket() {
|
|||||||
sif::info << "Longitude: " << gps->fix.longitude << std::endl;
|
sif::info << "Longitude: " << gps->fix.longitude << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {}
|
void Q7STestTask::testFileSystemHandlerDirect(FsOpCodes opCode) {
|
||||||
|
HostFilesystem hostFs;
|
||||||
|
auto* sdcMan = SdCardManager::instance();
|
||||||
|
std::string mountPrefix = sdcMan->getCurrentMountPrefix();
|
||||||
|
sif::info << "Current mount prefix: " << mountPrefix << std::endl;
|
||||||
|
auto prefixedPath = fshelpers::getPrefixedPath(*sdcMan, "conf/test.txt");
|
||||||
|
sif::info << "Prefixed path: " << prefixedPath << std::endl;
|
||||||
|
if (opCode == FsOpCodes::CREATE_EMPTY_FILE_IN_TMP) {
|
||||||
|
FilesystemParams params("/tmp/hello.txt");
|
||||||
|
auto res = hostFs.createFile(params);
|
||||||
|
if(res != OK) {
|
||||||
|
sif::warning << "Creating empty file in /tmp failed" << std::endl;
|
||||||
|
}
|
||||||
|
bool fileExists = std::filesystem::exists("/tmp/hello.txt");
|
||||||
|
if(not fileExists) {
|
||||||
|
sif::warning << "File was not created!" << std::endl;
|
||||||
|
}
|
||||||
|
hostFs.removeFile("/tmp/hello.txt");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Q7STestTask::xadcTest() {
|
void Q7STestTask::xadcTest() {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
|
@ -198,15 +198,6 @@ void initmission::initTasks() {
|
|||||||
}
|
}
|
||||||
#endif /* OBSW_ADD_RTD_DEVICES */
|
#endif /* OBSW_ADD_RTD_DEVICES */
|
||||||
|
|
||||||
// FS task, task interval does not matter because it runs in permanent loop, priority low
|
|
||||||
// because it is a non-essential background task
|
|
||||||
PeriodicTaskIF* fsTask = factory->createPeriodicTask(
|
|
||||||
"FILE_SYSTEM_TASK", 25, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.4, missedDeadlineFunc);
|
|
||||||
result = fsTask->addComponent(objects::FILE_SYSTEM_HANDLER);
|
|
||||||
if (result != returnvalue::OK) {
|
|
||||||
initmission::printAddObjectError("FILE_SYSTEM_TASK", objects::FILE_SYSTEM_HANDLER);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if OBSW_ADD_STAR_TRACKER == 1
|
#if OBSW_ADD_STAR_TRACKER == 1
|
||||||
PeriodicTaskIF* strHelperTask = factory->createPeriodicTask(
|
PeriodicTaskIF* strHelperTask = factory->createPeriodicTask(
|
||||||
"STR_HELPER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
|
"STR_HELPER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 0.2, missedDeadlineFunc);
|
||||||
@ -288,7 +279,6 @@ void initmission::initTasks() {
|
|||||||
ptmeTestTask->startTask();
|
ptmeTestTask->startTask();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fsTask->startTask();
|
|
||||||
#if OBSW_ADD_STAR_TRACKER == 1
|
#if OBSW_ADD_STAR_TRACKER == 1
|
||||||
strHelperTask->startTask();
|
strHelperTask->startTask();
|
||||||
#endif /* OBSW_ADD_STAR_TRACKER == 1 */
|
#endif /* OBSW_ADD_STAR_TRACKER == 1 */
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "helpers.h"
|
#include "helpers.h"
|
||||||
|
|
||||||
std::filesystem::path fshelpers::buildPrefixedPath(SdCardManager &man,
|
std::filesystem::path fshelpers::getPrefixedPath(SdCardManager &man,
|
||||||
std::filesystem::path pathWihtoutPrefix) {
|
std::filesystem::path pathWihtoutPrefix) {
|
||||||
auto prefix = man.getCurrentMountPrefix();
|
auto prefix = man.getCurrentMountPrefix();
|
||||||
auto resPath = prefix / pathWihtoutPrefix;
|
auto resPath = prefix / pathWihtoutPrefix;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
namespace fshelpers {
|
namespace fshelpers {
|
||||||
|
|
||||||
std::filesystem::path buildPrefixedPath(SdCardManager& man,
|
std::filesystem::path getPrefixedPath(SdCardManager& man,
|
||||||
std::filesystem::path pathWihtoutPrefix);
|
std::filesystem::path pathWihtoutPrefix);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user