diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index b7edc0cb..88004b0a 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -263,7 +263,8 @@ void CommandingServiceBase::handleRequestQueue() { object_id_t objectId; for (result = requestQueue->receiveMessage(&message); result == RETURN_OK; result = requestQueue->receiveMessage(&message)) { - result = setUpTcReader(message.getStorageId()); + address = message.getStorageId(); + result = setUpTcReader(address); if (result != HasReturnvaluesIF::RETURN_OK) { // TODO: Warning? rejectPacket(tcverif::START_FAILURE, address, result); diff --git a/src/fsfw/tmtcservices/PusServiceBase.cpp b/src/fsfw/tmtcservices/PusServiceBase.cpp index d3d23ed7..f8cc7cb8 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.cpp +++ b/src/fsfw/tmtcservices/PusServiceBase.cpp @@ -140,12 +140,15 @@ void PusServiceBase::setErrorReporter(InternalErrorReporterIF& errReporter_) { psbParams.errReporter = &errReporter_; } -void PusServiceBase::initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelper& tmStoreHelper) { - initializeTmSendHelper(tmSendHelper); - initializeTmStoreHelper(tmStoreHelper); +ReturnValue_t PusServiceBase::initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelper& tmStoreHelper) { + ReturnValue_t result = initializeTmSendHelper(tmSendHelper); + if(result != HasReturnvaluesIF::RETURN_OK) { + return result; + } + return initializeTmStoreHelper(tmStoreHelper); } -void PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) { +ReturnValue_t PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) { if (psbParams.reqQueue != nullptr) { tmSendHelper.setMsgQueue(*psbParams.reqQueue); tmSendHelper.setDefaultDestination(psbParams.reqQueue->getDefaultDestination()); @@ -160,16 +163,29 @@ void PusServiceBase::initializeTmSendHelper(TmSendHelper& tmSendHelper) { } else { tmSendHelper.setInternalErrorReporter(*psbParams.errReporter); } + return RETURN_OK; } -void PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const { +ReturnValue_t PusServiceBase::initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const { tmStoreHelper.setApid(psbParams.apid); + if(tmStoreHelper.getTmStore() == nullptr) { + auto* tmStore = ObjectManager::instance()->get(objects::TM_STORE); + if(tmStore == nullptr) { + return ObjectManagerIF::CHILD_INIT_FAILED; + } + tmStoreHelper.setTmStore(*tmStore); + } + if (psbParams.timeStamper == nullptr) { auto timerStamper = ObjectManager::instance()->get(objects::TIME_STAMPER); if (timerStamper != nullptr) { tmStoreHelper.setTimeStamper(*timerStamper); } } + // Generally, all TM packets will pass through a layer where the sequence count is set. + // This avoids duplicate calculation of the CRC16 + tmStoreHelper.disableCrcCalculation(); + return RETURN_OK; } void PusServiceBase::setVerificationReporter(VerificationReporterIF& reporter) { diff --git a/src/fsfw/tmtcservices/PusServiceBase.h b/src/fsfw/tmtcservices/PusServiceBase.h index 43a2c0d4..86d8ea1a 100644 --- a/src/fsfw/tmtcservices/PusServiceBase.h +++ b/src/fsfw/tmtcservices/PusServiceBase.h @@ -132,19 +132,19 @@ class PusServiceBase : public ExecutableObjectIF, * Helper methods if the implementing class wants to send telemetry * @param tmSendHelper */ - void initializeTmSendHelper(TmSendHelper& tmSendHelper); + ReturnValue_t initializeTmSendHelper(TmSendHelper& tmSendHelper); /** * Helper methods if the implementing class wants to store telemetry. It will set the correct APID * and it will also attempt to set a valid time stamper. If the manually specified time stamper is * null, it will attempt to find a suitable one using @objects::TIME_STAMPER * @param tmSendHelper */ - void initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const; + ReturnValue_t initializeTmStoreHelper(TmStoreHelper& tmStoreHelper) const; /** * Helper methods if the implementing class wants to both send and store telemetry * @param tmSendHelper */ - void initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelper& tmStoreHelper); + ReturnValue_t initializeTmHelpers(TmSendHelper& tmSendHelper, TmStoreHelper& tmStoreHelper); /** * @brief The handleRequest method shall handle any kind of Telecommand