avoid exceptions
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit

This commit is contained in:
2023-03-08 14:50:25 +01:00
parent 0bdc6d3d7c
commit ccf03b131b
19 changed files with 83 additions and 45 deletions

View File

@ -540,8 +540,10 @@ ReturnValue_t Guidance::getDistributionMatrixRw(ACS::SensorValues *sensorValues,
}
void Guidance::getTargetParamsSafe(double sunTargetSafe[3], double satRateSafe[3]) {
if (not std::filesystem::exists(SD_0_SKEWED_PTG_FILE) or
not std::filesystem::exists(SD_1_SKEWED_PTG_FILE)) { // ToDo: if file does not exist anymore
std::error_code e;
if (not std::filesystem::exists(SD_0_SKEWED_PTG_FILE, e) or
not std::filesystem::exists(SD_1_SKEWED_PTG_FILE,
e)) { // ToDo: if file does not exist anymore
std::memcpy(sunTargetSafe, acsParameters.safeModeControllerParameters.sunTargetDir,
3 * sizeof(double));
} else {
@ -553,15 +555,16 @@ void Guidance::getTargetParamsSafe(double sunTargetSafe[3], double satRateSafe[3
}
ReturnValue_t Guidance::solarArrayDeploymentComplete() {
if (std::filesystem::exists(SD_0_SKEWED_PTG_FILE)) {
std::error_code e;
if (std::filesystem::exists(SD_0_SKEWED_PTG_FILE, e)) {
std::remove(SD_0_SKEWED_PTG_FILE);
if (std::filesystem::exists(SD_0_SKEWED_PTG_FILE)) {
if (std::filesystem::exists(SD_0_SKEWED_PTG_FILE, e)) {
return returnvalue::FAILED;
}
}
if (std::filesystem::exists(SD_1_SKEWED_PTG_FILE)) {
if (std::filesystem::exists(SD_1_SKEWED_PTG_FILE, e)) {
std::remove(SD_1_SKEWED_PTG_FILE);
if (std::filesystem::exists(SD_1_SKEWED_PTG_FILE)) {
if (std::filesystem::exists(SD_1_SKEWED_PTG_FILE, e)) {
return returnvalue::FAILED;
}
}

View File

@ -319,11 +319,14 @@ void ScexDeviceHandler::performOperationHook() {
auto mntPrefix = sdcMan.getCurrentMountPrefix();
if (mntPrefix != nullptr) {
std::filesystem::path fullFilePath = mntPrefix;
std::error_code e;
fullFilePath /= "scex";
bool fileExists = std::filesystem::exists(fullFilePath);
bool fileExists = std::filesystem::exists(fullFilePath, e);
if (not fileExists) {
std::filesystem::create_directory(fullFilePath);
bool created = std::filesystem::create_directory(fullFilePath, e);
if (not created) {
sif::error << "Could not create SCEX directory: " << e << std::endl;
}
}
}
uint32_t remainingMillis = finishCountdown.getRemainingMillis();

View File

@ -43,15 +43,16 @@ ReturnValue_t SolarArrayDeploymentHandler::performOperation(uint8_t operationCod
#endif
if (opDivider.checkAndIncrement()) {
auto activeSdc = sdcMan.getActiveSdCard();
std::error_code e;
if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_0 and
sdcMan.isSdCardUsable(activeSdc.value())) {
if (exists(SD_0_DEPL_FILE)) {
if (exists(SD_0_DEPL_FILE, e)) {
// perform autonomous deployment handling
performAutonomousDepl(sd::SdCard::SLOT_0, dryRunStringInFile(SD_0_DEPL_FILE));
}
} else if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_1 and
sdcMan.isSdCardUsable(activeSdc.value())) {
if (exists(SD_1_DEPL_FILE)) {
if (exists(SD_1_DEPL_FILE, e)) {
// perform autonomous deployment handling
performAutonomousDepl(sd::SdCard::SLOT_1, dryRunStringInFile(SD_1_DEPL_FILE));
}
@ -137,15 +138,16 @@ ReturnValue_t SolarArrayDeploymentHandler::performAutonomousDepl(sd::SdCard sdCa
of << "phase: init\n";
of << "secs_since_start: 0\n";
};
std::error_code e;
if (sdCard == sd::SdCard::SLOT_0) {
if (not exists(SD_0_DEPLY_INFO)) {
if (not exists(SD_0_DEPLY_INFO, e)) {
initFile(SD_0_DEPLY_INFO);
}
if (not autonomousDeplForFile(sd::SdCard::SLOT_0, SD_0_DEPLY_INFO, dryRun)) {
initFile(SD_0_DEPLY_INFO);
}
} else if (sdCard == sd::SdCard::SLOT_1) {
if (not exists(SD_1_DEPLY_INFO)) {
if (not exists(SD_1_DEPLY_INFO, e)) {
initFile(SD_1_DEPLY_INFO);
}
if (not autonomousDeplForFile(sd::SdCard::SLOT_1, SD_1_DEPLY_INFO, dryRun)) {

View File

@ -3,6 +3,7 @@
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
#include <mission/memory/NvmParameterBase.h>
#include <cstddef>
#include <filesystem>
@ -10,7 +11,6 @@
#include "OBSWConfig.h"
#include "mission/devices/max1227.h"
#include "mission/memory/NVMParameterBase.h"
namespace plpcdu {

View File

@ -1 +1 @@
target_sources(${LIB_EIVE_MISSION} PRIVATE NVMParameterBase.cpp)
target_sources(${LIB_EIVE_MISSION} PRIVATE NvmParameterBase.cpp)

View File

@ -1,4 +1,4 @@
#include "NVMParameterBase.h"
#include <mission/memory/NvmParameterBase.h>
#include <fstream>
@ -10,7 +10,8 @@ NVMParameterBase::NVMParameterBase(std::string fullName) : fullName(fullName) {}
NVMParameterBase::NVMParameterBase() {}
ReturnValue_t NVMParameterBase::readJsonFile() {
if (std::filesystem::exists(fullName)) {
std::error_code e;
if (std::filesystem::exists(fullName, e)) {
// Read JSON file content into object
std::ifstream i(fullName);
try {
@ -39,7 +40,10 @@ void NVMParameterBase::setFullName(std::string fullName) { this->fullName = full
std::string NVMParameterBase::getFullName() const { return fullName; }
bool NVMParameterBase::getJsonFileExists() { return std::filesystem::exists(fullName); }
bool NVMParameterBase::getJsonFileExists() {
std::error_code e;
return std::filesystem::exists(fullName, e);
}
void NVMParameterBase::printKeys() const {
sif::info << "Printing keys for JSON file " << fullName << std::endl;

View File

@ -174,7 +174,8 @@ bool PersistentTmStore::updateBaseDir() {
return false;
}
basePath = path(currentPrefix) / baseDir / baseName;
if (not exists(basePath)) {
std::error_code e;
if (not exists(basePath, e)) {
create_directories(basePath);
}
baseDirUninitialized = false;

View File

@ -14,6 +14,7 @@
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
#include <fsfw/storagemanager/StorageManagerIF.h>
#include <fsfw/tasks/ExecutableObjectIF.h>
#include <mission/memory/NvmParameterBase.h>
#include <sstream>
#include <string>
@ -22,7 +23,6 @@
#include "OBSWConfig.h"
#include "fsfw/parameters/HasParametersIF.h"
#include "fsfw/parameters/ParameterHelper.h"
#include "mission/memory/NVMParameterBase.h"
static std::map<ParamIds, std::string> PARAM_KEY_MAP = {
{PARAM0, "Parameter0"},