From f1c37203a48cce0660951779310e12f4d36cf0a5 Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Tue, 26 Jul 2022 11:14:40 +0200 Subject: [PATCH] some more API improvements and replacements --- automation/Jenkinsfile | 2 +- scripts/helper.py | 2 +- src/fsfw/cfdp/definitions.h | 21 +++++++------------ src/fsfw/pus/CService200ModeCommanding.cpp | 3 ++- src/fsfw/pus/CService201HealthCommanding.cpp | 2 +- src/fsfw/pus/Service17Test.h | 2 +- .../pus/Service1TelecommandVerification.h | 2 +- src/fsfw/pus/Service20ParameterManagement.cpp | 3 +-- src/fsfw/pus/Service3Housekeeping.cpp | 3 ++- src/fsfw/pus/Service5EventReporting.h | 2 +- src/fsfw/pus/Service8FunctionManagement.cpp | 3 ++- src/fsfw/tmtcpacket/pus/PusIF.h | 6 ++---- src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp | 4 +--- src/fsfw/tmtcservices/CommandingServiceBase.h | 15 +++++++------ src/fsfw/tmtcservices/TmSendHelper.h | 1 - .../tmtcservices/TmStoreAndSendHelper.cpp | 9 ++++---- src/fsfw/tmtcservices/TmStoreAndSendHelper.h | 7 ++++--- src/fsfw/tmtcservices/TmStoreHelper.cpp | 11 +++++----- src/fsfw/tmtcservices/TmStoreHelper.h | 4 ++-- src/fsfw_hal/linux/CommandExecutor.h | 8 +++---- 20 files changed, 49 insertions(+), 61 deletions(-) diff --git a/automation/Jenkinsfile b/automation/Jenkinsfile index c5dcbe02..02340190 100644 --- a/automation/Jenkinsfile +++ b/automation/Jenkinsfile @@ -1,6 +1,6 @@ pipeline { environment { - BUILDDIR = 'build-tests' + BUILDDIR = 'cmake-build-tests' } agent { docker { image 'fsfw-ci:d3'} diff --git a/scripts/helper.py b/scripts/helper.py index 0ac616b6..0ced7186 100755 --- a/scripts/helper.py +++ b/scripts/helper.py @@ -13,7 +13,7 @@ from shutil import which from typing import List -UNITTEST_FOLDER_NAME = "build-tests" +UNITTEST_FOLDER_NAME = "cmake-build-tests" DOCS_FOLDER_NAME = "build-docs" diff --git a/src/fsfw/cfdp/definitions.h b/src/fsfw/cfdp/definitions.h index 93d15bcb..c532f3c1 100644 --- a/src/fsfw/cfdp/definitions.h +++ b/src/fsfw/cfdp/definitions.h @@ -15,24 +15,17 @@ static constexpr uint8_t VERSION_BITS = 0b00100000; static constexpr uint8_t CFDP_CLASS_ID = CLASS_ID::CFDP; -static constexpr ReturnValue_t INVALID_TLV_TYPE = - retval::makeCode(CFDP_CLASS_ID, 1); -static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS = - retval::makeCode(CFDP_CLASS_ID, 2); -static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN = - retval::makeCode(CFDP_CLASS_ID, 3); -static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS = - retval::makeCode(CFDP_CLASS_ID, 4); +static constexpr ReturnValue_t INVALID_TLV_TYPE = retval::makeCode(CFDP_CLASS_ID, 1); +static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS = retval::makeCode(CFDP_CLASS_ID, 2); +static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN = retval::makeCode(CFDP_CLASS_ID, 3); +static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS = retval::makeCode(CFDP_CLASS_ID, 4); //! Can not parse options. This can also occur because there are options //! available but the user did not pass a valid options array -static constexpr ReturnValue_t METADATA_CANT_PARSE_OPTIONS = - retval::makeCode(CFDP_CLASS_ID, 5); -static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS = - retval::makeCode(CFDP_CLASS_ID, 6); +static constexpr ReturnValue_t METADATA_CANT_PARSE_OPTIONS = retval::makeCode(CFDP_CLASS_ID, 5); +static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS = retval::makeCode(CFDP_CLASS_ID, 6); static constexpr ReturnValue_t FINISHED_CANT_PARSE_FS_RESPONSES = retval::makeCode(CFDP_CLASS_ID, 6); -static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE = - retval::makeCode(CFDP_CLASS_ID, 8); +static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE = retval::makeCode(CFDP_CLASS_ID, 8); //! Can not parse filestore response because user did not pass a valid instance //! or remaining size is invalid static constexpr ReturnValue_t FILESTORE_RESPONSE_CANT_PARSE_FS_MESSAGE = diff --git a/src/fsfw/pus/CService200ModeCommanding.cpp b/src/fsfw/pus/CService200ModeCommanding.cpp index 2e8e78a3..ea60d00b 100644 --- a/src/fsfw/pus/CService200ModeCommanding.cpp +++ b/src/fsfw/pus/CService200ModeCommanding.cpp @@ -113,7 +113,8 @@ ReturnValue_t CService200ModeCommanding::prepareWrongModeReply(const CommandMess ReturnValue_t CService200ModeCommanding::prepareCantReachModeReply(const CommandMessage *reply, object_id_t objectId) { CantReachModePacket cantReachModePacket(objectId, ModeMessage::getCantReachModeReason(reply)); - ReturnValue_t result = tmHelper.sendTmPacket(Subservice::REPLY_CANT_REACH_MODE, cantReachModePacket); + ReturnValue_t result = + tmHelper.sendTmPacket(Subservice::REPLY_CANT_REACH_MODE, cantReachModePacket); if (result == RETURN_OK) { // We want to produce an error here in any case because the mode was not reached return RETURN_FAILED; diff --git a/src/fsfw/pus/CService201HealthCommanding.cpp b/src/fsfw/pus/CService201HealthCommanding.cpp index c668ea52..4588907f 100644 --- a/src/fsfw/pus/CService201HealthCommanding.cpp +++ b/src/fsfw/pus/CService201HealthCommanding.cpp @@ -102,5 +102,5 @@ ReturnValue_t CService201HealthCommanding::handleReply(const CommandMessage *rep auto health = static_cast(HealthMessage::getHealth(reply)); auto oldHealth = static_cast(HealthMessage::getOldHealth(reply)); HealthSetReply healthSetReply(health, oldHealth); - return sendTmPacket(Subservice::REPLY_HEALTH_SET, healthSetReply); + return tmHelper.sendTmPacket(Subservice::REPLY_HEALTH_SET, healthSetReply); } diff --git a/src/fsfw/pus/Service17Test.h b/src/fsfw/pus/Service17Test.h index 771fbe55..7e2db98b 100644 --- a/src/fsfw/pus/Service17Test.h +++ b/src/fsfw/pus/Service17Test.h @@ -3,8 +3,8 @@ #include "fsfw/objectmanager/SystemObject.h" #include "fsfw/tmtcservices/PusServiceBase.h" -#include "fsfw/tmtcservices/TmStoreHelper.h" #include "fsfw/tmtcservices/TmStoreAndSendHelper.h" +#include "fsfw/tmtcservices/TmStoreHelper.h" /** * @brief Test Service diff --git a/src/fsfw/pus/Service1TelecommandVerification.h b/src/fsfw/pus/Service1TelecommandVerification.h index 5709e6a9..dcbb5017 100644 --- a/src/fsfw/pus/Service1TelecommandVerification.h +++ b/src/fsfw/pus/Service1TelecommandVerification.h @@ -8,8 +8,8 @@ #include "fsfw/tmtcservices/AcceptsVerifyMessageIF.h" #include "fsfw/tmtcservices/PusVerificationReport.h" #include "fsfw/tmtcservices/TmSendHelper.h" -#include "fsfw/tmtcservices/TmStoreHelper.h" #include "fsfw/tmtcservices/TmStoreAndSendHelper.h" +#include "fsfw/tmtcservices/TmStoreHelper.h" /** * @brief Verify TC acceptance, start, progress and execution. diff --git a/src/fsfw/pus/Service20ParameterManagement.cpp b/src/fsfw/pus/Service20ParameterManagement.cpp index ccb5a3b5..5f479530 100644 --- a/src/fsfw/pus/Service20ParameterManagement.cpp +++ b/src/fsfw/pus/Service20ParameterManagement.cpp @@ -64,8 +64,7 @@ ReturnValue_t Service20ParameterManagement::checkAndAcquireTargetID(object_id_t* ReturnValue_t Service20ParameterManagement::checkInterfaceAndAcquireMessageQueue( MessageQueueId_t* messageQueueToSet, object_id_t* objectId) { // check ReceivesParameterMessagesIF property of target - auto* possibleTarget = - ObjectManager::instance()->get(*objectId); + auto* possibleTarget = ObjectManager::instance()->get(*objectId); if (possibleTarget == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 sif::error << "Service20ParameterManagement::checkInterfaceAndAcquire" diff --git a/src/fsfw/pus/Service3Housekeeping.cpp b/src/fsfw/pus/Service3Housekeeping.cpp index 7ef5636d..df7cbe0a 100644 --- a/src/fsfw/pus/Service3Housekeeping.cpp +++ b/src/fsfw/pus/Service3Housekeeping.cpp @@ -290,7 +290,8 @@ ReturnValue_t Service3Housekeeping::generateHkReply(const CommandMessage* hkMess } HkPacket hkPacket(sid, resultPair.second.data(), resultPair.second.size()); - return sendTmPacket(static_cast(subserviceId), hkPacket.hkData, hkPacket.hkSize); + return tmHelper.sendTmPacket(static_cast(subserviceId), hkPacket.hkData, + hkPacket.hkSize); } sid_t Service3Housekeeping::buildSid(object_id_t objectId, const uint8_t** tcData, diff --git a/src/fsfw/pus/Service5EventReporting.h b/src/fsfw/pus/Service5EventReporting.h index fcbdcb6b..e6f67bfd 100644 --- a/src/fsfw/pus/Service5EventReporting.h +++ b/src/fsfw/pus/Service5EventReporting.h @@ -2,8 +2,8 @@ #define FSFW_PUS_SERVICE5EVENTREPORTING_H_ #include "fsfw/events/EventMessage.h" -#include "fsfw/tmtcservices/TmStoreAndSendHelper.h" #include "fsfw/tmtcservices/PusServiceBase.h" +#include "fsfw/tmtcservices/TmStoreAndSendHelper.h" /** * @brief Report on-board events like information or errors diff --git a/src/fsfw/pus/Service8FunctionManagement.cpp b/src/fsfw/pus/Service8FunctionManagement.cpp index cec4e423..f9a6a168 100644 --- a/src/fsfw/pus/Service8FunctionManagement.cpp +++ b/src/fsfw/pus/Service8FunctionManagement.cpp @@ -138,7 +138,8 @@ ReturnValue_t Service8FunctionManagement::handleDataReply(const CommandMessage* return result; } DataReply dataReply(objectId, actionId, buffer, size); - result = tmHelper.sendTmPacket(static_cast(Subservice::REPLY_DIRECT_COMMANDING_DATA), dataReply); + result = tmHelper.sendTmPacket(static_cast(Subservice::REPLY_DIRECT_COMMANDING_DATA), + dataReply); auto deletionResult = ipcStore->deleteData(storeId); if (deletionResult != HasReturnvaluesIF::RETURN_OK) { diff --git a/src/fsfw/tmtcpacket/pus/PusIF.h b/src/fsfw/tmtcpacket/pus/PusIF.h index 93223ba8..5f27846e 100644 --- a/src/fsfw/tmtcpacket/pus/PusIF.h +++ b/src/fsfw/tmtcpacket/pus/PusIF.h @@ -9,10 +9,8 @@ class PusIF : public SpacePacketIF { public: static constexpr uint8_t INTERFACE_ID = CLASS_ID::PUS_IF; - static constexpr ReturnValue_t INVALID_PUS_VERSION = - retval::makeCode(INTERFACE_ID, 0); - static constexpr ReturnValue_t INVALID_CRC_16 = - retval::makeCode(INTERFACE_ID, 1); + static constexpr ReturnValue_t INVALID_PUS_VERSION = retval::makeCode(INTERFACE_ID, 0); + static constexpr ReturnValue_t INVALID_CRC_16 = retval::makeCode(INTERFACE_ID, 1); ~PusIF() override = default; /** diff --git a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp index 71149613..ddcad33e 100644 --- a/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp +++ b/src/fsfw/tmtcpacket/pus/tm/PusTmCreator.cpp @@ -134,9 +134,7 @@ ReturnValue_t PusTmCreator::setSerializableUserData(SerializeIF& serializable) { return HasReturnvaluesIF::RETURN_OK; } -void PusTmCreator::setService(uint8_t service) { - pusParams.secHeader.service = service; -} +void PusTmCreator::setService(uint8_t service) { pusParams.secHeader.service = service; } void PusTmCreator::setSubservice(uint8_t subservice) { pusParams.secHeader.subservice = subservice; diff --git a/src/fsfw/tmtcservices/CommandingServiceBase.h b/src/fsfw/tmtcservices/CommandingServiceBase.h index e96c02d7..63067b07 100644 --- a/src/fsfw/tmtcservices/CommandingServiceBase.h +++ b/src/fsfw/tmtcservices/CommandingServiceBase.h @@ -6,7 +6,6 @@ #include "TmStoreHelper.h" #include "VerificationReporter.h" #include "fsfw/FSFW.h" -#include "fsfw/tmtcservices/TmStoreAndSendHelper.h" #include "fsfw/container/FIFO.h" #include "fsfw/container/FixedMap.h" #include "fsfw/ipc/CommandMessage.h" @@ -15,6 +14,7 @@ #include "fsfw/serialize/SerializeIF.h" #include "fsfw/storagemanager/StorageManagerIF.h" #include "fsfw/tasks/ExecutableObjectIF.h" +#include "fsfw/tmtcservices/TmStoreAndSendHelper.h" namespace Factory { void setStaticFrameworkObjectIds(); @@ -284,13 +284,12 @@ class CommandingServiceBase : public SystemObject, */ PeriodicTaskIF* executingTask = nullptr; - [[deprecated("Use function with same name provided by tmHelper")]] - ReturnValue_t sendTmPacket(uint8_t subservice, const uint8_t* sourceData, size_t sourceDataLen); - [[deprecated("Use function with same name provided by tmHelper")]] - ReturnValue_t sendTmPacket(uint8_t subservice, object_id_t objectId, const uint8_t* data, - size_t dataLen); - [[deprecated("Use function with same name provided by tmHelper")]] - ReturnValue_t sendTmPacket(uint8_t subservice, SerializeIF& sourceData); + [[deprecated("Use function with same name provided by tmHelper")]] ReturnValue_t sendTmPacket( + uint8_t subservice, const uint8_t* sourceData, size_t sourceDataLen); + [[deprecated("Use function with same name provided by tmHelper")]] ReturnValue_t sendTmPacket( + uint8_t subservice, object_id_t objectId, const uint8_t* data, size_t dataLen); + [[deprecated("Use function with same name provided by tmHelper")]] ReturnValue_t sendTmPacket( + uint8_t subservice, SerializeIF& sourceData); void checkAndExecuteFifo(CommandMapIter& iter); diff --git a/src/fsfw/tmtcservices/TmSendHelper.h b/src/fsfw/tmtcservices/TmSendHelper.h index c4bec886..244e7900 100644 --- a/src/fsfw/tmtcservices/TmSendHelper.h +++ b/src/fsfw/tmtcservices/TmSendHelper.h @@ -28,7 +28,6 @@ class TmSendHelper { ReturnValue_t sendPacket(MessageQueueId_t dest, const store_address_t& storeId); ReturnValue_t sendPacket(const store_address_t& storeId); - private: MessageQueueId_t defaultDest = MessageQueueIF::NO_QUEUE; bool ignoreFault = false; diff --git a/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp b/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp index f10bea32..61735ab5 100644 --- a/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreAndSendHelper.cpp @@ -1,9 +1,10 @@ #include "TmStoreAndSendHelper.h" + #include "tmHelpers.h" -TmStoreAndSendWrapper::TmStoreAndSendWrapper( - uint8_t defaultService, TmStoreHelper& storeHelper, TmSendHelper& sendHelper) - : storeHelper(storeHelper), sendHelper(sendHelper), defaultService(defaultService){} +TmStoreAndSendWrapper::TmStoreAndSendWrapper(uint8_t defaultService, TmStoreHelper& storeHelper, + TmSendHelper& sendHelper) + : storeHelper(storeHelper), sendHelper(sendHelper), defaultService(defaultService) {} ReturnValue_t TmStoreAndSendWrapper::storeAndSendTmPacket() { ReturnValue_t result = storeHelper.addPacketToStore(); @@ -17,7 +18,7 @@ ReturnValue_t TmStoreAndSendWrapper::storeAndSendTmPacket() { } return result; } - if(incrementSendCounter) { + if (incrementSendCounter) { sendCounter++; } return result; diff --git a/src/fsfw/tmtcservices/TmStoreAndSendHelper.h b/src/fsfw/tmtcservices/TmStoreAndSendHelper.h index 44ad1799..1a33b7d7 100644 --- a/src/fsfw/tmtcservices/TmStoreAndSendHelper.h +++ b/src/fsfw/tmtcservices/TmStoreAndSendHelper.h @@ -5,12 +5,13 @@ #include "TmStoreHelper.h" /** - * Wrapper class intended to help with PUS TM handling. This wrapper class also caches the current packet count - * and the service ID + * Wrapper class intended to help with PUS TM handling. This wrapper class also caches the current + * packet count and the service ID */ class TmStoreAndSendWrapper { public: - TmStoreAndSendWrapper(uint8_t defaultService, TmStoreHelper& storeHelper, TmSendHelper& sendHelper); + TmStoreAndSendWrapper(uint8_t defaultService, TmStoreHelper& storeHelper, + TmSendHelper& sendHelper); ReturnValue_t storeAndSendTmPacket(); ReturnValue_t sendTmPacket(uint8_t subservice); diff --git a/src/fsfw/tmtcservices/TmStoreHelper.cpp b/src/fsfw/tmtcservices/TmStoreHelper.cpp index a8105ae0..a87ca01d 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.cpp +++ b/src/fsfw/tmtcservices/TmStoreHelper.cpp @@ -18,10 +18,9 @@ TmStoreHelper::TmStoreHelper(uint16_t defaultApid, StorageManagerIF& tmStore, } ReturnValue_t TmStoreHelper::preparePacket(uint8_t service, uint8_t subservice, uint16_t counter) { - PusTmParams& params = creator.getParams(); - params.secHeader.service = service; - params.secHeader.subservice = subservice; - params.secHeader.messageTypeCounter = counter; + creator.setService(service); + creator.setSubservice(subservice); + creator.setMessageTypeCounter(counter); return HasReturnvaluesIF::RETURN_OK; } @@ -72,6 +71,6 @@ TimeStamperIF* TmStoreHelper::getTimeStamper() const { return creator.getTimesta uint16_t TmStoreHelper::getApid() const { return creator.getApid(); } -ReturnValue_t TmStoreHelper::setService(uint8_t service) { creator.setService(service); } +void TmStoreHelper::setService(uint8_t service) { creator.setService(service); } -ReturnValue_t TmStoreHelper::setSubservice(uint8_t subservice) { creator.setSubservice(subservice); } +void TmStoreHelper::setSubservice(uint8_t subservice) { creator.setSubservice(subservice); } diff --git a/src/fsfw/tmtcservices/TmStoreHelper.h b/src/fsfw/tmtcservices/TmStoreHelper.h index 6c18ac7f..e5d9eb7d 100644 --- a/src/fsfw/tmtcservices/TmStoreHelper.h +++ b/src/fsfw/tmtcservices/TmStoreHelper.h @@ -27,8 +27,8 @@ class TmStoreHelper { [[nodiscard]] uint16_t getApid() const; [[nodiscard]] const store_address_t& getCurrentAddr() const; - ReturnValue_t setService(uint8_t service); - ReturnValue_t setSubservice(uint8_t subservice); + void setService(uint8_t service); + void setSubservice(uint8_t subservice); ReturnValue_t setSourceDataRaw(const uint8_t* data, size_t len); ReturnValue_t setSourceDataSerializable(SerializeIF& serializable); diff --git a/src/fsfw_hal/linux/CommandExecutor.h b/src/fsfw_hal/linux/CommandExecutor.h index f5c7a803..27e78260 100644 --- a/src/fsfw_hal/linux/CommandExecutor.h +++ b/src/fsfw_hal/linux/CommandExecutor.h @@ -31,8 +31,7 @@ class CommandExecutor { static constexpr uint8_t CLASS_ID = CLASS_ID::LINUX_OSAL; //! [EXPORT] : [COMMENT] Execution of the current command has finished - static constexpr ReturnValue_t EXECUTION_FINISHED = - retval::makeCode(CLASS_ID, 0); + static constexpr ReturnValue_t EXECUTION_FINISHED = retval::makeCode(CLASS_ID, 0); //! [EXPORT] : [COMMENT] Command is pending. This will also be returned if the user tries //! to load another command but a command is still pending @@ -42,9 +41,8 @@ class CommandExecutor { //! [EXPORT] : [COMMENT] Command execution failed static constexpr ReturnValue_t COMMAND_ERROR = retval::makeCode(CLASS_ID, 3); //! [EXPORT] : [COMMENT] - static constexpr ReturnValue_t NO_COMMAND_LOADED_OR_PENDING = - retval::makeCode(CLASS_ID, 4); - static constexpr ReturnValue_t PCLOSE_CALL_ERROR =retval::makeCode(CLASS_ID, 6); + static constexpr ReturnValue_t NO_COMMAND_LOADED_OR_PENDING = retval::makeCode(CLASS_ID, 4); + static constexpr ReturnValue_t PCLOSE_CALL_ERROR = retval::makeCode(CLASS_ID, 6); /** * Constructor. Is initialized with maximum size of internal buffer to read data from the