core controller doing weird things
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good

This commit is contained in:
Robin Müller 2023-07-25 16:54:40 +02:00
parent bf730060b5
commit abbf170ce2
Signed by: muellerr
GPG Key ID: 407F9B00F858F270

View File

@ -1233,14 +1233,15 @@ ReturnValue_t CoreController::gracefulShutdownTasks(xsc::Chip chip, xsc::Copy co
// the more graceful way to reboot the system. // the more graceful way to reboot the system.
ReturnValue_t result = handleSwitchingSdCardsOffNonBlocking(); ReturnValue_t result = handleSwitchingSdCardsOffNonBlocking();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
sif::error << "CoreController::gracefulShutdownTasks: Issues unmounting or switching SD cards off" sif::error
<< "CoreController::gracefulShutdownTasks: Issues unmounting or switching SD cards off"
<< std::endl; << std::endl;
} }
// If any boot copies are unprotected. // If any boot copies are unprotected.
// Actually this function only ensures that reboots to the own image are protected.. // Actually this function only ensures that reboots to the own image are protected..
result = setBootCopyProtection(xsc::Chip::SELF_CHIP, xsc::Copy::SELF_COPY, true, result = setBootCopyProtection(xsc::Chip::SELF_CHIP, xsc::Copy::SELF_COPY, true, protOpPerformed,
protOpPerformed, false); false);
if (result == returnvalue::OK and protOpPerformed) { if (result == returnvalue::OK and protOpPerformed) {
// TODO: Would be nice to notify operator. But we can't use the filesystem anymore // TODO: Would be nice to notify operator. But we can't use the filesystem anymore
// and a reboot is imminent. Use scratch buffer? // and a reboot is imminent. Use scratch buffer?
@ -2589,11 +2590,16 @@ void CoreController::announceSdInfo(SdCardManager::SdStatePair sdStates) {
} }
ReturnValue_t CoreController::handleSwitchingSdCardsOffNonBlocking() { ReturnValue_t CoreController::handleSwitchingSdCardsOffNonBlocking() {
Countdown maxWaitTimeCd(6000); Countdown maxWaitTimeCd(10000);
Stopwatch watch; Stopwatch watch;
sdcMan->setBlocking(false); sdcMan->setBlocking(false);
SdCardManager::Operations op; SdCardManager::Operations op;
std::pair<sd::SdState, sd::SdState> sdStatus;
ReturnValue_t result = sdcMan->getSdCardsStatus(sdStatus);
if (result != returnvalue::OK) {
return result;
}
auto waitingForFinish = [&]() { auto waitingForFinish = [&]() {
while (sdcMan->checkCurrentOp(op) == SdCardManager::OpStatus::ONGOING) { while (sdcMan->checkCurrentOp(op) == SdCardManager::OpStatus::ONGOING) {
TaskFactory::delayTask(50); TaskFactory::delayTask(50);
@ -2603,28 +2609,33 @@ ReturnValue_t CoreController::handleSwitchingSdCardsOffNonBlocking() {
} }
return returnvalue::OK; return returnvalue::OK;
}; };
sif::debug << "hello 0" << std::endl;
if (sdStatus.first != sd::SdState::OFF) {
sdcMan->unmountSdCard(sd::SdCard::SLOT_0); sdcMan->unmountSdCard(sd::SdCard::SLOT_0);
ReturnValue_t result = waitingForFinish();
if (result != returnvalue::OK) {
return result;
}
sdcMan->unmountSdCard(sd::SdCard::SLOT_1);
result = waitingForFinish(); result = waitingForFinish();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
sdcMan->switchOffSdCard(sd::SdCard::SLOT_0, false); sdcMan->switchOffSdCard(sd::SdCard::SLOT_0, false);
result = waitingForFinish(); result = waitingForFinish();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
}
sif::debug << "hello 1" << std::endl;
if (sdStatus.second != sd::SdState::OFF) {
sdcMan->unmountSdCard(sd::SdCard::SLOT_1);
result = waitingForFinish();
if (result != returnvalue::OK) {
return result;
}
sdcMan->switchOffSdCard(sd::SdCard::SLOT_1, false); sdcMan->switchOffSdCard(sd::SdCard::SLOT_1, false);
result = waitingForFinish(); result = waitingForFinish();
if (result != returnvalue::OK) { if (result != returnvalue::OK) {
return result; return result;
} }
}
sif::debug << "hello 2" << std::endl;
return result; return result;
} }