improved mount logic, create conf folder is missing
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit

This commit is contained in:
Robin Müller 2022-02-28 16:35:16 +01:00
parent 8e6d8a6fa8
commit a2bc72a798
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
5 changed files with 177 additions and 174 deletions

View File

@ -59,7 +59,7 @@ ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) {
void CoreController::performControlOperation() {
performWatchdogControlOperation();
sdStateMachine();
performRebootFileHandling(false);
performMountedSdCardOperations();
}
ReturnValue_t CoreController::initializeLocalDataPool(localpool::DataPool &localDataPoolMap,
@ -94,7 +94,7 @@ ReturnValue_t CoreController::initializeAfterTaskCreation() {
}
}
sdStateMachine();
result = initVersionFile();
performMountedSdCardOperations();
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "CoreController::initialize: Version initialization failed" << std::endl;
}
@ -1174,19 +1174,12 @@ void CoreController::performWatchdogControlOperation() {
}
void CoreController::performRebootFileHandling(bool recreateFile) {
bool sdCardMounted = false;
if (not recreateFile and doPerformRebootFileHandling) {
sdCardMounted = sdcMan->isSdCardMounted(sdInfo.pref);
}
if ((doPerformRebootFileHandling and sdCardMounted) or recreateFile) {
using namespace std;
if (recreateFile) {
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE;
if (not std::filesystem::exists(path) or recreateFile) {
#if OBSW_VERBOSE_LEVEL >= 1
sif::info << "CoreController::performRebootFileHandling: Recreating reboot file" << std::endl;
#endif
}
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE;
if (not std::filesystem::exists(path) or recreateFile) {
rebootFile.enabled = true;
rebootFile.img00Cnt = 0;
rebootFile.img01Cnt = 0;
@ -1269,8 +1262,6 @@ void CoreController::performRebootFileHandling(bool recreateFile) {
} else {
rewriteRebootFile(rebootFile);
}
doPerformRebootFileHandling = false;
}
}
void CoreController::determineAndExecuteReboot(RebootFile &rf, bool &needsReboot,
@ -1520,6 +1511,22 @@ void CoreController::resetRebootCount(xsc::Chip tgtChip, xsc::Copy tgtCopy) {
rewriteRebootFile(rebootFile);
}
void CoreController::performMountedSdCardOperations() {
if(doPerformMountedSdCardOps) {
bool sdCardMounted = false;
sdCardMounted = sdcMan->isSdCardMounted(sdInfo.pref);
if(sdCardMounted) {
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + "/" + CONF_FOLDER;
if(not std::filesystem::exists(path)) {
std::filesystem::create_directory(path);
}
initVersionFile();
performRebootFileHandling(true);
doPerformMountedSdCardOps = false;
}
}
}
void CoreController::rewriteRebootFile(RebootFile file) {
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE;
std::ofstream rebootFile(path);

View File

@ -43,8 +43,11 @@ class CoreController : public ExtendedControllerBase {
static constexpr char CHIP_PROT_SCRIPT[] = "/home/root/scripts/get-chip-prot-status.sh";
static constexpr char CHIP_STATE_FILE[] = "/tmp/chip_prot_status.txt";
static constexpr char CURR_COPY_FILE[] = "/tmp/curr_copy.txt";
static constexpr char VERSION_FILE[] = "/conf/version.txt";
static constexpr char REBOOT_FILE[] = "/conf/reboot.txt";
static constexpr char CONF_FOLDER[] = "conf";
static constexpr char VERSION_FILE_NAME[] = "version.txt";
static constexpr char REBOOT_FILE_NAME[] = "reboot.txt";
const std::string VERSION_FILE = "/" + std::string(CONF_FOLDER) + "/" + std::string(VERSION_FILE_NAME);
const std::string REBOOT_FILE = "/" + std::string(CONF_FOLDER) + "/" + std::string(REBOOT_FILE_NAME);
static constexpr ActionId_t LIST_DIRECTORY_INTO_FILE = 0;
static constexpr ActionId_t SWITCH_REBOOT_FILE_HANDLING = 5;
@ -162,7 +165,7 @@ class CoreController : public ExtendedControllerBase {
sd::SdState commandedState = sd::SdState::OFF;
} sdInfo;
RebootFile rebootFile = {};
bool doPerformRebootFileHandling = true;
bool doPerformMountedSdCardOps = true;
/**
* Index 0: Chip 0 Copy 0
@ -177,7 +180,7 @@ class CoreController : public ExtendedControllerBase {
LocalDataPoolManager& poolManager) override;
LocalPoolDataSetBase* getDataSetHandle(sid_t sid) override;
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode, uint32_t* msToReachTheMode);
void performMountedSdCardOperations();
ReturnValue_t initVersionFile();
ReturnValue_t initBootCopy();
ReturnValue_t initWatchdogFifo();
@ -189,6 +192,7 @@ class CoreController : public ExtendedControllerBase {
ReturnValue_t sdCardSetup(sd::SdCard sdCard, sd::SdState targetState, std::string sdChar,
bool printOutput = true);
ReturnValue_t sdColdRedundantBlockingInit();
void currentStateSetter(sd::SdCard sdCard, sd::SdState newState);
void determinePreferredSdCard();
void executeNextExternalSdCommand();

2
fsfw

@ -1 +1 @@
Subproject commit 2d9216ba19f1931225daa5b6b6f244a48c09f1b9
Subproject commit 6e0b90696da2dfd2ec4749dfdb73950be2283c25

View File

@ -16,19 +16,12 @@ CoreController::CoreController() {
}
void CoreController::performRebootFileHandling(bool recreateFile) {
bool sdCardMounted = false;
if (not recreateFile and doPerformRebootFileHandling) {
sdCardMounted = sdcMan->isSdCardMounted(sdInfo.pref);
}
if ((doPerformRebootFileHandling and sdCardMounted) or recreateFile) {
using namespace std;
if (recreateFile) {
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE;
if (not std::filesystem::exists(path) or recreateFile) {
#if OBSW_VERBOSE_LEVEL >= 1
std::cout << "CoreController::performRebootFileHandling: Recreating reboot file" << std::endl;
#endif
}
std::string path = sdcMan->getCurrentMountPrefix(sdInfo.pref) + REBOOT_FILE;
if (not std::filesystem::exists(path) or recreateFile) {
rebootFile.enabled = true;
rebootFile.img00Cnt = 0;
rebootFile.img01Cnt = 0;
@ -111,10 +104,9 @@ void CoreController::performRebootFileHandling(bool recreateFile) {
} else {
rewriteRebootFile(rebootFile);
}
doPerformRebootFileHandling = false;
}
}
void CoreController::determineAndExecuteReboot(RebootFile &rf, bool &needsReboot,
xsc::Chip &tgtChip, xsc::Copy &tgtCopy) {
tgtChip = xsc::CHIP_0;

View File

@ -4,5 +4,5 @@
TEST_CASE( "Core Controller Reboot File Handling", "[reboot-file]" ) {
CoreController ctrl;
std::cout << "Hello, world!\n";
ctrl.performRebootFileHandling(true);
}