various bugfixes

This commit is contained in:
Robin Müller 2021-07-23 17:06:10 +02:00
parent 64844f83a9
commit 46e2e40cb1
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
3 changed files with 29 additions and 7 deletions

View File

@ -6,6 +6,8 @@
#include "../memory/scratchApi.h"
#include "../memory/SdCardManager.h"
#include <filesystem>
CoreController::CoreController(object_id_t objectId):
ExtendedControllerBase(objectId, objects::NO_OBJECT, 5) {
}
@ -27,10 +29,18 @@ LocalPoolDataSetBase* CoreController::getDataSetHandle(sid_t sid) {
}
ReturnValue_t CoreController::initialize() {
ReturnValue_t result = sdCardInit();
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "CoreController::initialize: SD card init failed" << std::endl;
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
try {
result = sdCardInit();
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "CoreController::initialize: SD card init failed" << std::endl;
}
}
catch(const std::filesystem::filesystem_error& e) {
sif::error << "CoreController::initialize: sdCardInit failed with exception " << e.what()
<< std::endl;
}
result = scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, 0);
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "CoreController::initialize: Setting up alloc failure "
@ -103,9 +113,14 @@ ReturnValue_t CoreController::sdCardSetup(SdCardManager& sdcMan,
return sdcMan.mountSdCard(sdCard);
}
else {
sif::info << "SD card " << sdString << " already on and mounted at " <<
mountString << std::endl;
return SdCardManager::ALREADY_MOUNTED;
if(std::filesystem::exists(mountString)) {
sif::info << "SD card " << sdString << " already on and mounted at " <<
mountString << std::endl;
return SdCardManager::ALREADY_MOUNTED;
}
sif::error << "SD card mounted but expected mount point " << mountString << " not found!"
<< std::endl;
return SdCardManager::MOUNT_ERROR;
}
}

View File

@ -218,6 +218,11 @@ ReturnValue_t SdCardManager::unmountSdCard(sd::SdCard sdCard) {
else if(sdCard == sd::SdCard::SLOT_1) {
mountPoint = SD_1_MOUNT_POINT;
}
if(not filesystem::exists(mountPoint)) {
sif::error << "SdCardManager::unmountSdCard: Default mount point " << mountPoint <<
"does not exist" << std::endl;
return UNMOUNT_ERROR;
}
if(filesystem::is_empty(mountPoint)) {
// The mount point will always exist, but if it is empty, that is strong hint that
// the SD card was not mounted properly. Still proceed with operation.

View File

@ -3,9 +3,11 @@
#include "utility.h"
#include "fsfw/serviceinterface/ServiceInterface.h"
#include <cstring>
void utility::handleSystemError(int retcode, std::string function) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::warning << function << ": System call failed with code " << retcode;
sif::warning << function << ": System call failed with code " << retcode << ": " <<
strerror(retcode) << std::endl;
#endif
}