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

This commit is contained in:
Daniel Agar
2021-09-08 10:21:09 -04:00
parent 5c7882b787
commit 29a91306b5
+7
View File
@@ -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)) {