Browse Source

lib/led: error if dropping ORB_ID(led_control) messages

master
Daniel Agar 3 years ago
parent
commit
29a91306b5
  1. 7
      src/lib/led/led.cpp

7
src/lib/led/led.cpp

@ -41,11 +41,18 @@ @@ -41,11 +41,18 @@
int LedController::update(LedControlData &control_data)
{
while (_led_control_sub.updated() || _force_update) {
const unsigned last_generation = _led_control_sub.get_last_generation();
// handle new state
led_control_s led_control;
if (_led_control_sub.copy(&led_control)) {
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());
}
// don't apply the new state just yet to avoid interrupting an ongoing blinking state
for (int i = 0; i < BOARD_MAX_LEDS; ++i) {
if (led_control.led_mask & (1 << i)) {

Loading…
Cancel
Save