Skip to content
Snippets Groups Projects
Unverified Commit 16935494 authored by Grigoris Pavlakis's avatar Grigoris Pavlakis
Browse files

Update tests to use the new string output

This marks completion of the arbitrary type field feature
parent 83658921
No related branches found
No related tags found
No related merge requests found
......@@ -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:
......
......@@ -10,4 +10,4 @@ uint8_t ParameterBase::getPFC() {
void ParameterBase::setFlags(const char* flags) {
this->flags = Flags(flags);
}
\ No newline at end of file
}
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment