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();