Non Blocking SD Card Initialization #75
@ -224,9 +224,11 @@ ReturnValue_t CoreController::sdInitStateMachine() {
|
|||||||
// 2. Hot redundant case: Other SD card needs to be mounted and switched on
|
// 2. Hot redundant case: Other SD card needs to be mounted and switched on
|
||||||
#if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT
|
#if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT
|
||||||
if(sdInfo.otherState == sd::SdState::ON) {
|
if(sdInfo.otherState == sd::SdState::ON) {
|
||||||
|
sif::debug << "Determine: Setting other state off" << std::endl;
|
||||||
sdInfo.state = SdStates::SET_STATE_OTHER;
|
sdInfo.state = SdStates::SET_STATE_OTHER;
|
||||||
}
|
}
|
||||||
else if(sdInfo.otherState == sd::SdState::MOUNTED) {
|
else if(sdInfo.otherState == sd::SdState::MOUNTED) {
|
||||||
|
sif::debug << "Determine: Unmounting other" << std::endl;
|
||||||
sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER;
|
sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -235,9 +237,11 @@ ReturnValue_t CoreController::sdInitStateMachine() {
|
|||||||
}
|
}
|
||||||
#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT
|
#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT
|
||||||
if(sdInfo.otherState == sd::SdState::OFF) {
|
if(sdInfo.otherState == sd::SdState::OFF) {
|
||||||
|
sif::debug << "Determine: Setting other state on" << std::endl;
|
||||||
sdInfo.state = SdStates::SET_STATE_OTHER;
|
sdInfo.state = SdStates::SET_STATE_OTHER;
|
||||||
}
|
}
|
||||||
else if(sdInfo.otherState == sd::SdState::ON) {
|
else if(sdInfo.otherState == sd::SdState::ON) {
|
||||||
|
sif::debug << "Determine: Mounting other" << std::endl;
|
||||||
sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER;
|
sdInfo.state = SdStates::MOUNT_UNMOUNT_OTHER;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -252,19 +256,24 @@ ReturnValue_t CoreController::sdInitStateMachine() {
|
|||||||
#if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT
|
#if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT
|
||||||
if(not sdInfo.commandExecuted) {
|
if(not sdInfo.commandExecuted) {
|
||||||
sif::debug << "Set state other off" << std::endl;
|
sif::debug << "Set state other off" << std::endl;
|
||||||
result = sdCardSetup(sdInfo.pref, sd::SdState::OFF, sdInfo.prefChar);
|
result = sdCardSetup(sdInfo.other, sd::SdState::OFF, sdInfo.otherChar);
|
||||||
sdInfo.commandExecuted = true;
|
sdInfo.commandExecuted = true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
nonBlockingOpChecking(SdStates::UPDATE_INFO, 10, "Switching off other SD card");
|
||||||
|
}
|
||||||
#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT
|
#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT
|
||||||
if(not sdInfo.commandExecuted) {
|
if(not sdInfo.commandExecuted) {
|
||||||
sif::debug << "Set state other on" << std::endl;
|
sif::debug << "Set state other on" << std::endl;
|
||||||
result = sdCardSetup(sdInfo.pref, sd::SdState::ON, sdInfo.prefChar);
|
result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar);
|
||||||
sdInfo.commandExecuted = true;
|
sdInfo.commandExecuted = true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else {
|
else {
|
||||||
nonBlockingOpChecking(SdStates::MOUNT_UNMOUNT_OTHER, 10, "Switching off other SD card");
|
nonBlockingOpChecking(SdStates::SdStates::MOUNT_UNMOUNT_OTHER, 10,
|
||||||
|
"Switching on other SD card");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sdInfo.state == SdStates::MOUNT_UNMOUNT_OTHER) {
|
if(sdInfo.state == SdStates::MOUNT_UNMOUNT_OTHER) {
|
||||||
@ -272,23 +281,21 @@ ReturnValue_t CoreController::sdInitStateMachine() {
|
|||||||
#if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT
|
#if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT
|
||||||
if(not sdInfo.commandExecuted) {
|
if(not sdInfo.commandExecuted) {
|
||||||
sif::debug << "Unmount other" << std::endl;
|
sif::debug << "Unmount other" << std::endl;
|
||||||
result = sdCardSetup(sdInfo.pref, sd::SdState::ON, sdInfo.prefChar);
|
result = sdCardSetup(sdInfo.other, sd::SdState::ON, sdInfo.otherChar);
|
||||||
sdInfo.commandExecuted = true;
|
sdInfo.commandExecuted = true;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
nonBlockingOpChecking(SdStates::SET_STATE_OTHER, 10, "Unmounting other SD card");
|
||||||
|
}
|
||||||
#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT
|
#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT
|
||||||
if(not sdInfo.commandExecuted) {
|
if(not sdInfo.commandExecuted) {
|
||||||
result = sdCardSetup(sdInfo.pref, sd::SdState::MOUNTED, sdInfo.prefChar);
|
result = sdCardSetup(sdInfo.other, sd::SdState::MOUNTED, sdInfo.otherChar);
|
||||||
sdInfo.commandExecuted = true;
|
sdInfo.commandExecuted = true;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else {
|
else {
|
||||||
#if Q7S_SD_CARD_CONFIG == Q7S_SD_COLD_REDUNDANT
|
nonBlockingOpChecking(SdStates::UPDATE_INFO, 4, "Mounting other SD card");
|
||||||
std::string opPrint = "Switching off other SD card";
|
|
||||||
#elif Q7S_SD_CARD_CONFIG == Q7S_SD_HOT_REDUNDANT
|
|
||||||
std::string opPrint = "Mounting other SD card";
|
|
||||||
#endif
|
|
||||||
nonBlockingOpChecking(SdStates::MOUNT_UNMOUNT_OTHER, 10, opPrint);
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sdInfo.state == SdStates::UPDATE_INFO) {
|
if(sdInfo.state == SdStates::UPDATE_INFO) {
|
||||||
@ -338,7 +345,7 @@ ReturnValue_t CoreController::sdCardSetup(sd::SdCard sdCard, sd::SdState targetS
|
|||||||
}
|
}
|
||||||
if(state == sd::SdState::MOUNTED) {
|
if(state == sd::SdState::MOUNTED) {
|
||||||
if(targetState == sd::SdState::OFF) {
|
if(targetState == sd::SdState::OFF) {
|
||||||
sif::info << "Switching off SD card" << sdChar << std::endl;
|
sif::info << "Switching off SD card " << sdChar << std::endl;
|
||||||
return sdcMan->switchOffSdCard(sdCard, true, &sdInfo.currentState);
|
return sdcMan->switchOffSdCard(sdCard, true, &sdInfo.currentState);
|
||||||
}
|
}
|
||||||
else if(targetState == sd::SdState::ON) {
|
else if(targetState == sd::SdState::ON) {
|
||||||
@ -375,7 +382,7 @@ ReturnValue_t CoreController::sdCardSetup(sd::SdCard sdCard, sd::SdState targetS
|
|||||||
return sdcMan->mountSdCard(sdCard);
|
return sdcMan->mountSdCard(sdCard);
|
||||||
}
|
}
|
||||||
else if(targetState == sd::SdState::OFF) {
|
else if(targetState == sd::SdState::OFF) {
|
||||||
sif::info << "Switching off SD card" << sdChar << std::endl;
|
sif::info << "Switching off SD card " << sdChar << std::endl;
|
||||||
return sdcMan->switchOffSdCard(sdCard, false, &sdInfo.currentState);
|
return sdcMan->switchOffSdCard(sdCard, false, &sdInfo.currentState);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user