continued sd card manager

This commit is contained in:
2021-07-08 11:23:08 +02:00
committed by Robin Mueller
parent 7600e10f1b
commit e5c3e2da53
3 changed files with 91 additions and 24 deletions

View File

@ -7,6 +7,7 @@
#include "fsfw/returnvalues/HasReturnvaluesIF.h"
#include <cstdint>
#include <utility>
class MutexIF;
@ -21,6 +22,12 @@ public:
static constexpr ReturnValue_t ALREADY_ON = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0);
static constexpr ReturnValue_t ALREADY_OFF = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 1);
static constexpr ReturnValue_t STATUS_FILE_NEXISTS =
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 2);
static constexpr ReturnValue_t STATUS_FILE_FORMAT_INVALID =
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 3);
static constexpr ReturnValue_t SYSTEM_CALL_ERROR =
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 4);
virtual ~SdCardManager();
@ -39,14 +46,33 @@ public:
ReturnValue_t switchOffSdCard(sd::SdCard sdCard);
bool sdCardActive(sd::SdCard sdCard);
/**
* Updated the state file or creates one if it does not exist. You need to call this
* function before calling #sdCardActiv
* @return - RETURN_OK if the state file was updated successfully
* - SYSTEM_CALL_ERROR if the call to create the status file failed
*/
ReturnValue_t updateSdCardStateFile();
/**
* Get the state of the SD cards. If the state file does not exist, this function will
* take care of updating it. If it does not, the function will use the state file to get
* the status of the SD cards and set the field of the provided boolean pair.
* @param active Pair of booleans, where the first entry is the state of the first SD card
* and the second one the state of the second SD card
* @return - RETURN_OK if the state was read successfully
* - STATUS_FILE_FORMAT_INVALID if there was an issue with the state file. The user
* should call #updateSdCardStateFile again in that case
* - STATUS_FILE_NEXISTS if the status file does not exist
*/
ReturnValue_t sdCardActive(std::pair<bool, bool>& active);
sd::SdCard getPreferedSdCard() const;
private:
SdCardManager();
ReturnValue_t updateSdCardStateFile();
ReturnValue_t setSdCardState(sd::SdCard sdCard, bool on);
sd::SdCard preferredSdCard = sd::SdCard::SLOT_0;