Merge pull request 'avoid exceptions' (#447) from bugfix_create_dir_no_exceptions into develop
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
Reviewed-on: #447 Reviewed-by: Marius Eggert <eggertm@irs.uni-stuttgart.de>
This commit is contained in:
commit
b2a8c5d7ec
@ -31,6 +31,8 @@ will consitute of a breaking change warranting a new major release:
|
|||||||
|
|
||||||
## Fixed
|
## Fixed
|
||||||
|
|
||||||
|
- `std::filesystem` API usages: Avoid exceptions by using variants which return an error code
|
||||||
|
instead of throwing exceptions.
|
||||||
- GPS fix loss was not reported if mode is unset.
|
- GPS fix loss was not reported if mode is unset.
|
||||||
- Star Tracker: OFF to NORMAL transition now posssible. Requires FSFW bump which sets
|
- Star Tracker: OFF to NORMAL transition now posssible. Requires FSFW bump which sets
|
||||||
transition source modes properly for those transitions.
|
transition source modes properly for those transitions.
|
||||||
|
@ -605,7 +605,8 @@ ReturnValue_t CoreController::sdCardSetup(sd::SdCard sdCard, sd::SdState targetS
|
|||||||
sif::info << "Unmounting SD card " << sdChar << std::endl;
|
sif::info << "Unmounting SD card " << sdChar << std::endl;
|
||||||
return sdcMan->unmountSdCard(sdCard);
|
return sdcMan->unmountSdCard(sdCard);
|
||||||
} else {
|
} else {
|
||||||
if (std::filesystem::exists(mountString)) {
|
std::error_code e;
|
||||||
|
if (std::filesystem::exists(mountString, e)) {
|
||||||
sif::info << "SD card " << sdChar << " already on and mounted at " << mountString
|
sif::info << "SD card " << sdChar << " already on and mounted at " << mountString
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
return SdCardManager::ALREADY_MOUNTED;
|
return SdCardManager::ALREADY_MOUNTED;
|
||||||
@ -702,7 +703,8 @@ ReturnValue_t CoreController::initVersionFile() {
|
|||||||
std::string versionFilePath = currMntPrefix + VERSION_FILE;
|
std::string versionFilePath = currMntPrefix + VERSION_FILE;
|
||||||
std::fstream versionFile;
|
std::fstream versionFile;
|
||||||
|
|
||||||
if (not std::filesystem::exists(versionFilePath)) {
|
std::error_code e;
|
||||||
|
if (not std::filesystem::exists(versionFilePath, e)) {
|
||||||
sif::info << "Writing version file " << versionFilePath << ".." << std::endl;
|
sif::info << "Writing version file " << versionFilePath << ".." << std::endl;
|
||||||
versionFile.open(versionFilePath, std::ios_base::out);
|
versionFile.open(versionFilePath, std::ios_base::out);
|
||||||
versionFile << fullObswVersionString << std::endl;
|
versionFile << fullObswVersionString << std::endl;
|
||||||
@ -814,7 +816,8 @@ ReturnValue_t CoreController::actionListDirectoryIntoFile(ActionId_t actionId,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t CoreController::initBootCopyFile() {
|
ReturnValue_t CoreController::initBootCopyFile() {
|
||||||
if (not std::filesystem::exists(CURR_COPY_FILE)) {
|
std::error_code e;
|
||||||
|
if (not std::filesystem::exists(CURR_COPY_FILE, e)) {
|
||||||
// This file is created by the systemd service eive-early-config so this should
|
// This file is created by the systemd service eive-early-config so this should
|
||||||
// not happen normally
|
// not happen normally
|
||||||
std::string cmd = "xsc_boot_copy > " + std::string(CURR_COPY_FILE);
|
std::string cmd = "xsc_boot_copy > " + std::string(CURR_COPY_FILE);
|
||||||
@ -1118,7 +1121,8 @@ ReturnValue_t CoreController::updateProtInfo(bool regenerateChipStateFile) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (not filesystem::exists(CHIP_STATE_FILE)) {
|
std::error_code e;
|
||||||
|
if (not filesystem::exists(CHIP_STATE_FILE, e)) {
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
ifstream chipStateFile(CHIP_STATE_FILE);
|
ifstream chipStateFile(CHIP_STATE_FILE);
|
||||||
@ -1197,8 +1201,14 @@ void CoreController::performMountedSdCardOperations() {
|
|||||||
if (not performOneShotSdCardOpsSwitch) {
|
if (not performOneShotSdCardOpsSwitch) {
|
||||||
std::ostringstream path;
|
std::ostringstream path;
|
||||||
path << mntPoint << "/" << CONF_FOLDER;
|
path << mntPoint << "/" << CONF_FOLDER;
|
||||||
if (not std::filesystem::exists(path.str())) {
|
std::error_code e;
|
||||||
std::filesystem::create_directory(path.str());
|
if (not std::filesystem::exists(path.str()), e) {
|
||||||
|
bool created = std::filesystem::create_directory(path.str(), e);
|
||||||
|
if (not created) {
|
||||||
|
sif::error << "Could not create CONF folder at " << path.str() << ": " << e.message()
|
||||||
|
<< std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
initVersionFile();
|
initVersionFile();
|
||||||
ReturnValue_t result = initBootCopyFile();
|
ReturnValue_t result = initBootCopyFile();
|
||||||
@ -1283,7 +1293,8 @@ ReturnValue_t CoreController::performSdCardCheck() {
|
|||||||
void CoreController::performRebootFileHandling(bool recreateFile) {
|
void CoreController::performRebootFileHandling(bool recreateFile) {
|
||||||
using namespace std;
|
using namespace std;
|
||||||
std::string path = currMntPrefix + REBOOT_FILE;
|
std::string path = currMntPrefix + REBOOT_FILE;
|
||||||
if (not std::filesystem::exists(path) or recreateFile) {
|
std::error_code e;
|
||||||
|
if (not std::filesystem::exists(path, e) or recreateFile) {
|
||||||
#if OBSW_VERBOSE_LEVEL >= 1
|
#if OBSW_VERBOSE_LEVEL >= 1
|
||||||
sif::info << "CoreController::performRebootFileHandling: Recreating reboot file" << std::endl;
|
sif::info << "CoreController::performRebootFileHandling: Recreating reboot file" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
@ -1750,7 +1761,8 @@ ReturnValue_t CoreController::initClockFromTimeFile() {
|
|||||||
using namespace GpsHyperion;
|
using namespace GpsHyperion;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
std::string fileName = currMntPrefix + BACKUP_TIME_FILE;
|
std::string fileName = currMntPrefix + BACKUP_TIME_FILE;
|
||||||
if (sdcMan->isSdCardUsable(std::nullopt) and std::filesystem::exists(fileName) and
|
std::error_code e;
|
||||||
|
if (sdcMan->isSdCardUsable(std::nullopt) and std::filesystem::exists(fileName, e) and
|
||||||
((gpsFix == FixMode::UNKNOWN or gpsFix == FixMode::NOT_SEEN) or
|
((gpsFix == FixMode::UNKNOWN or gpsFix == FixMode::NOT_SEEN) or
|
||||||
not utility::timeSanityCheck())) {
|
not utility::timeSanityCheck())) {
|
||||||
ifstream timeFile(fileName);
|
ifstream timeFile(fileName);
|
||||||
@ -1875,7 +1887,8 @@ ReturnValue_t CoreController::executeSwUpdate(SwUpdateSources sourceDir, const u
|
|||||||
prefixPath = path("/tmp");
|
prefixPath = path("/tmp");
|
||||||
}
|
}
|
||||||
path archivePath = prefixPath / path(config::OBSW_UPDATE_ARCHIVE_FILE_NAME);
|
path archivePath = prefixPath / path(config::OBSW_UPDATE_ARCHIVE_FILE_NAME);
|
||||||
if (not exists(archivePath)) {
|
std::error_code e;
|
||||||
|
if (not exists(archivePath, e)) {
|
||||||
return HasFileSystemIF::FILE_DOES_NOT_EXIST;
|
return HasFileSystemIF::FILE_DOES_NOT_EXIST;
|
||||||
}
|
}
|
||||||
ostringstream cmd("tar -xJf", ios::app);
|
ostringstream cmd("tar -xJf", ios::app);
|
||||||
@ -1885,12 +1898,12 @@ ReturnValue_t CoreController::executeSwUpdate(SwUpdateSources sourceDir, const u
|
|||||||
utility::handleSystemError(result, "CoreController::executeAction: SW Update Decompression");
|
utility::handleSystemError(result, "CoreController::executeAction: SW Update Decompression");
|
||||||
}
|
}
|
||||||
path strippedImagePath = prefixPath / path(config::STRIPPED_OBSW_BINARY_FILE_NAME);
|
path strippedImagePath = prefixPath / path(config::STRIPPED_OBSW_BINARY_FILE_NAME);
|
||||||
if (!exists(strippedImagePath)) {
|
if (!exists(strippedImagePath, e)) {
|
||||||
// TODO: Custom returnvalue?
|
// TODO: Custom returnvalue?
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
path obswVersionFilePath = prefixPath / path(config::OBSW_VERSION_FILE_NAME);
|
path obswVersionFilePath = prefixPath / path(config::OBSW_VERSION_FILE_NAME);
|
||||||
if (!exists(obswVersionFilePath)) {
|
if (!exists(obswVersionFilePath, e)) {
|
||||||
// TODO: Custom returnvalue?
|
// TODO: Custom returnvalue?
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,8 @@ void WatchdogHandler::periodicOperation() {
|
|||||||
ReturnValue_t WatchdogHandler::initialize(bool enableWatchdogFunction) {
|
ReturnValue_t WatchdogHandler::initialize(bool enableWatchdogFunction) {
|
||||||
using namespace std::filesystem;
|
using namespace std::filesystem;
|
||||||
this->enableWatchFunction = enableWatchdogFunction;
|
this->enableWatchFunction = enableWatchdogFunction;
|
||||||
if (not std::filesystem::exists(watchdog::FIFO_NAME)) {
|
std::error_code e;
|
||||||
|
if (not std::filesystem::exists(watchdog::FIFO_NAME, e)) {
|
||||||
// Still return returnvalue::OK for now
|
// Still return returnvalue::OK for now
|
||||||
sif::info << "Watchdog FIFO " << watchdog::FIFO_NAME << " does not exist, can't initiate"
|
sif::info << "Watchdog FIFO " << watchdog::FIFO_NAME << " does not exist, can't initiate"
|
||||||
<< " watchdog" << std::endl;
|
<< " watchdog" << std::endl;
|
||||||
|
@ -198,7 +198,8 @@ ReturnValue_t SdCardManager::setSdCardState(sd::SdCard sdCard, bool on) {
|
|||||||
ReturnValue_t SdCardManager::getSdCardsStatus(SdStatePair& active) {
|
ReturnValue_t SdCardManager::getSdCardsStatus(SdStatePair& active) {
|
||||||
using namespace std;
|
using namespace std;
|
||||||
MutexGuard mg(sdLock, LOCK_TYPE, SD_LOCK_TIMEOUT, LOCK_CTX);
|
MutexGuard mg(sdLock, LOCK_TYPE, SD_LOCK_TIMEOUT, LOCK_CTX);
|
||||||
if (not filesystem::exists(SD_STATE_FILE)) {
|
std::error_code e;
|
||||||
|
if (not filesystem::exists(SD_STATE_FILE, e)) {
|
||||||
return STATUS_FILE_NEXISTS;
|
return STATUS_FILE_NEXISTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,7 +240,8 @@ ReturnValue_t SdCardManager::mountSdCard(sd::SdCard sdCard) {
|
|||||||
mountDev = SD_1_DEV_NAME;
|
mountDev = SD_1_DEV_NAME;
|
||||||
mountPoint = config::SD_1_MOUNT_POINT;
|
mountPoint = config::SD_1_MOUNT_POINT;
|
||||||
}
|
}
|
||||||
if (not filesystem::exists(mountDev)) {
|
std::error_code e;
|
||||||
|
if (not filesystem::exists(mountDev, e)) {
|
||||||
sif::warning << "SdCardManager::mountSdCard: Device file does not exists. Make sure to"
|
sif::warning << "SdCardManager::mountSdCard: Device file does not exists. Make sure to"
|
||||||
" turn on the SD card"
|
" turn on the SD card"
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
@ -274,7 +276,8 @@ ReturnValue_t SdCardManager::unmountSdCard(sd::SdCard sdCard) {
|
|||||||
} else if (sdCard == sd::SdCard::SLOT_1) {
|
} else if (sdCard == sd::SdCard::SLOT_1) {
|
||||||
mountPoint = config::SD_1_MOUNT_POINT;
|
mountPoint = config::SD_1_MOUNT_POINT;
|
||||||
}
|
}
|
||||||
if (not filesystem::exists(mountPoint)) {
|
std::error_code e;
|
||||||
|
if (not filesystem::exists(mountPoint, e)) {
|
||||||
sif::error << "SdCardManager::unmountSdCard: Default mount point " << mountPoint
|
sif::error << "SdCardManager::unmountSdCard: Default mount point " << mountPoint
|
||||||
<< "does not exist" << std::endl;
|
<< "does not exist" << std::endl;
|
||||||
return UNMOUNT_ERROR;
|
return UNMOUNT_ERROR;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef BSP_Q7S_MEMORY_LOCALPARAMETERHANDLER_H_
|
#ifndef BSP_Q7S_MEMORY_LOCALPARAMETERHANDLER_H_
|
||||||
#define BSP_Q7S_MEMORY_LOCALPARAMETERHANDLER_H_
|
#define BSP_Q7S_MEMORY_LOCALPARAMETERHANDLER_H_
|
||||||
|
|
||||||
#include <mission/memory/NVMParameterBase.h>
|
#include <mission/memory/NvmParameterBase.h>
|
||||||
#include <mission/memory/SdCardMountedIF.h>
|
#include <mission/memory/SdCardMountedIF.h>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -37,9 +37,10 @@ int obsw::obsw(int argc, char* argv[]) {
|
|||||||
std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl;
|
std::cout << "-- " << __DATE__ << " " << __TIME__ << " --" << std::endl;
|
||||||
|
|
||||||
#if Q7S_CHECK_FOR_ALREADY_RUNNING_IMG == 1
|
#if Q7S_CHECK_FOR_ALREADY_RUNNING_IMG == 1
|
||||||
|
std::error_code e;
|
||||||
// Check special file here. This file is created or deleted by the eive-watchdog application
|
// Check special file here. This file is created or deleted by the eive-watchdog application
|
||||||
// or systemd service!
|
// or systemd service!
|
||||||
if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) {
|
if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME, e)) {
|
||||||
sif::warning << "File " << watchdog::RUNNING_FILE_NAME
|
sif::warning << "File " << watchdog::RUNNING_FILE_NAME
|
||||||
<< " exists so the software might "
|
<< " exists so the software might "
|
||||||
"already be running. Check if obsw systemd service has been stopped."
|
"already be running. Check if obsw systemd service has been stopped."
|
||||||
@ -84,8 +85,9 @@ void obsw::bootDelayHandling() {
|
|||||||
homedir = getpwuid(getuid())->pw_dir;
|
homedir = getpwuid(getuid())->pw_dir;
|
||||||
}
|
}
|
||||||
std::filesystem::path bootDelayFile = std::filesystem::path(homedir) / "boot_delay_secs.txt";
|
std::filesystem::path bootDelayFile = std::filesystem::path(homedir) / "boot_delay_secs.txt";
|
||||||
|
std::error_code e;
|
||||||
// Init delay handling.
|
// Init delay handling.
|
||||||
if (std::filesystem::exists(bootDelayFile)) {
|
if (std::filesystem::exists(bootDelayFile, e)) {
|
||||||
std::ifstream ifile(bootDelayFile);
|
std::ifstream ifile(bootDelayFile);
|
||||||
std::string lineStr;
|
std::string lineStr;
|
||||||
unsigned int bootDelaySecs = 0;
|
unsigned int bootDelaySecs = 0;
|
||||||
|
2
fsfw
2
fsfw
@ -1 +1 @@
|
|||||||
Subproject commit 7f6ba5f40b47bc32802efdc4ed41b4bad4b8071b
|
Subproject commit 26e4445189b676eaee11840e5a9d0ede25cf3896
|
@ -540,8 +540,10 @@ ReturnValue_t Guidance::getDistributionMatrixRw(ACS::SensorValues *sensorValues,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Guidance::getTargetParamsSafe(double sunTargetSafe[3], double satRateSafe[3]) {
|
void Guidance::getTargetParamsSafe(double sunTargetSafe[3], double satRateSafe[3]) {
|
||||||
if (not std::filesystem::exists(SD_0_SKEWED_PTG_FILE) or
|
std::error_code e;
|
||||||
not std::filesystem::exists(SD_1_SKEWED_PTG_FILE)) { // ToDo: if file does not exist anymore
|
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,
|
std::memcpy(sunTargetSafe, acsParameters.safeModeControllerParameters.sunTargetDir,
|
||||||
3 * sizeof(double));
|
3 * sizeof(double));
|
||||||
} else {
|
} else {
|
||||||
@ -553,15 +555,16 @@ void Guidance::getTargetParamsSafe(double sunTargetSafe[3], double satRateSafe[3
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t Guidance::solarArrayDeploymentComplete() {
|
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);
|
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;
|
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);
|
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;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -319,11 +319,14 @@ void ScexDeviceHandler::performOperationHook() {
|
|||||||
auto mntPrefix = sdcMan.getCurrentMountPrefix();
|
auto mntPrefix = sdcMan.getCurrentMountPrefix();
|
||||||
if (mntPrefix != nullptr) {
|
if (mntPrefix != nullptr) {
|
||||||
std::filesystem::path fullFilePath = mntPrefix;
|
std::filesystem::path fullFilePath = mntPrefix;
|
||||||
|
std::error_code e;
|
||||||
fullFilePath /= "scex";
|
fullFilePath /= "scex";
|
||||||
bool fileExists = std::filesystem::exists(fullFilePath);
|
bool fileExists = std::filesystem::exists(fullFilePath, e);
|
||||||
|
|
||||||
if (not fileExists) {
|
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();
|
uint32_t remainingMillis = finishCountdown.getRemainingMillis();
|
||||||
|
@ -43,15 +43,16 @@ ReturnValue_t SolarArrayDeploymentHandler::performOperation(uint8_t operationCod
|
|||||||
#endif
|
#endif
|
||||||
if (opDivider.checkAndIncrement()) {
|
if (opDivider.checkAndIncrement()) {
|
||||||
auto activeSdc = sdcMan.getActiveSdCard();
|
auto activeSdc = sdcMan.getActiveSdCard();
|
||||||
|
std::error_code e;
|
||||||
if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_0 and
|
if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_0 and
|
||||||
sdcMan.isSdCardUsable(activeSdc.value())) {
|
sdcMan.isSdCardUsable(activeSdc.value())) {
|
||||||
if (exists(SD_0_DEPL_FILE)) {
|
if (exists(SD_0_DEPL_FILE, e)) {
|
||||||
// perform autonomous deployment handling
|
// perform autonomous deployment handling
|
||||||
performAutonomousDepl(sd::SdCard::SLOT_0, dryRunStringInFile(SD_0_DEPL_FILE));
|
performAutonomousDepl(sd::SdCard::SLOT_0, dryRunStringInFile(SD_0_DEPL_FILE));
|
||||||
}
|
}
|
||||||
} else if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_1 and
|
} else if (activeSdc and activeSdc.value() == sd::SdCard::SLOT_1 and
|
||||||
sdcMan.isSdCardUsable(activeSdc.value())) {
|
sdcMan.isSdCardUsable(activeSdc.value())) {
|
||||||
if (exists(SD_1_DEPL_FILE)) {
|
if (exists(SD_1_DEPL_FILE, e)) {
|
||||||
// perform autonomous deployment handling
|
// perform autonomous deployment handling
|
||||||
performAutonomousDepl(sd::SdCard::SLOT_1, dryRunStringInFile(SD_1_DEPL_FILE));
|
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 << "phase: init\n";
|
||||||
of << "secs_since_start: 0\n";
|
of << "secs_since_start: 0\n";
|
||||||
};
|
};
|
||||||
|
std::error_code e;
|
||||||
if (sdCard == sd::SdCard::SLOT_0) {
|
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);
|
initFile(SD_0_DEPLY_INFO);
|
||||||
}
|
}
|
||||||
if (not autonomousDeplForFile(sd::SdCard::SLOT_0, SD_0_DEPLY_INFO, dryRun)) {
|
if (not autonomousDeplForFile(sd::SdCard::SLOT_0, SD_0_DEPLY_INFO, dryRun)) {
|
||||||
initFile(SD_0_DEPLY_INFO);
|
initFile(SD_0_DEPLY_INFO);
|
||||||
}
|
}
|
||||||
} else if (sdCard == sd::SdCard::SLOT_1) {
|
} 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);
|
initFile(SD_1_DEPLY_INFO);
|
||||||
}
|
}
|
||||||
if (not autonomousDeplForFile(sd::SdCard::SLOT_1, SD_1_DEPLY_INFO, dryRun)) {
|
if (not autonomousDeplForFile(sd::SdCard::SLOT_1, SD_1_DEPLY_INFO, dryRun)) {
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||||
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
|
#include <fsfw/devicehandlers/DeviceHandlerIF.h>
|
||||||
|
#include <mission/memory/NvmParameterBase.h>
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
@ -10,7 +11,6 @@
|
|||||||
|
|
||||||
#include "OBSWConfig.h"
|
#include "OBSWConfig.h"
|
||||||
#include "mission/devices/max1227.h"
|
#include "mission/devices/max1227.h"
|
||||||
#include "mission/memory/NVMParameterBase.h"
|
|
||||||
|
|
||||||
namespace plpcdu {
|
namespace plpcdu {
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
target_sources(${LIB_EIVE_MISSION} PRIVATE NVMParameterBase.cpp)
|
target_sources(${LIB_EIVE_MISSION} PRIVATE NvmParameterBase.cpp)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include "NVMParameterBase.h"
|
#include <mission/memory/NvmParameterBase.h>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
@ -10,13 +10,14 @@ NVMParameterBase::NVMParameterBase(std::string fullName) : fullName(fullName) {}
|
|||||||
NVMParameterBase::NVMParameterBase() {}
|
NVMParameterBase::NVMParameterBase() {}
|
||||||
|
|
||||||
ReturnValue_t NVMParameterBase::readJsonFile() {
|
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
|
// Read JSON file content into object
|
||||||
std::ifstream i(fullName);
|
std::ifstream i(fullName);
|
||||||
try {
|
try {
|
||||||
i >> json;
|
i >> json;
|
||||||
} catch (nlohmann::json::exception& e) {
|
} catch (nlohmann::json::exception& nlohmannE) {
|
||||||
sif::warning << "Reading JSON file failed with error " << e.what() << std::endl;
|
sif::warning << "Reading JSON file failed with error " << nlohmannE.what() << std::endl;
|
||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
@ -39,7 +40,10 @@ void NVMParameterBase::setFullName(std::string fullName) { this->fullName = full
|
|||||||
|
|
||||||
std::string NVMParameterBase::getFullName() const { return fullName; }
|
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 {
|
void NVMParameterBase::printKeys() const {
|
||||||
sif::info << "Printing keys for JSON file " << fullName << std::endl;
|
sif::info << "Printing keys for JSON file " << fullName << std::endl;
|
@ -174,7 +174,8 @@ bool PersistentTmStore::updateBaseDir() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
basePath = path(currentPrefix) / baseDir / baseName;
|
basePath = path(currentPrefix) / baseDir / baseName;
|
||||||
if (not exists(basePath)) {
|
std::error_code e;
|
||||||
|
if (not exists(basePath, e)) {
|
||||||
create_directories(basePath);
|
create_directories(basePath);
|
||||||
}
|
}
|
||||||
baseDirUninitialized = false;
|
baseDirUninitialized = false;
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
#include <fsfw/serviceinterface/ServiceInterfaceStream.h>
|
||||||
#include <fsfw/storagemanager/StorageManagerIF.h>
|
#include <fsfw/storagemanager/StorageManagerIF.h>
|
||||||
#include <fsfw/tasks/ExecutableObjectIF.h>
|
#include <fsfw/tasks/ExecutableObjectIF.h>
|
||||||
|
#include <mission/memory/NvmParameterBase.h>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@ -22,7 +23,6 @@
|
|||||||
#include "OBSWConfig.h"
|
#include "OBSWConfig.h"
|
||||||
#include "fsfw/parameters/HasParametersIF.h"
|
#include "fsfw/parameters/HasParametersIF.h"
|
||||||
#include "fsfw/parameters/ParameterHelper.h"
|
#include "fsfw/parameters/ParameterHelper.h"
|
||||||
#include "mission/memory/NVMParameterBase.h"
|
|
||||||
|
|
||||||
static std::map<ParamIds, std::string> PARAM_KEY_MAP = {
|
static std::map<ParamIds, std::string> PARAM_KEY_MAP = {
|
||||||
{PARAM0, "Parameter0"},
|
{PARAM0, "Parameter0"},
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#ifndef BSP_Q7S_CORE_NVMPARAMS_PARAMETERDEFINITIONS_H_
|
#ifndef BSP_Q7S_CORE_NVMPARAMS_PARAMETERDEFINITIONS_H_
|
||||||
#define BSP_Q7S_CORE_NVMPARAMS_PARAMETERDEFINITIONS_H_
|
#define BSP_Q7S_CORE_NVMPARAMS_PARAMETERDEFINITIONS_H_
|
||||||
|
|
||||||
|
#include <mission/memory/NvmParameterBase.h>
|
||||||
|
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <nlohmann/json.hpp>
|
#include <nlohmann/json.hpp>
|
||||||
|
|
||||||
#include "mission/memory/NVMParameterBase.h"
|
|
||||||
|
|
||||||
class DummyParameter : public NVMParameterBase {
|
class DummyParameter : public NVMParameterBase {
|
||||||
public:
|
public:
|
||||||
static constexpr char DUMMY_KEY_PARAM_1[] = "dummy1";
|
static constexpr char DUMMY_KEY_PARAM_1[] = "dummy1";
|
||||||
|
@ -18,8 +18,9 @@
|
|||||||
|
|
||||||
WatchdogTask::WatchdogTask() : fd(0) {
|
WatchdogTask::WatchdogTask() : fd(0) {
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
std::error_code e;
|
||||||
// Only create the FIFO if it does not exist yet
|
// Only create the FIFO if it does not exist yet
|
||||||
if (not std::filesystem::exists(watchdog::FIFO_NAME)) {
|
if (not std::filesystem::exists(watchdog::FIFO_NAME, e)) {
|
||||||
// Permission 666 or rw-rw-rw-
|
// Permission 666 or rw-rw-rw-
|
||||||
mode_t mode = DEFFILEMODE;
|
mode_t mode = DEFFILEMODE;
|
||||||
result = mkfifo(watchdog::FIFO_NAME.c_str(), mode);
|
result = mkfifo(watchdog::FIFO_NAME.c_str(), mode);
|
||||||
@ -167,7 +168,8 @@ int WatchdogTask::performRunningOperation() {
|
|||||||
std::cout << "OBSW is running" << std::endl;
|
std::cout << "OBSW is running" << std::endl;
|
||||||
#if WATCHDOG_CREATE_FILE_IF_RUNNING == 1
|
#if WATCHDOG_CREATE_FILE_IF_RUNNING == 1
|
||||||
std::cout << "Creating " << watchdog::RUNNING_FILE_NAME << std::endl;
|
std::cout << "Creating " << watchdog::RUNNING_FILE_NAME << std::endl;
|
||||||
if (not std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) {
|
std::error_code e;
|
||||||
|
if (not std::filesystem::exists(watchdog::RUNNING_FILE_NAME, e)) {
|
||||||
std::ofstream obswRunningFile(watchdog::RUNNING_FILE_NAME);
|
std::ofstream obswRunningFile(watchdog::RUNNING_FILE_NAME);
|
||||||
if (not obswRunningFile.good()) {
|
if (not obswRunningFile.good()) {
|
||||||
std::cerr << "Creating file " << watchdog::RUNNING_FILE_NAME << " failed" << std::endl;
|
std::cerr << "Creating file " << watchdog::RUNNING_FILE_NAME << " failed" << std::endl;
|
||||||
@ -196,7 +198,8 @@ int WatchdogTask::performNotRunningOperation(LoopResult type) {
|
|||||||
if (obswRunning) {
|
if (obswRunning) {
|
||||||
#if WATCHDOG_CREATE_FILE_IF_RUNNING == 1
|
#if WATCHDOG_CREATE_FILE_IF_RUNNING == 1
|
||||||
std::cout << "Removing " << watchdog::RUNNING_FILE_NAME << std::endl;
|
std::cout << "Removing " << watchdog::RUNNING_FILE_NAME << std::endl;
|
||||||
if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) {
|
std::error_code e;
|
||||||
|
if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME, e)) {
|
||||||
int result = std::remove(watchdog::RUNNING_FILE_NAME.c_str());
|
int result = std::remove(watchdog::RUNNING_FILE_NAME.c_str());
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
std::cerr << "Removing " << watchdog::RUNNING_FILE_NAME << " failed with code " << errno
|
std::cerr << "Removing " << watchdog::RUNNING_FILE_NAME << " failed with code " << errno
|
||||||
|
@ -12,7 +12,8 @@
|
|||||||
*/
|
*/
|
||||||
int main() {
|
int main() {
|
||||||
std::cout << "Starting OBSW watchdog" << std::endl;
|
std::cout << "Starting OBSW watchdog" << std::endl;
|
||||||
if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME)) {
|
std::error_code e;
|
||||||
|
if (std::filesystem::exists(watchdog::RUNNING_FILE_NAME, e)) {
|
||||||
std::cout << "Removing " << watchdog::RUNNING_FILE_NAME << std::endl;
|
std::cout << "Removing " << watchdog::RUNNING_FILE_NAME << std::endl;
|
||||||
int result = std::remove(watchdog::RUNNING_FILE_NAME.c_str());
|
int result = std::remove(watchdog::RUNNING_FILE_NAME.c_str());
|
||||||
if (result != 0) {
|
if (result != 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user