Merge remote-tracking branch 'origin/develop' into heater_handling
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
2023-01-17 15:37:57 +01:00
5 changed files with 46 additions and 5 deletions

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