From 1693549420ad5de6da40db4164dac0b543d9ed59 Mon Sep 17 00:00:00 2001 From: Grigoris Pavlakis <grigpavl@ece.auth.gr> Date: Sun, 1 Sep 2019 09:14:01 +0300 Subject: [PATCH] Update tests to use the new string output This marks completion of the arbitrary type field feature --- inc/Services/Parameter.hpp | 9 +++------ src/Services/Parameter.cpp | 2 +- test/Services/ParameterService.cpp | 11 +++++++++-- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/inc/Services/Parameter.hpp b/inc/Services/Parameter.hpp index 9cf9a015..25922c9a 100644 --- a/inc/Services/Parameter.hpp +++ b/inc/Services/Parameter.hpp @@ -6,7 +6,7 @@ // Number of binary flags in every parameter. Final number TBD. #define NUM_OF_FLAGS 3 -// Maximum etl::string length in bytes +// 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. @@ -20,13 +20,9 @@ * Useful type definitions * * @typedef ParamId: the unique ID of a parameter, used for searching - * @typedef ValueType: the type of the parameter's value (changing types is WIP) - * @typedef UpdatePtr: pointer to a void function, with a single ValueType* argument (return address) * @typedef Flags: container for the binary flags */ typedef uint16_t ParamId; -//typedef uint32_t ValueType; -//#typedef ; typedef etl::bitset<NUM_OF_FLAGS> Flags; /** @@ -53,6 +49,8 @@ typedef etl::bitset<NUM_OF_FLAGS> Flags; * as its update function pointer. Arguments initialValue and newPtr are optional, and have default values of * 0 and nullptr respectively. * + * @todo Update documentation + * * @public setCurrentValue(): Changes the current value of the parameter * @public getCurrentValue(): Gets the current value of the parameter * @public getPTC(), getPFC(): Returns the PFC and PTC of the parameter @@ -86,7 +84,6 @@ public: template <typename ValueType> class Parameter : public ParameterBase { void (* ptr)(ValueType*); - ValueType currentValue; public: diff --git a/src/Services/Parameter.cpp b/src/Services/Parameter.cpp index f1410d91..ab1fa516 100644 --- a/src/Services/Parameter.cpp +++ b/src/Services/Parameter.cpp @@ -10,4 +10,4 @@ uint8_t ParameterBase::getPFC() { void ParameterBase::setFlags(const char* flags) { this->flags = Flags(flags); -} \ No newline at end of file +} diff --git a/test/Services/ParameterService.cpp b/test/Services/ParameterService.cpp index 86987f9e..eb4dd86b 100644 --- a/test/Services/ParameterService.cpp +++ b/test/Services/ParameterService.cpp @@ -93,7 +93,10 @@ TEST_CASE("Parameter Report Subservice") { CHECK(report.readUint16() == 1); // only one parameter shall be contained CHECK(report.readUint16() == 1); // check for parameter ID - CHECK(report.readUint32() == 12); // check for value (defined when adding parameters) + uint8_t data[MAX_STRING_LENGTH]; + report.readString(data, MAX_STRING_LENGTH); + String<MAX_STRING_LENGTH> str = String<MAX_STRING_LENGTH>(data); + CHECK(str.compare("12")); // check for value as string (defined when adding parameters) ServiceTests::reset(); // clear all errors Services.reset(); // reset the services @@ -143,7 +146,11 @@ TEST_CASE("Parameter Setting Subservice") { CHECK(report.messageType == 2); CHECK(report.readUint16() == 1); // only 1 ID contained CHECK(report.readUint16() == 1); // contained ID should be ID 1 - CHECK(report.readUint32() == 3735928559); // whose value is 0xDEADBEEF + + char data[MAX_STRING_LENGTH]; + report.readString(data, MAX_STRING_LENGTH); + String<MAX_STRING_LENGTH> str = String<MAX_STRING_LENGTH>(data); + CHECK(str.compare("3735928559")); // whose value is the string 0xDEADBEEF ServiceTests::reset(); Services.reset(); -- GitLab