continued a bit
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2021-08-05 18:37:14 +02:00
parent 05088ce02c
commit f0e282c6e1
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
5 changed files with 43 additions and 25 deletions

View File

@ -159,18 +159,18 @@ ReturnValue_t CoreController::initSdCardNonBlocking() {
SdCardManager::Operations operation;
SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation);
if(status == SdCardManager::OpStatus::SUCCESS) {
state = SdStates::SET_STATE;
state = SdStates::SET_STATE_SELF;
commandExecuted = false;
sdcInitCycleCount = 0;
}
else if(sdcInitCycleCount > 2) {
else if(sdcInitCycleCount > 4) {
sif::warning << "CoreController::initSdCardNonBlocking: "
"Updating SDC file takes too long" << std::endl;
}
}
}
if(state == SdStates::SET_STATE) {
if(state == SdStates::SET_STATE_SELF) {
if(not commandExecuted) {
determinePreferredSdCard();
statusPair = SdCardManager::SdStatusPair(sd::SdState::OFF, sd::SdState::OFF);
@ -250,6 +250,7 @@ ReturnValue_t CoreController::initSdCardNonBlocking() {
}
}
sdcInitCycleCount++;
return HasReturnvaluesIF::RETURN_OK;
#endif /* Q7S_SD_CARD_CONFIG != Q7S_SD_NONE */
}
@ -290,7 +291,7 @@ ReturnValue_t CoreController::sdCardSetup(SdCardManager::SdStatusPair& statusPai
return sdcMan->switchOnSdCard(sdCard, true, &statusPair);
}
else {
if(state == SdStates::SET_STATE) {
if(state == SdStates::SET_STATE_SELF) {
sif::info << "Switching on SD card" << std::endl;
return sdcMan->switchOnSdCard(sdCard, false, &statusPair);
}
@ -303,7 +304,7 @@ ReturnValue_t CoreController::sdCardSetup(SdCardManager::SdStatusPair& statusPai
return sdcMan->mountSdCard(sdCard);
}
else {
if(state == SdStates::SET_STATE) {
if(state == SdStates::SET_STATE_SELF) {
return SdCardManager::ALREADY_ON;
}
if(state == SdStates::MOUNT) {
@ -379,6 +380,7 @@ ReturnValue_t CoreController::sdCardColdRedundantInit(SdCardManager* sdcMan,
otherString = "0";
}
if(step != SdStates::SET_STATE_OTHER) {
result = sdCardSetup(statusPair, preferredSdCard, preferredString);
if(result != SdCardManager::ALREADY_MOUNTED and result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "Setting up preferred card " << otherString <<
@ -387,17 +389,23 @@ ReturnValue_t CoreController::sdCardColdRedundantInit(SdCardManager* sdcMan,
sdCardSetup(statusPair, preferredSdCard, preferredString);
result = HasReturnvaluesIF::RETURN_FAILED;
}
}
if(BLOCKING_SD_INIT or (not BLOCKING_SD_INIT and state == SdStates::SET_STATE_OTHER)) {
// Don't disable other card if enabling the first one already failed
// Otherwise, try to turn off the other SD card
if(result != HasReturnvaluesIF::RETURN_FAILED and otherStatus != sd::SdState::OFF) {
sif::info << "Switching off secondary SD card " << otherString << std::endl;
// Switch off other SD card in cold redundant mode if setting up preferred one walked
// Switch off other SD card in cold redundant mode if setting up preferred one worked
// without issues
result = sdcMan->switchOffSdCard(otherSdc, otherStatus, &statusPair);
if(result != HasReturnvaluesIF::RETURN_OK and result != SdCardManager::ALREADY_OFF) {
ReturnValue_t result2 = sdcMan->switchOffSdCard(otherSdc, otherStatus, &statusPair);
if(result2 != HasReturnvaluesIF::RETURN_OK and result2 != SdCardManager::ALREADY_OFF) {
sif::warning << "Switching off secondary SD card " << otherString <<
" in cold redundant mode failed" << std::endl;
}
}
}
return result;
}

View File

@ -64,12 +64,13 @@ private:
NONE,
START,
GET_INFO,
SET_STATE,
SET_STATE_SELF,
SET_STATE_OTHER,
MOUNT,
UPDATE_INFO,
DONE
};
static constexpr bool BLOCKING_SD_INIT = true;
static constexpr bool BLOCKING_SD_INIT = false;
SdCardManager* sdcMan = nullptr;
uint16_t sdcInitCycleCount = 0;

View File

@ -386,16 +386,21 @@ SdCardManager::OpStatus SdCardManager::checkCurrentOp(Operations &currentOp) {
currentOp = this->currentOp;
bool bytesRead = false;
#if OBSW_ENABLE_TIMERS == 1
Timer timer;
timer.setTimer(200);
timer.setTimer(100);
uint32_t remainingTimeMs = 0;
#endif
while(true) {
ReturnValue_t result = cmdExecutor.check(bytesRead);
// This timer can prevent deadlocks due to missconfigurations
#if OBSW_ENABLE_TIMERS == 1
timer.getTimer(&remainingTimeMs);
if(remainingTimeMs == 0) {
sif::error << "SdCardManager::checkCurrentOp: Timeout!" << std::endl;
return OpStatus::FAIL;
}
#endif
switch(result) {
case(CommandExecutor::BYTES_READ): {
continue;

2
fsfw

@ -1 +1 @@
Subproject commit 6073abb12db23decbc9d69f4b6342f4f6f1247bd
Subproject commit 3704d2b8295152652a4c7836b595223d8fa3767d

View File

@ -22,6 +22,10 @@
debugging. */
#define OBSW_VERBOSE_LEVEL 1
//! Timers can mess up the code when debugging
//! TODO: Enable for mission code, disable for debug code
#define OBSW_ENABLE_TIMERS 0
#define OBSW_PRINT_MISSED_DEADLINES 1
#define OBSW_ADD_TEST_CODE 1
#define OBSW_ADD_TEST_PST 1