diff --git a/inc/Services/Parameter.hpp b/inc/Services/Parameter.hpp new file mode 100644 index 0000000000000000000000000000000000000000..ad2436d571666fb5b0cc69e278916b949704ef2a --- /dev/null +++ b/inc/Services/Parameter.hpp @@ -0,0 +1,39 @@ +#ifndef ECSS_SERVICES_PARAMETER_HPP +#define ECSS_SERVICES_PARAMETER_HPP + +#include "etl/bitset.h" + +// Number of binary flags in every parameter. +#define NUM_OF_FLAGS 5 + +/** + * Generic parameter structure + * PTC and PFC for each parameter shall be specified as in + * ECSS-E-ST-70-41C, chapter 7.3 + */ + +typedef uint16_t ParamId; // parameter IDs are given sequentially +typedef void(*UpdatePtr)(uint32_t*); // pointer to the update function of this parameter +// (argument is a pointer to the variable where the value will be returned, in +// this case currentValue) + +class Parameter { + uint8_t ptc = 0; // Packet field type code (PTC) + uint8_t pfc = 0; // Packet field format code (PFC) + UpdatePtr ptr = nullptr; // Function pointer used for updates + uint32_t currentValue = 0; // Last good value of the parameter + etl::bitset<NUM_OF_FLAGS> flags = {false}; + // Various flags (TBD which. Ideas: update with priority, do not poll, etc.) + + public: + Parameter(uint8_t new_ptc, uint8_t new_pfc, UpdatePtr new_ptr) { + ptc = new_ptc; + pfc = new_pfc; + ptr = new_ptr; + + (*ptr)(¤tValue); // call the update function for the initial value + } +}; + + +#endif //ECSS_SERVICES_PARAMETER_HPP diff --git a/inc/Services/ParameterService.hpp b/inc/Services/ParameterService.hpp index 4974dbc7b371c7c2840713320cd3d55891d80ced..e4093a4129fd6cfff6d346ab28062aec90e41b1f 100644 --- a/inc/Services/ParameterService.hpp +++ b/inc/Services/ParameterService.hpp @@ -3,14 +3,12 @@ #include "Service.hpp" #include "ErrorHandler.hpp" +#include "Parameter.hpp" #include "etl/map.h" -#include "etl/bitset.h" // Number of stored parameters. MAX_PARAMS is just a dummy number for now. #define MAX_PARAMS 5 -// Number of binary flags in every parameter. -#define NUM_OF_FLAGS 5 /** * Implementation of the ST[20] parameter management service, * as defined in ECSS-E-ST-70-41C @@ -18,21 +16,6 @@ * @author Grigoris Pavlakis <grigpavl@ece.auth.gr> */ -/** - * Generic parameter structure - * PTC and PFC for each parameter shall be specified as in - * ECSS-E-ST-70-41C, chapter 7.3 - */ -typedef uint16_t ParamId; // parameter IDs are given sequentially -struct Parameter { - uint8_t ptc; // Packet field type code (PTC) - uint8_t pfc; // Packet field format code (PFC) - void (*updatePtr)(); // Pointer to the function used to update the value - uint32_t currentValue; // Last good value of the parameter - etl::bitset<NUM_OF_FLAGS> flags; // Various flags (TBD which). - // (Ideas: update with priority, do not poll, etc.) -}; - /** * Parameter manager - ST[20] * Holds the list with the parameters and provides functions diff --git a/src/Services/ParameterService.cpp b/src/Services/ParameterService.cpp index 2bd6f638ec6c7f4c7e4af171e566c975dc54ce5f..a22b730e4772b827c6ae0f7bb69b96af2ec44ec6 100644 --- a/src/Services/ParameterService.cpp +++ b/src/Services/ParameterService.cpp @@ -1,12 +1,7 @@ #include "Services/ParameterService.hpp" -//#define DEMOMODE - -//#include <ctime> -//#include <cstdlib> ParameterService::ParameterService() { -//#ifdef DEMOMODE // // Test code, setting up some of the parameter fields // // time_t currTime = time(nullptr); @@ -34,6 +29,8 @@ ParameterService::ParameterService() { //#endif } +void + void ParameterService::reportParameterIds(Message& paramIds) { paramIds.assertTC(20, 1); Message reqParam(20, 2, Message::TM, 1); // empty TM[20, 2] parameter report message