eive-obsw/bsp_q7s/memory/SdCardManager.cpp

56 lines
1.2 KiB
C++
Raw Normal View History

2021-07-07 20:50:11 +02:00
#include "SdCardManager.h"
#include "fsfw/ipc/MutexFactory.h"
#include <fstream>
#include <filesystem>
SdCardManager* SdCardManager::factoryInstance = nullptr;
SdCardManager::SdCardManager() {
}
SdCardManager::~SdCardManager() {
}
void SdCardManager::create() {
if(factoryInstance == nullptr) {
factoryInstance = new SdCardManager();
}
}
SdCardManager* SdCardManager::instance() {
SdCardManager::create();
return SdCardManager::factoryInstance;
}
ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard) {
if(sdCardActive(sdCard)) {
return ALREADY_ON;
}
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t SdCardManager::switchOffSdCard(sd::SdCard sdCard) {
return HasReturnvaluesIF::RETURN_OK;
}
bool SdCardManager::sdCardActive(sd::SdCard sdCard) {
if(std::filesystem::exists("/tmp/sd_status.txt")) {
std::ifstream sdStatus("/tmp/sd_status.txt");
return HasReturnvaluesIF::RETURN_OK;
}
return false;
}
sd::SdCard SdCardManager::getPreferredSdCard() const {
return preferredSdCard;
}
void SdCardManager::setPreferredSdCard(sd::SdCard sdCard) {
preferredSdCard = sdCard;
}
void SdCardManager::updateSdCardStateFile() {
}