diff --git a/inc/ECSS_Definitions.hpp b/inc/ECSS_Definitions.hpp index c59a2624d5c4ba9b77f3dc68db1aa4284b0f4d2d..882052bc0e6c8f2639f4a090796f8af417b0e1fa 100644 --- a/inc/ECSS_Definitions.hpp +++ b/inc/ECSS_Definitions.hpp @@ -145,4 +145,15 @@ * @brief Size of the map holding the Parameter objects for the ST[20] parameter service */ #define ECSS_ST_20_MAX_PARAMETERS 5 + +/** + * @brief (TEMPORARY) Length of the flags bitset for each \ref Parameter of ST[20] + */ +#define ECSS_ST_20_NUMBER_OF_FLAGS 3 + +/** + * @brief Maximum etl::string output length in bytes for each \ref Parameter of ST[20] + */ + +#define ECSS_ST_20_MAX_STRING_LENGTH 5 #endif // ECSS_SERVICES_ECSS_DEFINITIONS_H diff --git a/inc/Services/Parameter.hpp b/inc/Services/Parameter.hpp index 7e6eae599d96c93726f3d3fa3f22108df9af2aa8..d74ee712e5be0adf54438a8c350078bd487eb55a 100644 --- a/inc/Services/Parameter.hpp +++ b/inc/Services/Parameter.hpp @@ -3,11 +3,8 @@ #include "etl/bitset.h" #include "etl/String.hpp" +#include "ECSS_Definitions.hpp" -// Number of binary flags in every parameter. Final number TBD. -#define NUM_OF_FLAGS 3 -// Maximum etl::string output length in bytes -#define MAX_STRING_LENGTH 5 /** * Implementation of a Parameter field, as specified in ECSS-E-ST-70-41C. * Fully compliant with the standards requirements, while adding some small, @@ -23,7 +20,7 @@ * @typedef Flags: container for the binary flags */ typedef uint16_t ParamId; -typedef etl::bitset<NUM_OF_FLAGS> Flags; +typedef etl::bitset<ECSS_ST_20_NUMBER_OF_FLAGS> Flags; typedef enum {STRING = 0, INT32 = 1, } TypesList; @@ -71,7 +68,7 @@ public: uint8_t getPFC(); - virtual String<MAX_STRING_LENGTH> getValueAsString() = 0; + virtual String<ECSS_ST_20_MAX_STRING_LENGTH> getValueAsString() = 0; template <typename ValueType> void setCurrentValue(ValueType newVal) { @@ -104,8 +101,8 @@ public: } } - String<MAX_STRING_LENGTH> getValueAsString() override { - String<MAX_STRING_LENGTH> contents(reinterpret_cast<uint8_t*>(¤tValue), sizeInBytes); + String<ECSS_ST_20_MAX_STRING_LENGTH> getValueAsString() override { + String<ECSS_ST_20_MAX_STRING_LENGTH> contents(reinterpret_cast<uint8_t*>(¤tValue), sizeInBytes); return contents; } }; diff --git a/src/Services/ParameterService.cpp b/src/Services/ParameterService.cpp index 9040a65eedd7ba8e1678e9c0e40392b782d2acb7..5863540614cf9f6b81a3a8e995219e3cbefad8d6 100644 --- a/src/Services/ParameterService.cpp +++ b/src/Services/ParameterService.cpp @@ -26,7 +26,7 @@ void ParameterService::addNewParameter(uint16_t id, ParameterBase* param, const } void ParameterService::reportParameterIds(Message& paramIds) { - etl::vector<std::pair<uint16_t, String<MAX_STRING_LENGTH>>, ECSS_ST_20_MAX_PARAMETERS> validParams; + etl::vector<std::pair<uint16_t, String<ECSS_ST_20_MAX_STRING_LENGTH>>, ECSS_ST_20_MAX_PARAMETERS> validParams; Message reqParam(20, 2, Message::TM, 1); // empty TM[20, 2] parameter report message @@ -50,7 +50,7 @@ void ParameterService::reportParameterIds(Message& paramIds) { uint16_t currId = paramIds.readUint16(); if (paramsList.find(currId) != paramsList.end()) { - std::pair<uint16_t, String<MAX_STRING_LENGTH>> p = std::make_pair(currId, paramsList.at(currId) + std::pair<uint16_t, String<ECSS_ST_20_MAX_STRING_LENGTH>> p = std::make_pair(currId, paramsList.at(currId) ->getValueAsString()); // pair containing the parameter's ID as first element and its current value as second validParams.push_back(p); diff --git a/test/Services/ParameterService.cpp b/test/Services/ParameterService.cpp index eb4dd86b3c8eab81d5579b6ac75989950a21aeac..b829bb5ce87c426ded7ac5240513f25f250d8cc5 100644 --- a/test/Services/ParameterService.cpp +++ b/test/Services/ParameterService.cpp @@ -93,9 +93,9 @@ TEST_CASE("Parameter Report Subservice") { CHECK(report.readUint16() == 1); // only one parameter shall be contained CHECK(report.readUint16() == 1); // check for parameter ID - uint8_t data[MAX_STRING_LENGTH]; - report.readString(data, MAX_STRING_LENGTH); - String<MAX_STRING_LENGTH> str = String<MAX_STRING_LENGTH>(data); + uint8_t data[ECSS_ST_20_MAX_STRING_LENGTH]; + report.readString(data, ECSS_ST_20_MAX_STRING_LENGTH); + String<ECSS_ST_20_MAX_STRING_LENGTH> str = String<ECSS_ST_20_MAX_STRING_LENGTH>(data); CHECK(str.compare("12")); // check for value as string (defined when adding parameters) ServiceTests::reset(); // clear all errors @@ -147,9 +147,9 @@ TEST_CASE("Parameter Setting Subservice") { CHECK(report.readUint16() == 1); // only 1 ID contained CHECK(report.readUint16() == 1); // contained ID should be ID 1 - char data[MAX_STRING_LENGTH]; - report.readString(data, MAX_STRING_LENGTH); - String<MAX_STRING_LENGTH> str = String<MAX_STRING_LENGTH>(data); + char data[ECSS_ST_20_MAX_STRING_LENGTH]; + report.readString(data, ECSS_ST_20_MAX_STRING_LENGTH); + String<ECSS_ST_20_MAX_STRING_LENGTH> str = String<ECSS_ST_20_MAX_STRING_LENGTH>(data); CHECK(str.compare("3735928559")); // whose value is the string 0xDEADBEEF ServiceTests::reset();