lib/led: replace subscription missed error with perf count

This commit is contained in:
Daniel Agar 2021-09-15 12:23:18 -04:00
parent 113ea5ea26
commit e31dd34388
2 changed files with 10 additions and 6 deletions

View File

@ -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

View File

@ -43,16 +43,14 @@
#include <drivers/drv_hrt.h>
#include <drivers/drv_led.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/SubscriptionInterval.hpp>
#include <uORB/topics/led_control.h>
#include <uORB/topics/parameter_update.h>
#include <lib/parameters/param.h>
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