prep for leap seconds
Some checks failed
EIVE/eive-obsw/pipeline/pr-main There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/pr-main There was a failure building this commit
This commit is contained in:
parent
cda2a9df33
commit
2a2a173ebd
@ -480,6 +480,13 @@ ReturnValue_t CoreController::executeAction(ActionId_t actionId, MessageQueueId_
|
||||
successRecipient = commandedBy;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
case (UPDATE_LEAP_SECONDS): {
|
||||
ReturnValue_t result = actionUpdateLeapSeconds();
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
return HasActionsIF::EXECUTION_FINISHED;
|
||||
}
|
||||
default: {
|
||||
return HasActionsIF::INVALID_ACTION_ID;
|
||||
}
|
||||
@ -2066,9 +2073,60 @@ ReturnValue_t CoreController::backupTimeFileHandler() {
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void CoreController::initLeapSeconds() {
|
||||
ReturnValue_t result = initLeapSecondsFromFile();
|
||||
if (result != returnvalue::OK) {
|
||||
Clock::setLeapSeconds(config::LEAP_SECONDS);
|
||||
writeLeapSecondsToFile(config::LEAP_SECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
ReturnValue_t CoreController::initLeapSecondsFromFile() {
|
||||
std::string fileName = currMntPrefix + LEAP_SECONDS_FILE;
|
||||
std::error_code e;
|
||||
if (sdcMan->isSdCardUsable(std::nullopt) and std::filesystem::exists(fileName, e)) {
|
||||
std::ifstream leapSecondsFile(fileName);
|
||||
std::string nextWord;
|
||||
std::getline(leapSecondsFile, nextWord);
|
||||
std::istringstream iss(nextWord);
|
||||
iss >> nextWord;
|
||||
if (iss.bad() or nextWord != "LEAP") {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
iss >> nextWord;
|
||||
if (iss.bad() or nextWord != "SECONDS:") {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
iss >> nextWord;
|
||||
uint16_t leapSeconds = 0;
|
||||
size_t checkPtr;
|
||||
leapSeconds = std::stoi(nextWord.c_str(), &checkPtr, 10);
|
||||
if (iss.bad() or *checkPtr) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
Clock::setLeapSeconds(leapSeconds);
|
||||
return returnvalue::OK;
|
||||
}
|
||||
return returnvalue::FAILED;
|
||||
};
|
||||
|
||||
ReturnValue_t CoreController::writeLeapSecondsToFile(const uint16_t leapSeconds) {
|
||||
std::string fileName = currMntPrefix + LEAP_SECONDS_FILE;
|
||||
if (sdcMan->isSdCardUsable(std::nullopt)) {
|
||||
std::ofstream leapSecondsFile(fileName.c_str(), std::ofstream::out | std::ofstream::trunc);
|
||||
if (leapSecondsFile.is_open()) {
|
||||
leapSecondsFile << "LEAP SECONDS: " << leapSeconds << std::endl;
|
||||
}
|
||||
}
|
||||
return returnvalue::FAILED;
|
||||
};
|
||||
|
||||
ReturnValue_t CoreController::actionUpdateLeapSeconds() { ; }
|
||||
|
||||
ReturnValue_t CoreController::initClockFromTimeFile() {
|
||||
using namespace GpsHyperion;
|
||||
using namespace std;
|
||||
|
||||
std::string fileName = currMntPrefix + BACKUP_TIME_FILE;
|
||||
std::error_code e;
|
||||
if (sdcMan->isSdCardUsable(std::nullopt) and std::filesystem::exists(fileName, e) and
|
||||
|
@ -150,6 +150,8 @@ class CoreController : public ExtendedControllerBase, public ReceivesParameterMe
|
||||
std::string(core::LEGACY_REBOOT_WATCHDOG_FILE_NAME);
|
||||
const std::string REBOOT_WATCHDOG_FILE =
|
||||
"/" + std::string(core::CONF_FOLDER) + "/" + std::string(core::REBOOT_WATCHDOG_FILE_NAME);
|
||||
const std::string LEAP_SECONDS_FILE =
|
||||
"/" + std::string(core::CONF_FOLDER) + "/" + std::string(core::LEAP_SECONDS_FILE_NAME);
|
||||
const std::string BACKUP_TIME_FILE =
|
||||
"/" + std::string(core::CONF_FOLDER) + "/" + std::string(core::TIME_FILE_NAME);
|
||||
const std::string REBOOT_COUNTERS_FILE =
|
||||
@ -335,7 +337,11 @@ class CoreController : public ExtendedControllerBase, public ReceivesParameterMe
|
||||
void performMountedSdCardOperations();
|
||||
ReturnValue_t initVersionFile();
|
||||
|
||||
void initLeapSeconds();
|
||||
ReturnValue_t initLeapSecondsFromFile();
|
||||
ReturnValue_t initClockFromTimeFile();
|
||||
ReturnValue_t actionUpdateLeapSeconds();
|
||||
ReturnValue_t writeLeapSecondsToFile(const uint16_t leapSeconds);
|
||||
ReturnValue_t performSdCardCheck();
|
||||
ReturnValue_t backupTimeFileHandler();
|
||||
ReturnValue_t initBootCopyFile();
|
||||
|
@ -20,6 +20,9 @@ static constexpr char OBSW_VERSION_FILE_PATH[] = "/usr/share/eive-obsw/obsw_vers
|
||||
// ISO8601 timestamp.
|
||||
static constexpr char FILE_DATE_FORMAT[] = "%FT%H%M%SZ";
|
||||
|
||||
// Leap Seconds as of 2024-03-04
|
||||
static constexpr uint16_t LEAP_SECONDS = 37;
|
||||
|
||||
static constexpr uint16_t EIVE_PUS_APID = 0x65;
|
||||
static constexpr uint16_t EIVE_CFDP_APID = 0x66;
|
||||
static constexpr uint16_t EIVE_LOCAL_CFDP_ENTITY_ID = EIVE_CFDP_APID;
|
||||
|
@ -55,6 +55,7 @@ static constexpr char VERSION_FILE_NAME[] = "version.txt";
|
||||
static constexpr char LEGACY_REBOOT_WATCHDOG_FILE_NAME[] = "reboot.txt";
|
||||
static constexpr char REBOOT_WATCHDOG_FILE_NAME[] = "reboot_watchdog.txt";
|
||||
static constexpr char REBOOT_COUNTER_FILE_NAME[] = "reboot_counters.txt";
|
||||
static constexpr char LEAP_SECONDS_FILE_NAME[] = "leapseconds.txt";
|
||||
static constexpr char TIME_FILE_NAME[] = "time_backup.txt";
|
||||
|
||||
static constexpr uint32_t SYS_ROM_BASE_ADDR = 0x80000000;
|
||||
@ -93,6 +94,8 @@ static constexpr ActionId_t MV_HELPER = 53;
|
||||
static constexpr ActionId_t RM_HELPER = 54;
|
||||
static constexpr ActionId_t MKDIR_HELPER = 55;
|
||||
|
||||
static constexpr ActionId_t UPDATE_LEAP_SECONDS = 60;
|
||||
|
||||
static constexpr uint8_t SUBSYSTEM_ID = SUBSYSTEM_ID::CORE;
|
||||
|
||||
static constexpr Event ALLOC_FAILURE = event::makeEvent(SUBSYSTEM_ID, 0, severity::MEDIUM);
|
||||
|
Loading…
Reference in New Issue
Block a user