Merge pull request 'improve sd lock handling again' (#523) from another_imrovement_sd_lock_handling into develop
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

Reviewed-on: #523
This commit is contained in:
Robin Müller 2023-03-24 21:29:39 +01:00
commit b301cbc750
2 changed files with 3 additions and 3 deletions

View File

@ -312,7 +312,6 @@ void SdCardManager::resetState() {
ReturnValue_t SdCardManager::updateSdStatePair() {
using namespace std;
MutexGuard mg(sdLock, LOCK_TYPE, SD_LOCK_TIMEOUT, LOCK_CTX);
std::error_code e;
if (not filesystem::exists(SD_STATE_FILE, e)) {
return STATUS_FILE_NEXISTS;
@ -362,6 +361,7 @@ void SdCardManager::processSdStatusLine(std::string& line, uint8_t& idx, sd::SdC
sdStates.second = sd::SdState::ON;
}
} else if (word == "off") {
MutexGuard mg(sdLock, LOCK_TYPE, SD_LOCK_TIMEOUT, LOCK_CTX);
if (currentSd == sd::SdCard::SLOT_0) {
sdStates.first = sd::SdState::OFF;
} else {
@ -371,6 +371,7 @@ void SdCardManager::processSdStatusLine(std::string& line, uint8_t& idx, sd::SdC
}
if (mountLine) {
MutexGuard mg(sdLock, LOCK_TYPE, SD_LOCK_TIMEOUT, LOCK_CTX);
if (currentSd == sd::SdCard::SLOT_0) {
sdStates.first = sd::SdState::MOUNTED;
} else {
@ -409,7 +410,6 @@ ReturnValue_t SdCardManager::updateSdCardStateFile() {
if (cmdExecutor.getCurrentState() == CommandExecutor::States::PENDING) {
return CommandExecutor::COMMAND_PENDING;
}
MutexGuard mg(sdLock, LOCK_TYPE, SD_LOCK_TIMEOUT, LOCK_CTX);
// Use q7hw utility and pipe the command output into the state file
std::string updateCmd = "q7hw sd info all > " + std::string(SD_STATE_FILE);
cmdExecutor.load(updateCmd, true, printCmdOutput);

View File

@ -228,7 +228,7 @@ class SdCardManager : public SystemObject, public SdCardMountedIF {
MutexIF* prefLock = nullptr;
MutexIF* defaultLock = nullptr;
static constexpr MutexIF::TimeoutType LOCK_TYPE = MutexIF::TimeoutType::WAITING;
static constexpr uint32_t SD_LOCK_TIMEOUT = 250;
static constexpr uint32_t SD_LOCK_TIMEOUT = 100;
static constexpr uint32_t OTHER_TIMEOUT = 20;
static constexpr char LOCK_CTX[] = "SdCardManager";