Filesystem Update #53

Merged
meierj merged 17 commits from mueller/filesystem-update into develop 2021-07-22 09:03:43 +02:00
3 changed files with 28 additions and 11 deletions
Showing only changes of commit a15e0bbaa5 - Show all commits

View File

@ -41,7 +41,10 @@ ReturnValue_t CoreController::initialize() {
sif::info << "Switching on SD card " << printoutString << ".." << std::endl; sif::info << "Switching on SD card " << printoutString << ".." << std::endl;
result = SdCardManager::instance()->switchOnSdCard(preferredSdCard, true); result = SdCardManager::instance()->switchOnSdCard(preferredSdCard, true);
if(result == SdCardManager::ALREADY_ON) { if(result == SdCardManager::ALREADY_MOUNTED) {
sif::info << "SD card " << printoutString << " is already on and mounted" << std::endl;
}
else if(result == SdCardManager::ALREADY_ON) {
sif::info << "SD card " << printoutString << " is already on" << std::endl; sif::info << "SD card " << printoutString << " is already on" << std::endl;
} }
else if(result != HasReturnvaluesIF::RETURN_OK) { else if(result != HasReturnvaluesIF::RETURN_OK) {
@ -49,7 +52,7 @@ ReturnValue_t CoreController::initialize() {
<< std::endl; << std::endl;
} }
else { else {
sif::info << "SD card " << printoutString << " was switched on" << std::endl; sif::info << "SD card " << printoutString << " was switched on and mounted" << std::endl;
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
} }

View File

@ -39,9 +39,18 @@ ReturnValue_t SdCardManager::switchOnSdCard(sd::SdCard sdCard, bool doMountSdCar
return result; return result;
} }
if(sdCard == sd::SdCard::SLOT_0) { if(sdCard == sd::SdCard::SLOT_0) {
if(active.first == sd::SdStatus::ON or active.first == sd::SdStatus::MOUNTED) { if(active.first == sd::SdStatus::MOUNTED) {
return ALREADY_ON; return ALREADY_MOUNTED;
} }
else if(active.first == sd::SdStatus::ON) {
if(not doMountSdCard) {
return ALREADY_ON;
}
else {
return mountSdCard(sdCard);
}
}
} }
else if(sdCard == sd::SdCard::SLOT_1) { else if(sdCard == sd::SdCard::SLOT_1) {
if(active.second == sd::SdStatus::ON or active.second == sd::SdStatus::MOUNTED) { if(active.second == sd::SdStatus::ON or active.second == sd::SdStatus::MOUNTED) {

View File

@ -21,17 +21,22 @@ class SdCardManager {
public: public:
static constexpr uint8_t INTERFACE_ID = CLASS_ID::SD_CARD_MANAGER; static constexpr uint8_t INTERFACE_ID = CLASS_ID::SD_CARD_MANAGER;
static constexpr ReturnValue_t ALREADY_ON = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0); static constexpr ReturnValue_t ALREADY_ON =
static constexpr ReturnValue_t ALREADY_OFF = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 1); HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 0);
static constexpr ReturnValue_t STATUS_FILE_NEXISTS = static constexpr ReturnValue_t ALREADY_MOUNTED =
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 1);
static constexpr ReturnValue_t ALREADY_OFF =
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 2); HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 2);
static constexpr ReturnValue_t STATUS_FILE_NEXISTS =
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 10);
static constexpr ReturnValue_t STATUS_FILE_FORMAT_INVALID = static constexpr ReturnValue_t STATUS_FILE_FORMAT_INVALID =
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 3); HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 11);
static constexpr ReturnValue_t MOUNT_ERROR = HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 4); static constexpr ReturnValue_t MOUNT_ERROR =
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 12);
static constexpr ReturnValue_t UNMOUNT_ERROR = static constexpr ReturnValue_t UNMOUNT_ERROR =
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 5); HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 13);
static constexpr ReturnValue_t SYSTEM_CALL_ERROR = static constexpr ReturnValue_t SYSTEM_CALL_ERROR =
HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 6); HasReturnvaluesIF::makeReturnCode(INTERFACE_ID, 14);
// C++17 does not support constexpr std::string yet // C++17 does not support constexpr std::string yet
static constexpr char SD_0_DEV_NAME[] = "/dev/mmcblk0p1"; static constexpr char SD_0_DEV_NAME[] = "/dev/mmcblk0p1";