first successfull tests
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
This commit is contained in:
@ -34,11 +34,18 @@ SdCardManager* SdCardManager::instance() {
|
||||
}
|
||||
|
||||
ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard,
|
||||
SdStatusPair* statusPair) {
|
||||
SdStatePair* statusPair) {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
std::unique_ptr<SdStatusPair> sdStatusPtr;
|
||||
if(doMountSdCard) {
|
||||
if(not blocking) {
|
||||
sif::warning << "SdCardManager::switchOnSdCard: Two-step command but manager is"
|
||||
" not configured for blocking operation. Forcing blocking mode.." << std::endl;
|
||||
blocking = true;
|
||||
}
|
||||
}
|
||||
std::unique_ptr<SdStatePair> sdStatusPtr;
|
||||
if(statusPair == nullptr) {
|
||||
sdStatusPtr = std::make_unique<SdStatusPair>();
|
||||
sdStatusPtr = std::make_unique<SdStatePair>();
|
||||
statusPair = sdStatusPtr.get();
|
||||
result = getSdCardActiveStatus(*statusPair);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
@ -91,12 +98,19 @@ ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCar
|
||||
}
|
||||
|
||||
ReturnValue_t SdCardManager::switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard,
|
||||
SdStatusPair* statusPair) {
|
||||
SdStatePair* statusPair) {
|
||||
std::pair<sd::SdState, sd::SdState> active;
|
||||
ReturnValue_t result = getSdCardActiveStatus(active);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
if(doUnmountSdCard) {
|
||||
if(not blocking) {
|
||||
sif::warning << "SdCardManager::switchOffSdCard: Two-step command but manager is"
|
||||
" not configured for blocking operation. Forcing blocking mode.." << std::endl;
|
||||
blocking = true;
|
||||
}
|
||||
}
|
||||
// Not allowed, this function turns off one SD card
|
||||
if(sdCard == sd::SdCard::BOTH) {
|
||||
sif::warning << "SdCardManager::switchOffSdCard: API does not allow sd::SdStatus::BOTH"
|
||||
@ -155,7 +169,7 @@ ReturnValue_t SdCardManager::setSdCardState(sd::SdCard sdCard, bool on) {
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t SdCardManager::getSdCardActiveStatus(SdStatusPair& active) {
|
||||
ReturnValue_t SdCardManager::getSdCardActiveStatus(SdStatePair& active) {
|
||||
using namespace std;
|
||||
if(not filesystem::exists(SD_STATE_FILE)) {
|
||||
return STATUS_FILE_NEXISTS;
|
||||
@ -253,23 +267,34 @@ ReturnValue_t SdCardManager::unmountSdCard(sd::SdCard sdCard) {
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t SdCardManager::sanitizeState(SdStatusPair* statusPair, sd::SdCard prefSdCard) {
|
||||
std::unique_ptr<SdStatusPair> sdStatusPtr;
|
||||
ReturnValue_t SdCardManager::sanitizeState(SdStatePair* statusPair, sd::SdCard prefSdCard) {
|
||||
std::unique_ptr<SdStatePair> sdStatusPtr;
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
// Enforce blocking operation for now. Be careful to reset it when returning prematurely!
|
||||
bool resetNonBlockingState = false;
|
||||
if(not this->blocking) {
|
||||
blocking = true;
|
||||
resetNonBlockingState = true;
|
||||
}
|
||||
if(prefSdCard == sd::SdCard::NONE) {
|
||||
ReturnValue_t result = getPreferredSdCard(prefSdCard);
|
||||
result = getPreferredSdCard(prefSdCard);
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {}
|
||||
}
|
||||
if(statusPair == nullptr) {
|
||||
sdStatusPtr = std::make_unique<SdStatusPair>();
|
||||
sdStatusPtr = std::make_unique<SdStatePair>();
|
||||
statusPair = sdStatusPtr.get();
|
||||
getSdCardActiveStatus(*statusPair);
|
||||
}
|
||||
|
||||
if(statusPair->first == sd::SdState::ON) {
|
||||
return mountSdCard(prefSdCard);
|
||||
result = mountSdCard(prefSdCard);
|
||||
}
|
||||
|
||||
return switchOnSdCard(prefSdCard, true, statusPair);
|
||||
result = switchOnSdCard(prefSdCard, true, statusPair);
|
||||
if(resetNonBlockingState) {
|
||||
blocking = false;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void SdCardManager::resetState() {
|
||||
|
Reference in New Issue
Block a user