lib/led: replace subscription missed error with perf count

This commit is contained in:
Daniel Agar
2021-10-06 09:31:44 -04:00
parent 113ea5ea26
commit e31dd34388
2 changed files with 10 additions and 6 deletions
+2 -1
View File
@@ -75,7 +75,8 @@ int LedController::update(LedControlData &control_data)
if ((_led_control_sub.get_last_generation() != last_generation + 1) if ((_led_control_sub.get_last_generation() != last_generation + 1)
&& (_led_control_sub.get_last_generation() != last_generation)) { && (_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 // don't apply the new state just yet to avoid interrupting an ongoing blinking state
+8 -5
View File
@@ -43,16 +43,14 @@
#include <drivers/drv_hrt.h> #include <drivers/drv_hrt.h>
#include <drivers/drv_led.h> #include <drivers/drv_led.h>
#include <px4_platform_common/module_params.h> #include <px4_platform_common/module_params.h>
#include <lib/parameters/param.h>
#include <lib/perf/perf_counter.h>
#include <uORB/Subscription.hpp> #include <uORB/Subscription.hpp>
#include <uORB/SubscriptionInterval.hpp> #include <uORB/SubscriptionInterval.hpp>
#include <uORB/topics/led_control.h> #include <uORB/topics/led_control.h>
#include <uORB/topics/parameter_update.h> #include <uORB/topics/parameter_update.h>
#include <lib/parameters/param.h>
using namespace time_literals; using namespace time_literals;
struct LedControlDataSingle { struct LedControlDataSingle {
@@ -72,7 +70,10 @@ class LedController : public ModuleParams
{ {
public: public:
LedController() : ModuleParams(nullptr) {} 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. * get maxium time between two consecutive calls to update() in us.
@@ -185,6 +186,8 @@ private:
hrt_abstime _last_update_call{0}; 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}; uint8_t _max_brightness{UINT8_MAX};
bool _force_update{true}; ///< force an orb_copy in the beginning bool _force_update{true}; ///< force an orb_copy in the beginning