From e31dd3438887ecff830bb8dd36f20d8a32b3e2cd Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Wed, 15 Sep 2021 12:23:18 -0400 Subject: [PATCH] lib/led: replace subscription missed error with perf count --- src/lib/led/led.cpp | 3 ++- src/lib/led/led.h | 13 ++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/lib/led/led.cpp b/src/lib/led/led.cpp index 8248dcc92b..6a96d49960 100644 --- a/src/lib/led/led.cpp +++ b/src/lib/led/led.cpp @@ -75,7 +75,8 @@ int LedController::update(LedControlData &control_data) if ((_led_control_sub.get_last_generation() != last_generation + 1) && (_led_control_sub.get_last_generation() != last_generation)) { - PX4_ERR("led_control lost, generation %d -> %d", last_generation, _led_control_sub.get_last_generation()); + perf_count(_led_control_sub_lost_perf); + PX4_DEBUG("led_control lost, generation %d -> %d", last_generation, _led_control_sub.get_last_generation()); } // don't apply the new state just yet to avoid interrupting an ongoing blinking state diff --git a/src/lib/led/led.h b/src/lib/led/led.h index 5d15161312..48a0cb17dc 100644 --- a/src/lib/led/led.h +++ b/src/lib/led/led.h @@ -43,16 +43,14 @@ #include #include - #include - +#include +#include #include #include #include #include -#include - using namespace time_literals; struct LedControlDataSingle { @@ -72,7 +70,10 @@ class LedController : public ModuleParams { public: LedController() : ModuleParams(nullptr) {} - ~LedController() override = default; + ~LedController() override + { + perf_free(_led_control_sub_lost_perf); + } /** * get maxium time between two consecutive calls to update() in us. @@ -185,6 +186,8 @@ private: hrt_abstime _last_update_call{0}; + perf_counter_t _led_control_sub_lost_perf{perf_alloc(PC_COUNT, MODULE_NAME": led_control message missed")}; + uint8_t _max_brightness{UINT8_MAX}; bool _force_update{true}; ///< force an orb_copy in the beginning