add init boot delay handling in OBSW

This commit is contained in:
Robin Müller 2023-01-13 11:43:44 +01:00
parent 3ae08a4a57
commit 83361a5e16
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
1 changed files with 22 additions and 0 deletions

View File

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