tested hot redundant config as well

This commit is contained in:
Robin Müller 2021-08-08 00:37:07 +02:00
parent 5a4d287f67
commit 1c0ea5cbb1
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
2 changed files with 44 additions and 30 deletions

View File

@ -123,8 +123,8 @@ ReturnValue_t CoreController::initSdCardBlocking() {
return result;
#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT
sif::info << "Hot redundant SD card configuration" << std::endl;
sdCardSetup(statusPair, sd::SdCard::SLOT_0, "0");
sdCardSetup(statusPair, sd::SdCard::SLOT_1, "1");
sdCardSetup(sd::SdCard::SLOT_0, sd::SdState::MOUNTED, "0", false);
sdCardSetup(sd::SdCard::SLOT_1, sd::SdState::MOUNTED, "1", false);
// Update status file
sdcMan->updateSdCardStateFile();
return HasReturnvaluesIF::RETURN_OK;
@ -240,21 +240,19 @@ ReturnValue_t CoreController::sdStateMachine() {
sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER;
}
else {
// Is already off, update info
sdInfo.state = SdStates::UPDATE_INFO;
// Is already off, update info, but with a small delay
sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE;
}
#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT
if(sdInfo.otherState == sd::SdState::OFF) {
sif::debug << "Determine: Setting other state on" << std::endl;
sdInfo.state = SdStates::SET_STATE_OTHER;
}
else if(sdInfo.otherState == sd::SdState::ON) {
sif::debug << "Determine: Mounting other" << std::endl;
sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER;
}
else {
// Is already on and mounted, update info
sdInfo.state = SdStates::UPDATE_INFO;
sdInfo.state = SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE;
}
#endif
}
@ -267,17 +265,18 @@ ReturnValue_t CoreController::sdStateMachine() {
sdInfo.commandExecuted = true;
}
else {
nonBlockingOpChecking(SdStates::UPDATE_INFO, 10, "Switching off other SD card");
nonBlockingOpChecking(SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE, 10,
"Switching off other SD card");
sdInfo.otherState = sd::SdState::OFF;
currentStateSetter(sdInfo.other, sd::SdState::OFF);
}
#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT
if(not sdInfo.commandExecuted) {
result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar);
result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar, false);
sdInfo.commandExecuted = true;
}
else {
nonBlockingOpChecking(SdStates::SdStates::MOUNT_UNMOUNT_OTHER, 10,
nonBlockingOpChecking(SdStates::MOUNT_UNMOUNT_OTHER, 10,
"Switching on other SD card");
sdInfo.otherState = sd::SdState::ON;
currentStateSetter(sdInfo.other, sd::SdState::ON);
@ -311,25 +310,28 @@ ReturnValue_t CoreController::sdStateMachine() {
#endif
}
if(sdInfo.state == SdStates::UPDATE_INFO) {
if(not sdInfo.commandExecuted) {
// It is assumed that all tasks are running by the point this section is reached.
// Therefore, perform this operation in blocking mode because it does not take long
// and the ready state of the SD card is available sooner
sdcMan->setBlocking(true);
// Update status file
result = sdcMan->updateSdCardStateFile();
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "CoreController::initialize: Updating SD card state file failed"
<< std::endl;
}
sdInfo.commandExecuted = false;
sdInfo.state = SdStates::DONE;
sdInfo.initFinished = true;
sdInfo.cycleCount = 0;
sdcMan->setBlocking(false);
sdcMan->getSdCardActiveStatus(sdInfo.currentState);
if(sdInfo.state == SdStates::SKIP_CYCLE_BEFORE_INFO_UPDATE) {
sdInfo.state = SdStates::UPDATE_INFO;
}
else if(sdInfo.state == SdStates::UPDATE_INFO) {
// It is assumed that all tasks are running by the point this section is reached.
// Therefore, perform this operation in blocking mode because it does not take long
// and the ready state of the SD card is available sooner
sdcMan->setBlocking(true);
// Update status file
result = sdcMan->updateSdCardStateFile();
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "CoreController::initialize: Updating SD card state file failed"
<< std::endl;
}
sdInfo.commandExecuted = false;
sdInfo.state = SdStates::DONE;
sdInfo.cycleCount = 0;
sdcMan->setBlocking(false);
sdcMan->getSdCardActiveStatus(sdInfo.currentState);
if(not sdInfo.initFinished) {
updateSdInfoOther();
sdInfo.initFinished = true;
sif::info << "SD card initialization finished" << std::endl;
}
}

View File

@ -60,19 +60,29 @@ private:
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
uint32_t *msToReachTheMode);
// States for non-blocking setup
// States for SD state machine, which is used in non-blocking mode
enum class SdStates {
NONE,
START,
GET_INFO,
SET_STATE_SELF,
MOUNT_SELF,
// Determine operations for other SD card, depending on redundancy configuration
DETERMINE_OTHER,
SET_STATE_OTHER,
// Mount or unmount other
MOUNT_UNMOUNT_OTHER,
// Skip period because the shell command used to generate the info file sometimes is
// missing the last performed operation if executed too early
SKIP_CYCLE_BEFORE_INFO_UPDATE,
UPDATE_INFO,
DONE
// SD initialization done
DONE,
// Used if SD switches or mount commands are issued via telecommand
SET_STATE_FROM_COMMAND,
MOUNT_FROM_COMMAND,
UNMOUNT_FROM_COMMAND,
};
static constexpr bool BLOCKING_SD_INIT = false;
@ -93,6 +103,8 @@ private:
bool initFinished = false;
SdCardManager::SdStatePair currentState;
uint16_t cycleCount = 0;
sd::SdCard commandedCard = sd::SdCard::NONE;
sd::SdState commandedState = sd::SdState::OFF;
};
SdInfo sdInfo;