This commit is contained in:
parent
05088ce02c
commit
f0e282c6e1
@ -159,18 +159,18 @@ ReturnValue_t CoreController::initSdCardNonBlocking() {
|
|||||||
SdCardManager::Operations operation;
|
SdCardManager::Operations operation;
|
||||||
SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation);
|
SdCardManager::OpStatus status = sdcMan->checkCurrentOp(operation);
|
||||||
if(status == SdCardManager::OpStatus::SUCCESS) {
|
if(status == SdCardManager::OpStatus::SUCCESS) {
|
||||||
state = SdStates::SET_STATE;
|
state = SdStates::SET_STATE_SELF;
|
||||||
commandExecuted = false;
|
commandExecuted = false;
|
||||||
sdcInitCycleCount = 0;
|
sdcInitCycleCount = 0;
|
||||||
}
|
}
|
||||||
else if(sdcInitCycleCount > 2) {
|
else if(sdcInitCycleCount > 4) {
|
||||||
sif::warning << "CoreController::initSdCardNonBlocking: "
|
sif::warning << "CoreController::initSdCardNonBlocking: "
|
||||||
"Updating SDC file takes too long" << std::endl;
|
"Updating SDC file takes too long" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state == SdStates::SET_STATE) {
|
if(state == SdStates::SET_STATE_SELF) {
|
||||||
if(not commandExecuted) {
|
if(not commandExecuted) {
|
||||||
determinePreferredSdCard();
|
determinePreferredSdCard();
|
||||||
statusPair = SdCardManager::SdStatusPair(sd::SdState::OFF, sd::SdState::OFF);
|
statusPair = SdCardManager::SdStatusPair(sd::SdState::OFF, sd::SdState::OFF);
|
||||||
@ -250,6 +250,7 @@ ReturnValue_t CoreController::initSdCardNonBlocking() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sdcInitCycleCount++;
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
#endif /* Q7S_SD_CARD_CONFIG != Q7S_SD_NONE */
|
#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);
|
return sdcMan->switchOnSdCard(sdCard, true, &statusPair);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(state == SdStates::SET_STATE) {
|
if(state == SdStates::SET_STATE_SELF) {
|
||||||
sif::info << "Switching on SD card" << std::endl;
|
sif::info << "Switching on SD card" << std::endl;
|
||||||
return sdcMan->switchOnSdCard(sdCard, false, &statusPair);
|
return sdcMan->switchOnSdCard(sdCard, false, &statusPair);
|
||||||
}
|
}
|
||||||
@ -303,7 +304,7 @@ ReturnValue_t CoreController::sdCardSetup(SdCardManager::SdStatusPair& statusPai
|
|||||||
return sdcMan->mountSdCard(sdCard);
|
return sdcMan->mountSdCard(sdCard);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(state == SdStates::SET_STATE) {
|
if(state == SdStates::SET_STATE_SELF) {
|
||||||
return SdCardManager::ALREADY_ON;
|
return SdCardManager::ALREADY_ON;
|
||||||
}
|
}
|
||||||
if(state == SdStates::MOUNT) {
|
if(state == SdStates::MOUNT) {
|
||||||
@ -379,6 +380,7 @@ ReturnValue_t CoreController::sdCardColdRedundantInit(SdCardManager* sdcMan,
|
|||||||
otherString = "0";
|
otherString = "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(step != SdStates::SET_STATE_OTHER) {
|
||||||
result = sdCardSetup(statusPair, preferredSdCard, preferredString);
|
result = sdCardSetup(statusPair, preferredSdCard, preferredString);
|
||||||
if(result != SdCardManager::ALREADY_MOUNTED and result != HasReturnvaluesIF::RETURN_OK) {
|
if(result != SdCardManager::ALREADY_MOUNTED and result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
sif::warning << "Setting up preferred card " << otherString <<
|
sif::warning << "Setting up preferred card " << otherString <<
|
||||||
@ -387,17 +389,23 @@ ReturnValue_t CoreController::sdCardColdRedundantInit(SdCardManager* sdcMan,
|
|||||||
sdCardSetup(statusPair, preferredSdCard, preferredString);
|
sdCardSetup(statusPair, preferredSdCard, preferredString);
|
||||||
result = HasReturnvaluesIF::RETURN_FAILED;
|
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) {
|
if(result != HasReturnvaluesIF::RETURN_FAILED and otherStatus != sd::SdState::OFF) {
|
||||||
sif::info << "Switching off secondary SD card " << otherString << std::endl;
|
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
|
// without issues
|
||||||
result = sdcMan->switchOffSdCard(otherSdc, otherStatus, &statusPair);
|
ReturnValue_t result2 = sdcMan->switchOffSdCard(otherSdc, otherStatus, &statusPair);
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK and result != SdCardManager::ALREADY_OFF) {
|
if(result2 != HasReturnvaluesIF::RETURN_OK and result2 != SdCardManager::ALREADY_OFF) {
|
||||||
sif::warning << "Switching off secondary SD card " << otherString <<
|
sif::warning << "Switching off secondary SD card " << otherString <<
|
||||||
" in cold redundant mode failed" << std::endl;
|
" in cold redundant mode failed" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,12 +64,13 @@ private:
|
|||||||
NONE,
|
NONE,
|
||||||
START,
|
START,
|
||||||
GET_INFO,
|
GET_INFO,
|
||||||
SET_STATE,
|
SET_STATE_SELF,
|
||||||
|
SET_STATE_OTHER,
|
||||||
MOUNT,
|
MOUNT,
|
||||||
UPDATE_INFO,
|
UPDATE_INFO,
|
||||||
DONE
|
DONE
|
||||||
};
|
};
|
||||||
static constexpr bool BLOCKING_SD_INIT = true;
|
static constexpr bool BLOCKING_SD_INIT = false;
|
||||||
|
|
||||||
SdCardManager* sdcMan = nullptr;
|
SdCardManager* sdcMan = nullptr;
|
||||||
uint16_t sdcInitCycleCount = 0;
|
uint16_t sdcInitCycleCount = 0;
|
||||||
|
@ -386,16 +386,21 @@ SdCardManager::OpStatus SdCardManager::checkCurrentOp(Operations ¤tOp) {
|
|||||||
currentOp = this->currentOp;
|
currentOp = this->currentOp;
|
||||||
bool bytesRead = false;
|
bool bytesRead = false;
|
||||||
|
|
||||||
|
#if OBSW_ENABLE_TIMERS == 1
|
||||||
Timer timer;
|
Timer timer;
|
||||||
timer.setTimer(200);
|
timer.setTimer(100);
|
||||||
uint32_t remainingTimeMs = 0;
|
uint32_t remainingTimeMs = 0;
|
||||||
|
#endif
|
||||||
while(true) {
|
while(true) {
|
||||||
ReturnValue_t result = cmdExecutor.check(bytesRead);
|
ReturnValue_t result = cmdExecutor.check(bytesRead);
|
||||||
|
// This timer can prevent deadlocks due to missconfigurations
|
||||||
|
#if OBSW_ENABLE_TIMERS == 1
|
||||||
timer.getTimer(&remainingTimeMs);
|
timer.getTimer(&remainingTimeMs);
|
||||||
if(remainingTimeMs == 0) {
|
if(remainingTimeMs == 0) {
|
||||||
sif::error << "SdCardManager::checkCurrentOp: Timeout!" << std::endl;
|
sif::error << "SdCardManager::checkCurrentOp: Timeout!" << std::endl;
|
||||||
return OpStatus::FAIL;
|
return OpStatus::FAIL;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
switch(result) {
|
switch(result) {
|
||||||
case(CommandExecutor::BYTES_READ): {
|
case(CommandExecutor::BYTES_READ): {
|
||||||
continue;
|
continue;
|
||||||
|
2
fsfw
2
fsfw
@ -1 +1 @@
|
|||||||
Subproject commit 6073abb12db23decbc9d69f4b6342f4f6f1247bd
|
Subproject commit 3704d2b8295152652a4c7836b595223d8fa3767d
|
@ -22,6 +22,10 @@
|
|||||||
debugging. */
|
debugging. */
|
||||||
#define OBSW_VERBOSE_LEVEL 1
|
#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_PRINT_MISSED_DEADLINES 1
|
||||||
#define OBSW_ADD_TEST_CODE 1
|
#define OBSW_ADD_TEST_CODE 1
|
||||||
#define OBSW_ADD_TEST_PST 1
|
#define OBSW_ADD_TEST_PST 1
|
||||||
|
Loading…
Reference in New Issue
Block a user