update to new API
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2022-09-12 17:23:43 +02:00
parent 002f776bef
commit 4649a75d40
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
10 changed files with 39 additions and 27 deletions

View File

@ -12,10 +12,12 @@ bool RPiSdCardManager::isSdCardMounted(sd::SdCard sdCard) {
return true; return true;
} }
sd::SdCard RPiSdCardManager::getPreferredSdCard() const { std::optional<sd::SdCard> RPiSdCardManager::getPreferredSdCard() const {
return std::nullopt;
} }
void RPiSdCardManager::setActiveSdCard(sd::SdCard sdCard) {} void RPiSdCardManager::setActiveSdCard(sd::SdCard sdCard) {}
sd::SdCard RPiSdCardManager::getActiveSdCard() const {} std::optional<sd::SdCard> RPiSdCardManager::getActiveSdCard() const {
return std::nullopt;
}

View File

@ -7,9 +7,9 @@ public:
RPiSdCardManager(const std::string& prefix); RPiSdCardManager(const std::string& prefix);
const std::string& getCurrentMountPrefix() const override; const std::string& getCurrentMountPrefix() const override;
bool isSdCardMounted(sd::SdCard sdCard) 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; void setActiveSdCard(sd::SdCard sdCard) override;
sd::SdCard getActiveSdCard() const override; std::optional<sd::SdCard> getActiveSdCard() const override;
private: private:
std::string prefix; std::string prefix;
}; };

View File

