eive-obsw/bsp_q7s/memory/FileSystemHandler.cpp

66 lines
2.2 KiB
C++
Raw Normal View History

2021-07-08 12:22:41 +02:00
#include "FileSystemHandler.h"
#include "fsfw/tasks/TaskFactory.h"
2021-07-08 12:32:24 +02:00
#include "fsfw/memory/GenericFileSystemMessage.h"
#include "fsfw/ipc/QueueFactory.h"
2021-07-08 12:22:41 +02:00
FileSystemHandler::FileSystemHandler(object_id_t fileSystemHandler):
SystemObject(fileSystemHandler) {
2021-07-12 16:32:14 +02:00
mq = QueueFactory::instance()->createMessageQueue(FS_MAX_QUEUE_SIZE);
2021-07-08 12:32:24 +02:00
}
FileSystemHandler::~FileSystemHandler() {
QueueFactory::instance()->deleteMessageQueue(mq);
2021-07-08 12:22:41 +02:00
}
ReturnValue_t FileSystemHandler::performOperation(uint8_t unsignedChar) {
while(true) {
2021-07-08 12:32:24 +02:00
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) {
2021-07-08 12:36:41 +02:00
case(GenericFileSystemMessage::CMD_CREATE_DIRECTORY): {
break;
}
case(GenericFileSystemMessage::CMD_CREATE_FILE): {
break;
}
2021-07-08 12:32:24 +02:00
}
}
2021-07-08 12:22:41 +02:00
// 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);
}
}
2021-07-08 12:32:24 +02:00
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;
}