diff --git a/CHANGELOG.md b/CHANGELOG.md index e04ce0f6..463e983d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/bsp_q7s/obsw.cpp b/bsp_q7s/obsw.cpp index d497eceb..dd0c486b 100644 --- a/bsp_q7s/obsw.cpp +++ b/bsp_q7s/obsw.cpp @@ -1,8 +1,13 @@ #include "obsw.h" #include +#include #include +#include +#include +#include + #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 (;;) {