@ -139,7 +139,11 @@ ReturnValue_t CoreController::initialize() {
ReturnValue_t CoreController::initializeAfterTaskCreation() { ReturnValue_t CoreController::initializeAfterTaskCreation() {
ReturnValue_t result = returnvalue::OK; 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); sdcMan->setActiveSdCard(sdInfo.pref);
currMntPrefix = sdcMan->getCurrentMountPrefix(); currMntPrefix = sdcMan->getCurrentMountPrefix();
if (BLOCKING_SD_INIT) { if (BLOCKING_SD_INIT) {
@ -337,7 +341,11 @@ ReturnValue_t CoreController::sdStateMachine() {
if (sdInfo.state == SdStates::SET_STATE_SELF) { if (sdInfo.state == SdStates::SET_STATE_SELF) {
if (not sdInfo.commandExecuted) { if (not sdInfo.commandExecuted) {
result = sdcMan->getSdCardsStatus(sdInfo.currentState); result = sdcMan->getSdCardsStatus(sdInfo.currentState);
sdInfo.pref = sdcMan->getPreferredSdCard(); auto sdCard = sdcMan->getPreferredSdCard();
if(not sdCard) {
return returnvalue::FAILED;
}
sdInfo.pref = sdCard.value();
updateSdInfoOther(); updateSdInfoOther();
if (sdInfo.pref != sd::SdCard::SLOT_0 and sdInfo.pref != sd::SdCard::SLOT_1) { 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; sif::warning << "Preferred SD card invalid. Setting to card 0.." << std::endl;

View File

@ -71,8 +71,8 @@ void FileSystemHandler::fileSystemHandlerLoop() {
void FileSystemHandler::fileSystemCheckup() { void FileSystemHandler::fileSystemCheckup() {
SdCardManager::SdStatePair statusPair; SdCardManager::SdStatePair statusPair;
sdcMan->getSdCardsStatus(statusPair); sdcMan->getSdCardsStatus(statusPair);
sd::SdCard preferredSdCard = sdcMan->getPreferredSdCard(); auto preferredSdCard = sdcMan->getPreferredSdCard();
if ((preferredSdCard == sd::SdCard::SLOT_0) and (statusPair.first == sd::SdState::MOUNTED)) { if (preferredSdCard and (preferredSdCard == sd::SdCard::SLOT_0) and (statusPair.first == sd::SdState::MOUNTED)) {
currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT;
} else if ((preferredSdCard == sd::SdCard::SLOT_1) and } else if ((preferredSdCard == sd::SdCard::SLOT_1) and
(statusPair.second == sd::SdState::MOUNTED)) { (statusPair.second == sd::SdState::MOUNTED)) {
@ -90,7 +90,7 @@ void FileSystemHandler::fileSystemCheckup() {
sif::warning << "Preferred SD card is " << sdString sif::warning << "Preferred SD card is " << sdString
<< " but does not appear to be mounted. Attempting fix.." << std::endl; << " but does not appear to be mounted. Attempting fix.." << std::endl;
// This function will appear to fix the inconsistent state // 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) { if (result != returnvalue::OK) {
// Oh no. // Oh no.
triggerEvent(SdCardManager::SANITIZATION_FAILED, 0, 0); triggerEvent(SdCardManager::SANITIZATION_FAILED, 0, 0);
@ -108,7 +108,11 @@ ReturnValue_t FileSystemHandler::initialize() {
<< std::endl; << std::endl;
} }
sdcMan = SdCardManager::instance(); 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) { if (preferredSdCard == sd::SdCard::SLOT_0) {
currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT; currentMountPrefix = SdCardManager::SD_0_MOUNT_POINT;
} else if (preferredSdCard == sd::SdCard::SLOT_1) { } else if (preferredSdCard == sd::SdCard::SLOT_1) {

View File

@ -300,11 +300,6 @@ ReturnValue_t SdCardManager::sanitizeState(SdStatePair* statusPair, sd::SdCard p
blocking = true; blocking = true;
resetNonBlockingState = true; resetNonBlockingState = true;
} }
if (prefSdCard == sd::SdCard::NONE) {
result = getPreferredSdCard();
if (result != returnvalue::OK) {
}
}
if (statusPair == nullptr) { if (statusPair == nullptr) {
sdStatusPtr = std::make_unique<SdStatePair>(); sdStatusPtr = std::make_unique<SdStatePair>();
statusPair = sdStatusPtr.get(); statusPair = sdStatusPtr.get();
@ -379,7 +374,7 @@ void SdCardManager::processSdStatusLine(std::pair<sd::SdState, sd::SdState>& act
idx++; idx++;
} }
sd::SdCard SdCardManager::getPreferredSdCard() const { std::optional<sd::SdCard> SdCardManager::getPreferredSdCard() const {
MutexGuard mg(mutex); MutexGuard mg(mutex);
auto res = mg.getLockResult(); auto res = mg.getLockResult();
if (res != returnvalue::OK) { 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;
}

View File

@ -92,7 +92,7 @@ class SdCardManager : public SystemObject, public SdCardMountedIF {
* @param sdCard * @param sdCard
* @return * @return
*/ */
sd::SdCard getPreferredSdCard() const override; std::optional<sd::SdCard> getPreferredSdCard() const override;
/** /**
* Switch on the specified SD card. * Switch on the specified SD card.
@ -159,7 +159,7 @@ class SdCardManager : public SystemObject, public SdCardMountedIF {
* mounted * mounted
* @return * @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 * Unmount the specified SD card. This is recommended before switching it off. The SD card

2
fsfw

@ -1 +1 @@
Subproject commit 141dcb1f149b824b5bd6e5d3339ecb712835751e Subproject commit cf8fe7ea728bea077b9936bcf0db96845bc6419e

View File

@ -491,8 +491,8 @@ void PayloadPcduHandler::checkAdcValues() {
void PayloadPcduHandler::checkJsonFileInit() { void PayloadPcduHandler::checkJsonFileInit() {
if (not jsonFileInitComplete) { if (not jsonFileInitComplete) {
sd::SdCard activeSd = sdcMan->getActiveSdCard(); auto activeSd = sdcMan->getActiveSdCard();
if (sdcMan->isSdCardMounted(activeSd)) { if (activeSd and sdcMan->isSdCardMounted(activeSd.value())) {
params.initialize(sdcMan->getCurrentMountPrefix()); params.initialize(sdcMan->getCurrentMountPrefix());
jsonFileInitComplete = true; jsonFileInitComplete = true;
} }

View File

@ -2,7 +2,7 @@
#define MISSION_MEMORY_SDCARDMOUNTERIF_H_ #define MISSION_MEMORY_SDCARDMOUNTERIF_H_
#include <string> #include <string>
#include <optional>
#include "definitions.h" #include "definitions.h"
class SdCardMountedIF { class SdCardMountedIF {
@ -10,9 +10,9 @@ class SdCardMountedIF {
virtual ~SdCardMountedIF(){}; virtual ~SdCardMountedIF(){};
virtual const std::string& getCurrentMountPrefix() const = 0; virtual const std::string& getCurrentMountPrefix() const = 0;
virtual bool isSdCardMounted(sd::SdCard sdCard) = 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 void setActiveSdCard(sd::SdCard sdCard) = 0;
virtual sd::SdCard getActiveSdCard() const = 0; virtual std::optional<sd::SdCard> getActiveSdCard() const = 0;
private: private:
}; };

2
tmtc

@ -1 +1 @@
Subproject commit b4d4a51164af69a22eedd645775061dbb51702b1 Subproject commit e1d84c5b99e99ea9a9687dcd298d815dc4d8d2b6