improve sd lock handling again
Some checks are pending
EIVE/eive-obsw/pipeline/head Build started...

This commit is contained in:
Robin Müller 2023-03-24 21:29:13 +01:00
parent 61c26fe53a
commit e69812b48b
No known key found for this signature in database
GPG Key ID: 11D4952C8CCEF814
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";