This commit is contained in:
parent
002f776bef
commit
4649a75d40
@ -12,10 +12,12 @@ bool RPiSdCardManager::isSdCardMounted(sd::SdCard sdCard) {
|
||||
return true;
|
||||
}
|
||||
|
||||
sd::SdCard RPiSdCardManager::getPreferredSdCard() const {
|
||||
|
||||
std::optional<sd::SdCard> RPiSdCardManager::getPreferredSdCard() const {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
void RPiSdCardManager::setActiveSdCard(sd::SdCard sdCard) {}
|
||||
|
||||
sd::SdCard RPiSdCardManager::getActiveSdCard() const {}
|
||||
std::optional<sd::SdCard> RPiSdCardManager::getActiveSdCard() const {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
@ -7,9 +7,9 @@ public:
|
||||
RPiSdCardManager(const std::string& prefix);
|
||||
const std::string& getCurrentMountPrefix() const override;
|
||||
bool isSdCardMounted(sd::SdCard sdCard) override;
|
||||
sd::SdCard getPreferredSdCard() const override;
|
||||
std::optional<sd::SdCard> getPreferredSdCard() const override;
|
||||
void setActiveSdCard(sd::SdCard sdCard) override;
|
||||
sd::SdCard getActiveSdCard() const override;
|
||||
std::optional<sd::SdCard> getActiveSdCard() const override;
|
||||
private:
|
||||
std::string prefix;
|
||||
};
|
||||
|
@ -139,7 +139,11 @@ ReturnValue_t CoreController::initialize() {
|
||||
|
||||
ReturnValue_t CoreController::initializeAfterTaskCreation() {
|
||||
ReturnValue_t result = returnvalue::OK;
|
||||
sdInfo.pref = sdcMan->getPreferredSdCard();
|
||||
auto sdCard = sdcMan->getPreferredSdCard();
|
||||
if(not sdCard) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
sdInfo.pref = sdCard.value();
|
||||
sdcMan->setActiveSdCard(sdInfo.pref);
|
||||
currMntPrefix = sdcMan->getCurrentMountPrefix();
|
||||
if (BLOCKING_SD_INIT) {
|
||||
@ -337,7 +341,11 @@ ReturnValue_t CoreController::sdStateMachine() {
|
||||
if (sdInfo.state == SdStates::SET_STATE_SELF) {
|
||||
if (not sdInfo.commandExecuted) {
|
||||
result = sdcMan->getSdCardsStatus(sdInfo.currentState);
|
||||
sdInfo.pref = sdcMan->getPreferredSdCard();
|
||||
auto sdCard = sdcMan->getPreferredSdCard();
|
||||
if(not sdCard) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
sdInfo.pref = sdCard.value();
|
||||
updateSdInfoOther();
|
||||
if (sdInfo.pref != sd::SdCard::SLOT_0 and sdInfo.pref != sd::SdCard::SLOT_1) {
|
||||
sif::warning << "Preferred SD card invalid. Setting to card 0.." << std::endl;
|
||||
|
@ -71,8 +71,8 @@ void FileSystemHandler::fileSystemHandlerLoop() {
|
||||
void FileSystemHandler::fileSystemCheckup() {
|
||||
SdCardManager::SdStatePair statusPair;
|
||||
sdcMan->getSdCardsStatus(statusPair);
|
||||
sd::SdCard preferredSdCard = sdcMan->getPreferredSdCard();
|
||||
if ((preferredSdCard == sd::SdCard::SLOT_0) and (statusPair.first == sd::SdState::MOUNTED)) {
|
||||
auto preferredSdCard = sdcMan->getPreferredSdCard();
|
||||
if (preferredSdCard and (preferredSdCard == sd::SdCard::SLOT_0) and (statusPair.first == sd::SdState::MOUNTED)) {
|
||||
currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT;
|
||||
} else if ((preferredSdCard == sd::SdCard::SLOT_1) and
|
||||
(statusPair.second == sd::SdState::MOUNTED)) {
|
||||
@ -90,7 +90,7 @@ void FileSystemHandler::fileSystemCheckup() {
|
||||
sif::warning << "Preferred SD card is " << sdString
|
||||
<< " but does not appear to be mounted. Attempting fix.." << std::endl;
|
||||
// This function will appear to fix the inconsistent state
|
||||
ReturnValue_t result = sdcMan->sanitizeState(&statusPair, preferredSdCard);
|
||||
ReturnValue_t result = sdcMan->sanitizeState(&statusPair, preferredSdCard.value());
|
||||
if (result != returnvalue::OK) {
|
||||
// Oh no.
|
||||
triggerEvent(SdCardManager::SANITIZATION_FAILED, 0, 0);
|
||||
@ -108,7 +108,11 @@ ReturnValue_t FileSystemHandler::initialize() {
|
||||
<< std::endl;
|
||||
}
|
||||
sdcMan = SdCardManager::instance();
|
||||
sd::SdCard preferredSdCard = sdcMan->getPreferredSdCard();
|
||||
auto sdCard = sdcMan->getPreferredSdCard();
|
||||
if(not sdCard) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
sd::SdCard preferredSdCard = sdCard.value();
|
||||
if (preferredSdCard == sd::SdCard::SLOT_0) {
|
||||
currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT;
|
||||
} else if (preferredSdCard == sd::SdCard::SLOT_1) {
|
||||
|
@ -300,11 +300,6 @@ ReturnValue_t SdCardManager::sanitizeState(SdStatePair* statusPair, sd::SdCard p
|
||||
blocking = true;
|
||||
resetNonBlockingState = true;
|
||||
}
|
||||
if (prefSdCard == sd::SdCard::NONE) {
|
||||
result = getPreferredSdCard();
|
||||
if (result != returnvalue::OK) {
|
||||
}
|
||||
}
|
||||
if (statusPair == nullptr) {
|
||||
sdStatusPtr = std::make_unique<SdStatePair>();
|
||||
statusPair = sdStatusPtr.get();
|
||||
@ -379,7 +374,7 @@ void SdCardManager::processSdStatusLine(std::pair<sd::SdState, sd::SdState>& act
|
||||
idx++;
|
||||
}
|
||||
|
||||
sd::SdCard SdCardManager::getPreferredSdCard() const {
|
||||
std::optional<sd::SdCard> SdCardManager::getPreferredSdCard() const {
|
||||
MutexGuard mg(mutex);
|
||||
auto res = mg.getLockResult();
|
||||
if (res != returnvalue::OK) {
|
||||
@ -558,4 +553,7 @@ void SdCardManager::setActiveSdCard(sd::SdCard sdCard) {
|
||||
}
|
||||
}
|
||||
|
||||
sd::SdCard SdCardManager::getActiveSdCard() const { return sdInfo.active; }
|
||||
std::optional<sd::SdCard> SdCardManager::getActiveSdCard() const {
|
||||
MutexGuard mg(mutex);
|
||||
return sdInfo.active;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ class SdCardManager : public SystemObject, public SdCardMountedIF {
|
||||
* @param sdCard
|
||||
* @return
|
||||
*/
|
||||
sd::SdCard getPreferredSdCard() const override;
|
||||
std::optional<sd::SdCard> getPreferredSdCard() const override;
|
||||
|
||||
/**
|
||||
* Switch on the specified SD card.
|
||||
@ -159,7 +159,7 @@ class SdCardManager : public SystemObject, public SdCardMountedIF {
|
||||
* mounted
|
||||
* @return
|
||||
*/
|
||||
sd::SdCard getActiveSdCard() const override;
|
||||
std::optional<sd::SdCard> getActiveSdCard() const override;
|
||||
|
||||
/**
|
||||
* Unmount the specified SD card. This is recommended before switching it off. The SD card
|
||||
|
2
fsfw
2
fsfw
@ -1 +1 @@
|
||||
Subproject commit 141dcb1f149b824b5bd6e5d3339ecb712835751e
|
||||
Subproject commit cf8fe7ea728bea077b9936bcf0db96845bc6419e
|
@ -491,8 +491,8 @@ void PayloadPcduHandler::checkAdcValues() {
|
||||
|
||||
void PayloadPcduHandler::checkJsonFileInit() {
|
||||
if (not jsonFileInitComplete) {
|
||||
sd::SdCard activeSd = sdcMan->getActiveSdCard();
|
||||
if (sdcMan->isSdCardMounted(activeSd)) {
|
||||
auto activeSd = sdcMan->getActiveSdCard();
|
||||
if (activeSd and sdcMan->isSdCardMounted(activeSd.value())) {
|
||||
params.initialize(sdcMan->getCurrentMountPrefix());
|
||||
jsonFileInitComplete = true;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define MISSION_MEMORY_SDCARDMOUNTERIF_H_
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <optional>
|
||||
#include "definitions.h"
|
||||
|
||||
class SdCardMountedIF {
|
||||
@ -10,9 +10,9 @@ class SdCardMountedIF {
|
||||
virtual ~SdCardMountedIF(){};
|
||||
virtual const std::string& getCurrentMountPrefix() const = 0;
|
||||
virtual bool isSdCardMounted(sd::SdCard sdCard) = 0;
|
||||
virtual sd::SdCard getPreferredSdCard() const = 0;
|
||||
virtual std::optional<sd::SdCard> getPreferredSdCard() const = 0;
|
||||
virtual void setActiveSdCard(sd::SdCard sdCard) = 0;
|
||||
virtual sd::SdCard getActiveSdCard() const = 0;
|
||||
virtual std::optional<sd::SdCard> getActiveSdCard() const = 0;
|
||||
|
||||
private:
|
||||
};
|
||||
|
2
tmtc
2
tmtc
@ -1 +1 @@
|
||||
Subproject commit b4d4a51164af69a22eedd645775061dbb51702b1
|
||||
Subproject commit e1d84c5b99e99ea9a9687dcd298d815dc4d8d2b6
|
Loading…
Reference in New Issue
Block a user