safety mechanism on reboots
This commit is contained in:
parent
a3ed5aef8e
commit
a9096a46c0
@ -3,6 +3,7 @@
|
||||
#include <fsfw/events/EventManager.h>
|
||||
#include <fsfw/filesystem/HasFileSystemIF.h>
|
||||
#include <fsfw/ipc/QueueFactory.h>
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
|
||||
#include "OBSWVersion.h"
|
||||
#include "fsfw/serviceinterface/ServiceInterface.h"
|
||||
@ -932,6 +933,9 @@ ReturnValue_t CoreController::actionReboot(const uint8_t *data, size_t size) {
|
||||
ReturnValue_t CoreController::gracefulShutdownTasks(xsc::Chip chip, xsc::Copy copy,
|
||||
bool &protOpPerformed) {
|
||||
sdcMan->setBlocking(true);
|
||||
sdcMan->markUnusable();
|
||||
// Wait two seconds to ensure no one uses the SD cards
|
||||
TaskFactory::delayTask(2000);
|
||||
// Attempt graceful shutdown by unmounting and switching off SD cards
|
||||
sdcMan->switchOffSdCard(sd::SdCard::SLOT_0);
|
||||
sdcMan->switchOffSdCard(sd::SdCard::SLOT_1);
|
||||
|
@ -460,6 +460,13 @@ void SdCardManager::setBlocking(bool blocking) { this->blocking = blocking; }
|
||||
void SdCardManager::setPrintCommandOutput(bool print) { this->printCmdOutput = print; }
|
||||
|
||||
bool SdCardManager::isSdCardUsable(sd::SdCard sdCard) {
|
||||
{
|
||||
MutexGuard mg(mutex);
|
||||
if (markedUnusable) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
SdCardManager::SdStatePair active;
|
||||
ReturnValue_t result = this->getSdCardsStatus(active);
|
||||
|
||||
@ -562,3 +569,8 @@ std::optional<sd::SdCard> SdCardManager::getActiveSdCard() const {
|
||||
MutexGuard mg(mutex);
|
||||
return sdInfo.active;
|
||||
}
|
||||
|
||||
void SdCardManager::markUnusable() {
|
||||
MutexGuard mg(mutex);
|
||||
markedUnusable = true;
|
||||
}
|
||||
|
@ -214,12 +214,15 @@ class SdCardManager : public SystemObject, public SdCardMountedIF {
|
||||
|
||||
ReturnValue_t performFsck(sd::SdCard sdcard, bool printOutput, int& linuxError);
|
||||
|
||||
void markUnusable();
|
||||
|
||||
private:
|
||||
CommandExecutor cmdExecutor;
|
||||
Operations currentOp = Operations::IDLE;
|
||||
bool blocking = false;
|
||||
bool sdCardActive = true;
|
||||
bool printCmdOutput = true;
|
||||
bool markedUnusable = false;
|
||||
MutexIF* mutex = nullptr;
|
||||
|
||||
SdCardManager();
|
||||
|
Loading…
Reference in New Issue
Block a user