bugfix SdCardManager
Some checks are pending
EIVE/eive-obsw/pipeline/head Build started...
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
Jakob Meier 2022-05-26 01:56:19 +02:00
parent e5459bb1f7
commit c588ec4a1a
2 changed files with 11 additions and 4 deletions

View File

@ -20,9 +20,16 @@ SdCardManager* SdCardManager::INSTANCE = nullptr;
SdCardManager::SdCardManager() : SystemObject(objects::SDC_MANAGER), cmdExecutor(256) { SdCardManager::SdCardManager() : SystemObject(objects::SDC_MANAGER), cmdExecutor(256) {
mutex = MutexFactory::instance()->createMutex(); mutex = MutexFactory::instance()->createMutex();
MutexGuard mg(mutex); ReturnValue_t result = mutex->lockMutex();
if (result != RETURN_OK) {
sif::error << "SdCardManager::SdCardManager: Mutex lock failed" << std::endl;
}
uint8_t prefSdRaw = 0; uint8_t prefSdRaw = 0;
ReturnValue_t result = scratch::readNumber(scratch::PREFERED_SDC_KEY, prefSdRaw); result = scratch::readNumber(scratch::PREFERED_SDC_KEY, prefSdRaw);
result = mutex->unlockMutex();
if (result != RETURN_OK) {
sif::error << "SdCardManager::SdCardManager: Mutex unlock failed" << std::endl;
}
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != HasReturnvaluesIF::RETURN_OK) {
if (result == scratch::KEY_NOT_FOUND) { if (result == scratch::KEY_NOT_FOUND) {

View File

@ -76,12 +76,12 @@ ReturnValue_t readToFile(std::string name, std::ifstream& file, std::string& fil
int result = std::system(oss.str().c_str()); int result = std::system(oss.str().c_str());
if (result != 0) { if (result != 0) {
if (WEXITSTATUS(result) == 1) { if (WEXITSTATUS(result) == 1) {
sif::warning << "scratch::readNumber: Key " << name << " does not exist" << std::endl; sif::warning << "scratch::readToFile: Key " << name << " does not exist" << std::endl;
// Could not find value // Could not find value
std::remove(filename.c_str()); std::remove(filename.c_str());
return KEY_NOT_FOUND; return KEY_NOT_FOUND;
} else { } else {
utility::handleSystemError(result, "scratch::readNumber"); utility::handleSystemError(result, "scratch::readToFile");
std::remove(filename.c_str()); std::remove(filename.c_str());
return HasReturnvaluesIF::RETURN_FAILED; return HasReturnvaluesIF::RETURN_FAILED;
} }