diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b0235de..bcbc7a62 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,9 @@ will consitute of a breaking change warranting a new major release: ## Added - Add a way for the MAX31865 RTD handlers to recognize faulty/broken/off sensor devices. +- Add parameter interface for core controller +- Allow setting the preferred SD card via the new parameter interface of the core controller + with domain ID 0 and unque ID 0. # [v1.44.1] 2023-04-12 diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 554e5268..45a1326a 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -40,7 +40,8 @@ CoreController::CoreController(object_id_t objectId, bool enableHkSet) cmdRepliesSizes(128), opDivider5(5), opDivider10(10), - hkSet(this) { + hkSet(this), + paramHelper(this) { cmdExecutor.setRingBuffer(&cmdReplyBuf, &cmdRepliesSizes); try { sdcMan = SdCardManager::instance(); @@ -88,6 +89,10 @@ CoreController::CoreController(object_id_t objectId, bool enableHkSet) CoreController::~CoreController() {} ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) { + ReturnValue_t result = paramHelper.handleParameterMessage(message); + if(result == returnvalue::OK) { + return result; + } return ExtendedControllerBase::handleCommandMessage(message); } @@ -154,6 +159,11 @@ ReturnValue_t CoreController::initialize() { << std::endl; } + result = paramHelper.initialize(); + if(result != returnvalue::OK) { + return result; + } + sdStateMachine(); triggerEvent(core::REBOOT_SW, CURRENT_CHIP, CURRENT_COPY); @@ -2128,3 +2138,31 @@ bool CoreController::isNumber(const std::string &s) { return !s.empty() && std::find_if(s.begin(), s.end(), [](unsigned char c) { return !std::isdigit(c); }) == s.end(); } + +ReturnValue_t CoreController::getParameter(uint8_t domainId, uint8_t uniqueIdentifier, + ParameterWrapper *parameterWrapper, + const ParameterWrapper *newValues, + uint16_t startAtIndex) { + if(domainId != 0) { + return HasParametersIF::INVALID_DOMAIN_ID; + } + if(uniqueIdentifier >= ParamId::NUM_IDS) { + return HasParametersIF::INVALID_IDENTIFIER_ID; + } + uint8_t newPrefSd; + ReturnValue_t result = newValues->getElement(&newPrefSd); + if (result != returnvalue::OK) { + return result; + } + // Only SD card 0 (0) and 1 (1) are allowed values. + if(newPrefSd > 1) { + return HasParametersIF::INVALID_VALUE; + } + result = sdcMan->setPreferredSdCard(static_cast(newPrefSd)); + if(result != returnvalue::OK) { + return returnvalue::FAILED; + } + parameterWrapper->set(prefSdRaw); + return returnvalue::OK; + +} diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index 22b1f6ff..c5a5356a 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -4,6 +4,8 @@ #include #include #include +#include +#include #include #include #include @@ -48,8 +50,14 @@ struct RebootFile { xsc::Copy mechanismNextCopy = xsc::Copy::NO_COPY; }; -class CoreController : public ExtendedControllerBase { +class CoreController : public ExtendedControllerBase, + public ReceivesParameterMessagesIF { public: + enum ParamId: uint8_t { + PREF_SD = 0, + NUM_IDS + }; + static xsc::Chip CURRENT_CHIP; static xsc::Copy CURRENT_COPY; @@ -152,6 +160,7 @@ class CoreController : public ExtendedControllerBase { SdCardManager* sdcMan = nullptr; MessageQueueIF* eventQueue = nullptr; + uint8_t prefSdRaw = sd::SdCard::SLOT_0; SdStates sdFsmState = SdStates::START; SdStates fsmStateAfterDelay = SdStates::IDLE; enum SdCfgMode { PASSIVE, COLD_REDUNDANT, HOT_REDUNDANT }; @@ -216,10 +225,15 @@ class CoreController : public ExtendedControllerBase { core::HkSet hkSet; + ParameterHelper paramHelper; + #if OBSW_SD_CARD_MUST_BE_ON == 1 bool remountAttemptFlag = true; #endif + ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier, + ParameterWrapper *parameterWrapper, + const ParameterWrapper *newValues, uint16_t startAtIndex) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override;