Merge pull request 'Init Boot Delay OBSW' (#340) from mueller_init_boot_delay_obsw into develop
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

Reviewed-on: #340
Reviewed-by: Jakob Meier <meierj@irs.uni-stuttgart.de>
This commit is contained in:
Jakob Meier 2023-01-13 17:18:51 +01:00
commit d144502f1c
2 changed files with 41 additions and 0 deletions

View File

@ -10,6 +10,13 @@ list yields a list of all related PRs for each release.
# [unreleased]
## Added
- The Q7S SW now checks for a file named `boot_delay_secs.stxt` in the home directory.
If it exists and the file is empty, it will delay for 6 seconds before continuing
with the regular boot. It can also try to read delay seconds from the file.
PR: https://egit.irs.uni-stuttgart.de/eive/eive-obsw/pulls/340.
## Changed
- Bumped FSFW for Service 11 improvement which includes size and CRC check for contained TC

View File

@ -1,8 +1,13 @@
#include "obsw.h"
#include <filesystem>
#include <fstream>
#include <iostream>
#include <unistd.h>
#include <sys/types.h>
#include <pwd.h>
#include "OBSWConfig.h"
#include "commonConfig.h"
#include "core/scheduling.h"
@ -36,6 +41,35 @@ int obsw::obsw() {
return OBSW_ALREADY_RUNNING;
}
#endif
const char* homedir = nullptr;
homedir = getenv("HOME");
if(homedir == nullptr) {
homedir = getpwuid(getuid())->pw_dir;
}
std::filesystem::path bootDelayFile = std::filesystem::path(homedir) / "boot_delay_secs.txt";
// Init delay handling.
if (std::filesystem::exists(bootDelayFile)) {
std::ifstream ifile(bootDelayFile);
std::string lineStr;
unsigned int bootDelaySecs = 0;
unsigned int line = 0;
// Try to reas delay seconds from file.
while (std::getline(ifile, lineStr)) {
std::istringstream iss(lineStr);
if (!(iss >> bootDelaySecs)) {
break;
}
line++;
}
if (line == 0) {
// If the file is empty, assume default of 6 seconds
bootDelaySecs = 6;
}
std::cout << "Delaying OBSW start for " << bootDelaySecs << " seconds" << std::endl;
TaskFactory::delayTask(bootDelaySecs * 1000);
}
scheduling::initMission();
for (;;) {