From 059fb105583bd4ce072e1134ffbaa3aab8955d04 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Wed, 27 Jul 2022 11:41:06 +0200 Subject: [PATCH] add helper methods to disable crc calculation --- src/fsfw/tmtcservices/CommandingServiceBase.cpp | 4 ++++ src/fsfw/tmtcservices/CommandingServiceBase.h | 6 +++++- src/fsfw/tmtcservices/TmStoreHelper.cpp | 4 ++++ src/fsfw/tmtcservices/TmStoreHelper.h | 3 +++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.cpp b/src/fsfw/tmtcservices/CommandingServiceBase.cpp index 214adbfa2..0be7c3c89 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.cpp +++ b/src/fsfw/tmtcservices/CommandingServiceBase.cpp @@ -100,6 +100,10 @@ ReturnValue_t CommandingServiceBase::initialize() { } tmStoreHelper.setTmStore(*tmStore); } + // Generally, all TM packets will pass through a layer where the sequence count is set. + // This avoids duplicate calculation of the CRC16 + tmStoreHelper.disableCrcCalculation(); + if (errReporter == nullptr) { errReporter = ObjectManager::instance()->get(objects::INTERNAL_ERROR_REPORTER); diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index 20b7d9920..8017ecc82 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -25,12 +25,16 @@ void setStaticFrameworkObjectIds(); * relay Telecommands to software bus. * * It manages Telecommand reception and the generation of Verification Reports - * similar to PusServiceBase. This class is used if a telecommand can't be + * similar to @PusServiceBase. This class is used if a telecommand can't be * handled immediately and must be relayed to the internal software bus. * - isValidSubservice * - getMessageQueueAndObject * - prepareCommand * - handleReply + * + * Please note that the TM packets generated by this class will not have a valid CRC. It is + * generally assumed that all packets will pass through a layer where the sequence count is set + * and the CRC16 needs to be re-calculated anyway. * @author gaisser * @ingroup pus_services */ diff --git a/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp index a87ca01d6..8b7e59484 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -74,3 +74,7 @@ uint16_t TmStoreHelper::getApid() const { return creator.getApid(); } void TmStoreHelper::setService(uint8_t service) { creator.setService(service); } void TmStoreHelper::setSubservice(uint8_t subservice) { creator.setSubservice(subservice); } + +void TmStoreHelper::disableCrcCalculation() { creator.disableCrcCalculation(); } + +bool TmStoreHelper::crcCalculationEnabled() const { return creator.crcCalculationEnabled(); } diff --git a/src/fsfw/tmtcservices/TmStoreHelper.h b/src/fsfw/tmtcservices/TmStoreHelper.h index e5d9eb7d5..449a22876 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.h +++ b/src/fsfw/tmtcservices/TmStoreHelper.h @@ -13,6 +13,9 @@ class TmStoreHelper { TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore); TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore, TimeStamperIF& timeStamper); + void disableCrcCalculation(); + [[nodiscard]] bool crcCalculationEnabled() const; + ReturnValue_t preparePacket(uint8_t service, uint8_t subservice, uint16_t counter); PusTmCreator& getCreatorRef();