From 5156c0c9111990e106d7e7e1849df3dd6fa8bcf2 Mon Sep 17 00:00:00 2001 From: Alessio Morale Date: Tue, 3 May 2016 00:07:35 +0200 Subject: [PATCH] LP-304 - Allow further info to be added to PERF_INIT_COUNTER for future feature support. This may allow in future to extract the counters id list with grep to be handled by gcs or other custom tools Proposed usage: PERF_INIT_COUNTER(counterVariable, id, "MODULE NAME","COUNTER DESCRIPTION","UNIT OF MEASURE"); i.e.: PERF_INIT_COUNTER(counterExecutionTime, 0xAC700001, "ACTUATOR", "Actuator update execution time", "uS"); --- flight/pios/inc/pios_instrumentation_helper.h | 32 ++++++++++++++++----------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/flight/pios/inc/pios_instrumentation_helper.h b/flight/pios/inc/pios_instrumentation_helper.h index 6a9423a66..277f183fe 100644 --- a/flight/pios/inc/pios_instrumentation_helper.h +++ b/flight/pios/inc/pios_instrumentation_helper.h @@ -52,10 +52,16 @@ * The following code needs to be added to a function called at module initialization. * the second parameter is a unique counter Id. * A good pracice is to use the upper half word as module id and lower as counter id - *
PERF_INIT_COUNTER(counterUpd, 0xA7710001);
- * PERF_INIT_COUNTER(counterAtt, 0xA7710002);
- * PERF_INIT_COUNTER(counterPeriod, 0xA7710003);
- * PERF_INIT_COUNTER(counterAccelSamples, 0xA7710004);
+ * Optionally three strings containing Module Name, Counter description and unit of measure can be passed. + * Those strings will be used in future to automatically extract the list of counters from code to managed + * by GCS or some other custom tool. + * + * PERF_INIT_COUNTER(counterVariable, id, "MODULE NAME","COUNTER DESCRIPTION","UNIT OF MEASURE"); + * + *
PERF_INIT_COUNTER(counterUpd, 0xA7710001, "ATTITUDE", "Sensor update execution time", "us");
+ * PERF_INIT_COUNTER(counterAtt, 0xA7710002, "ATTITUDE", "Attitude estimation execution time", "us");
+ * PERF_INIT_COUNTER(counterPeriod, 0xA7710003, "ATTITUDE", "Sensor update period", "us");
+ * PERF_INIT_COUNTER(counterAccelSamples, 0xA7710004, "ATTITUDE", "Samples for each sensor cycle", "count");
* * At this point you can start using the counters as in the following samples * @@ -85,27 +91,27 @@ /** * include the following macro together with modules variable declaration */ -#define PERF_DEFINE_COUNTER(x) static pios_counter_t x +#define PERF_DEFINE_COUNTER(x) static pios_counter_t x /** * this mast be called at some module init code */ -#define PERF_INIT_COUNTER(x, id) x = PIOS_Instrumentation_CreateCounter(id) +#define PERF_INIT_COUNTER(x, id, ...) x = PIOS_Instrumentation_CreateCounter(id) /** * those are the monitoring macros */ -#define PERF_TIMED_SECTION_START(x) PIOS_Instrumentation_TimeStart(x) -#define PERF_TIMED_SECTION_END(x) PIOS_Instrumentation_TimeEnd(x) -#define PERF_MEASURE_PERIOD(x) PIOS_Instrumentation_TrackPeriod(x) -#define PERF_TRACK_VALUE(x, y) PIOS_Instrumentation_updateCounter(x, y) -#define PERF_INCREMENT_VALUE(x) PIOS_Instrumentation_incrementCounter(x, 1) -#define PERF_DECREMENT_VALUE(x) PIOS_Instrumentation_incrementCounter(x, -1) +#define PERF_TIMED_SECTION_START(x) PIOS_Instrumentation_TimeStart(x) +#define PERF_TIMED_SECTION_END(x) PIOS_Instrumentation_TimeEnd(x) +#define PERF_MEASURE_PERIOD(x) PIOS_Instrumentation_TrackPeriod(x) +#define PERF_TRACK_VALUE(x, y) PIOS_Instrumentation_updateCounter(x, y) +#define PERF_INCREMENT_VALUE(x) PIOS_Instrumentation_incrementCounter(x, 1) +#define PERF_DECREMENT_VALUE(x) PIOS_Instrumentation_incrementCounter(x, -1) #else #define PERF_DEFINE_COUNTER(x) -#define PERF_INIT_COUNTER(x, id) +#define PERF_INIT_COUNTER(x, id, ...) #define PERF_TIMED_SECTION_START(x) #define PERF_TIMED_SECTION_END(x) #define PERF_MEASURE_PERIOD(x) -- 2.11.4.GIT