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

Convert the Parameter struct to its own class

in order to make construction and adding more natural
parent e28b54b6
No related branches found
No related tags found
No related merge requests found
#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)(&currentValue); // call the update function for the initial value
}
};
#endif //ECSS_SERVICES_PARAMETER_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
......
#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
......
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