1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-03-16 08:29:15 +01:00

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");
This commit is contained in:
Alessio Morale 2016-05-03 00:07:35 +02:00
parent 1b254e4182
commit 5156c0c911

View File

@ -52,10 +52,16 @@
* The following code needs to be added to a function called at module initialization. * The following code needs to be added to a function called at module initialization.
* the second parameter is a unique counter Id. * 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 * A good pracice is to use the upper half word as module id and lower as counter id
* <pre>PERF_INIT_COUNTER(counterUpd, 0xA7710001); * Optionally three strings containing Module Name, Counter description and unit of measure can be passed.
* PERF_INIT_COUNTER(counterAtt, 0xA7710002); * Those strings will be used in future to automatically extract the list of counters from code to managed
* PERF_INIT_COUNTER(counterPeriod, 0xA7710003); * by GCS or some other custom tool.
* PERF_INIT_COUNTER(counterAccelSamples, 0xA7710004);</pre> *
* PERF_INIT_COUNTER(counterVariable, id, "MODULE NAME","COUNTER DESCRIPTION","UNIT OF MEASURE");
*
* <pre>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");</pre>
* *
* At this point you can start using the counters as in the following samples * 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 * 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 * 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 * those are the monitoring macros
*/ */
#define PERF_TIMED_SECTION_START(x) PIOS_Instrumentation_TimeStart(x) #define PERF_TIMED_SECTION_START(x) PIOS_Instrumentation_TimeStart(x)
#define PERF_TIMED_SECTION_END(x) PIOS_Instrumentation_TimeEnd(x) #define PERF_TIMED_SECTION_END(x) PIOS_Instrumentation_TimeEnd(x)
#define PERF_MEASURE_PERIOD(x) PIOS_Instrumentation_TrackPeriod(x) #define PERF_MEASURE_PERIOD(x) PIOS_Instrumentation_TrackPeriod(x)
#define PERF_TRACK_VALUE(x, y) PIOS_Instrumentation_updateCounter(x, y) #define PERF_TRACK_VALUE(x, y) PIOS_Instrumentation_updateCounter(x, y)
#define PERF_INCREMENT_VALUE(x) PIOS_Instrumentation_incrementCounter(x, 1) #define PERF_INCREMENT_VALUE(x) PIOS_Instrumentation_incrementCounter(x, 1)
#define PERF_DECREMENT_VALUE(x) PIOS_Instrumentation_incrementCounter(x, -1) #define PERF_DECREMENT_VALUE(x) PIOS_Instrumentation_incrementCounter(x, -1)
#else #else
#define PERF_DEFINE_COUNTER(x) #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_START(x)
#define PERF_TIMED_SECTION_END(x) #define PERF_TIMED_SECTION_END(x)
#define PERF_MEASURE_PERIOD(x) #define PERF_MEASURE_PERIOD(x)