added docs and improvements
This commit is contained in:
parent
4fc56417bc
commit
658e9a4907
@ -117,12 +117,12 @@ ReturnValue_t SdCardManager::setSdCardState(sd::SdCard sdCard, bool on) {
|
|||||||
|
|
||||||
ReturnValue_t SdCardManager::sdCardActive(std::pair<sd::SdStatus, sd::SdStatus>& active) {
|
ReturnValue_t SdCardManager::sdCardActive(std::pair<sd::SdStatus, sd::SdStatus>& active) {
|
||||||
using namespace std;
|
using namespace std;
|
||||||
if(not filesystem::exists("/tmp/sd_status.txt")) {
|
if(not filesystem::exists(SD_STATE_FILE)) {
|
||||||
return STATUS_FILE_NEXISTS;
|
return STATUS_FILE_NEXISTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now the file should exist in any case. Still check whether it exists.
|
// Now the file should exist in any case. Still check whether it exists.
|
||||||
fstream sdStatus("/tmp/sd_status.txt");
|
fstream sdStatus(SD_STATE_FILE);
|
||||||
if (not sdStatus.good()) {
|
if (not sdStatus.good()) {
|
||||||
return STATUS_FILE_NEXISTS;
|
return STATUS_FILE_NEXISTS;
|
||||||
}
|
}
|
||||||
@ -261,7 +261,9 @@ void SdCardManager::setPreferredSdCard(sd::SdCard sdCard) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t SdCardManager::updateSdCardStateFile() {
|
ReturnValue_t SdCardManager::updateSdCardStateFile() {
|
||||||
int result = std::system("q7hw sd info all > /tmp/sd_status.txt");
|
// Use q7hw utility and pipe the command output into the state file
|
||||||
|
std::string updateCmd = "q7hw sd info all > " + SD_STATE_FILE;
|
||||||
|
int result = std::system(updateCmd.c_str());
|
||||||
if(result == 0) {
|
if(result == 0) {
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ public:
|
|||||||
static constexpr char SD_1_DEV_NAME[] = "/dev/mmcblk1p1";
|
static constexpr char SD_1_DEV_NAME[] = "/dev/mmcblk1p1";
|
||||||
static constexpr char SD_0_MOUNT_POINT[] = "/mnt/sd0";
|
static constexpr char SD_0_MOUNT_POINT[] = "/mnt/sd0";
|
||||||
static constexpr char SD_1_MOUNT_POINT[] = "/mnt/sd1";
|
static constexpr char SD_1_MOUNT_POINT[] = "/mnt/sd1";
|
||||||
|
static constexpr char SD_STATE_FILE[] = "/tmp/sd_status.txt";
|
||||||
|
|
||||||
virtual ~SdCardManager();
|
virtual ~SdCardManager();
|
||||||
|
|
||||||
@ -53,7 +54,7 @@ public:
|
|||||||
sd::SdCard getPreferredSdCard() const;
|
sd::SdCard getPreferredSdCard() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switch on the specified SD card
|
* Switch on the specified SD card.
|
||||||
* @param sdCard
|
* @param sdCard
|
||||||
* @param doMountSdCard Mount the SD card after switching it on, which is necessary
|
* @param doMountSdCard Mount the SD card after switching it on, which is necessary
|
||||||
* to use it
|
* to use it
|
||||||
@ -63,7 +64,7 @@ public:
|
|||||||
ReturnValue_t switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard = true);
|
ReturnValue_t switchOnSdCard(sd::SdCard sdCard, bool doMountSdCard = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Switch off the specified SD card
|
* Switch off the specified SD card.
|
||||||
* @param sdCard
|
* @param sdCard
|
||||||
* @param doUnmountSdCard Unmount the SD card before switching the card off, which makes
|
* @param doUnmountSdCard Unmount the SD card before switching the card off, which makes
|
||||||
* the operation safer
|
* the operation safer
|
||||||
@ -73,8 +74,8 @@ public:
|
|||||||
ReturnValue_t switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard = true);
|
ReturnValue_t switchOffSdCard(sd::SdCard sdCard, bool doUnmountSdCard = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updated the state file or creates one if it does not exist. You need to call this
|
* Update the state file or creates one if it does not exist. You need to call this
|
||||||
* function before calling #sdCardActiv
|
* function before calling #sdCardActive
|
||||||
* @return - RETURN_OK if the state file was updated successfully
|
* @return - RETURN_OK if the state file was updated successfully
|
||||||
* - SYSTEM_CALL_ERROR if the call to create the status file failed
|
* - SYSTEM_CALL_ERROR if the call to create the status file failed
|
||||||
*/
|
*/
|
||||||
@ -93,7 +94,18 @@ public:
|
|||||||
*/
|
*/
|
||||||
ReturnValue_t sdCardActive(std::pair<sd::SdStatus, sd::SdStatus>& active);
|
ReturnValue_t sdCardActive(std::pair<sd::SdStatus, sd::SdStatus>& active);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mount the specified SD card. This is necessary to use it.
|
||||||
|
* @param sdCard
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
ReturnValue_t mountSdCard(sd::SdCard sdCard);
|
ReturnValue_t mountSdCard(sd::SdCard sdCard);
|
||||||
|
/**
|
||||||
|
* Unmount the specified SD card. This is recommended before switching it off. The SD card
|
||||||
|
* can't be used after it has been unmounted.
|
||||||
|
* @param sdCard
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
ReturnValue_t unmountSdCard(sd::SdCard sdCard);
|
ReturnValue_t unmountSdCard(sd::SdCard sdCard);
|
||||||
|
|
||||||
sd::SdCard getPreferedSdCard() const;
|
sd::SdCard getPreferedSdCard() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user