From 41ec6dc0f2efac827da16d72eba6a7ffd5c483f7 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 12 Apr 2023 18:06:04 +0200 Subject: [PATCH 1/3] set pref sd as param --- CHANGELOG.md | 3 +++ bsp_q7s/core/CoreController.cpp | 40 ++++++++++++++++++++++++++++++++- bsp_q7s/core/CoreController.h | 16 ++++++++++++- 3 files changed, 57 insertions(+), 2 deletions(-) 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; -- 2.43.0 From 2262a15e35e912db143cb506d0b00102c47d348f Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 12 Apr 2023 18:11:20 +0200 Subject: [PATCH 2/3] compile fix --- bsp_q7s/core/CoreController.cpp | 4 ++++ bsp_q7s/core/CoreController.h | 1 + 2 files changed, 5 insertions(+) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 45a1326a..14f6c782 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -2134,6 +2134,10 @@ void CoreController::announceBootCounts() { totalBootCount & 0xffffffff); } +MessageQueueId_t CoreController::getCommandQueue() const { + return ExtendedControllerBase::getCommandQueue(); +} + 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(); diff --git a/bsp_q7s/core/CoreController.h b/bsp_q7s/core/CoreController.h index c5a5356a..6e3da4bb 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -231,6 +231,7 @@ class CoreController : public ExtendedControllerBase, bool remountAttemptFlag = true; #endif + MessageQueueId_t getCommandQueue() const override; ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier, ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, uint16_t startAtIndex) override; -- 2.43.0 From dd211cdf545cd43ace4933360b056d7d853bf67a Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 12 Apr 2023 18:11:41 +0200 Subject: [PATCH 3/3] afmt --- bsp_q7s/core/CoreController.cpp | 39 ++++++++++++++++----------------- bsp_q7s/core/CoreController.h | 12 ++++------ 2 files changed, 23 insertions(+), 28 deletions(-) diff --git a/bsp_q7s/core/CoreController.cpp b/bsp_q7s/core/CoreController.cpp index 14f6c782..8486bd09 100644 --- a/bsp_q7s/core/CoreController.cpp +++ b/bsp_q7s/core/CoreController.cpp @@ -90,7 +90,7 @@ CoreController::~CoreController() {} ReturnValue_t CoreController::handleCommandMessage(CommandMessage *message) { ReturnValue_t result = paramHelper.handleParameterMessage(message); - if(result == returnvalue::OK) { + if (result == returnvalue::OK) { return result; } return ExtendedControllerBase::handleCommandMessage(message); @@ -160,7 +160,7 @@ ReturnValue_t CoreController::initialize() { } result = paramHelper.initialize(); - if(result != returnvalue::OK) { + if (result != returnvalue::OK) { return result; } @@ -2147,26 +2147,25 @@ ReturnValue_t CoreController::getParameter(uint8_t domainId, uint8_t uniqueIdent ParameterWrapper *parameterWrapper, const ParameterWrapper *newValues, uint16_t startAtIndex) { - if(domainId != 0) { + if (domainId != 0) { return HasParametersIF::INVALID_DOMAIN_ID; } - if(uniqueIdentifier >= ParamId::NUM_IDS) { + 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; - + 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 6e3da4bb..0f2d4033 100644 --- a/bsp_q7s/core/CoreController.h +++ b/bsp_q7s/core/CoreController.h @@ -50,13 +50,9 @@ struct RebootFile { xsc::Copy mechanismNextCopy = xsc::Copy::NO_COPY; }; -class CoreController : public ExtendedControllerBase, - public ReceivesParameterMessagesIF { +class CoreController : public ExtendedControllerBase, public ReceivesParameterMessagesIF { public: - enum ParamId: uint8_t { - PREF_SD = 0, - NUM_IDS - }; + enum ParamId : uint8_t { PREF_SD = 0, NUM_IDS }; static xsc::Chip CURRENT_CHIP; static xsc::Copy CURRENT_COPY; @@ -233,8 +229,8 @@ class CoreController : public ExtendedControllerBase, MessageQueueId_t getCommandQueue() const override; ReturnValue_t getParameter(uint8_t domainId, uint8_t uniqueIdentifier, - ParameterWrapper *parameterWrapper, - const ParameterWrapper *newValues, uint16_t startAtIndex) override; + ParameterWrapper* parameterWrapper, const ParameterWrapper* newValues, + uint16_t startAtIndex) override; ReturnValue_t initializeLocalDataPool(localpool::DataPool& localDataPoolMap, LocalDataPoolManager& poolManager) override; -- 2.43.0