From 83361a5e16d614fef843e4ce780be3e7819c9bde Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 Jan 2023 11:43:44 +0100 Subject: [PATCH 1/5] add init boot delay handling in OBSW --- bsp_q7s/obsw.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/bsp_q7s/obsw.cpp b/bsp_q7s/obsw.cpp index d497eceb..881c03e1 100644 --- a/bsp_q7s/obsw.cpp +++ b/bsp_q7s/obsw.cpp @@ -36,6 +36,28 @@ int obsw::obsw() { return OBSW_ALREADY_RUNNING; } #endif + + // Init delay handling. + if(std::filesystem::exists("$HOME/boot_delay.txt")) { + std::ifstream ifile("$HOME/boot_delay.txt"); + 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; + } + TaskFactory::delayTask(bootDelaySecs); + } + scheduling::initMission(); for (;;) { -- 2.34.1 From 4ebf73bd03b88ac03341e53c1adef5d1adf87362 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 Jan 2023 11:44:16 +0100 Subject: [PATCH 2/5] include missing type --- bsp_q7s/obsw.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/bsp_q7s/obsw.cpp b/bsp_q7s/obsw.cpp index 881c03e1..6b179058 100644 --- a/bsp_q7s/obsw.cpp +++ b/bsp_q7s/obsw.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "OBSWConfig.h" #include "commonConfig.h" -- 2.34.1 From 3f079b415d0b83e9cb07cbb94b42b542a9325fe7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 Jan 2023 11:59:11 +0100 Subject: [PATCH 3/5] small tweaks --- bsp_q7s/obsw.cpp | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/bsp_q7s/obsw.cpp b/bsp_q7s/obsw.cpp index 6b179058..6f42d984 100644 --- a/bsp_q7s/obsw.cpp +++ b/bsp_q7s/obsw.cpp @@ -1,8 +1,8 @@ #include "obsw.h" #include -#include #include +#include #include "OBSWConfig.h" #include "commonConfig.h" @@ -39,24 +39,25 @@ int obsw::obsw() { #endif // Init delay handling. - if(std::filesystem::exists("$HOME/boot_delay.txt")) { - std::ifstream ifile("$HOME/boot_delay.txt"); - 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; - } - TaskFactory::delayTask(bootDelaySecs); + if (std::filesystem::exists("$HOME/boot_delay_secs.txt")) { + std::ifstream ifile("$HOME/boot_delay_secs.txt"); + 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); } scheduling::initMission(); -- 2.34.1 From 9e9aa71e9b8924f57edcfe47d6cc36ef830c1413 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 Jan 2023 13:14:11 +0100 Subject: [PATCH 4/5] this works --- bsp_q7s/obsw.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bsp_q7s/obsw.cpp b/bsp_q7s/obsw.cpp index 6f42d984..dd0c486b 100644 --- a/bsp_q7s/obsw.cpp +++ b/bsp_q7s/obsw.cpp @@ -4,6 +4,10 @@ #include #include +#include +#include +#include + #include "OBSWConfig.h" #include "commonConfig.h" #include "core/scheduling.h" @@ -38,9 +42,15 @@ int obsw::obsw() { } #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("$HOME/boot_delay_secs.txt")) { - std::ifstream ifile("$HOME/boot_delay_secs.txt"); + if (std::filesystem::exists(bootDelayFile)) { + std::ifstream ifile(bootDelayFile); std::string lineStr; unsigned int bootDelaySecs = 0; unsigned int line = 0; @@ -57,7 +67,7 @@ int obsw::obsw() { bootDelaySecs = 6; } std::cout << "Delaying OBSW start for " << bootDelaySecs << " seconds" << std::endl; - TaskFactory::delayTask(bootDelaySecs); + TaskFactory::delayTask(bootDelaySecs * 1000); } scheduling::initMission(); -- 2.34.1 From f6706c4f9bc83e4ed70edbebd09aabf98062be7e Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Fri, 13 Jan 2023 13:16:26 +0100 Subject: [PATCH 5/5] update changelog --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) 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 -- 2.34.1