From 5cd70c9908921b20f41f35a4eb54698577f20f9f Mon Sep 17 00:00:00 2001 From: Julian Oes Date: Mon, 7 Nov 2022 21:25:59 +1300 Subject: [PATCH] dshot: add driver stats to dshot status command --- platforms/nuttx/src/px4/stm/stm32_common/dshot/dshot.c | 7 +++++++ src/drivers/drv_dshot.h | 2 ++ src/drivers/dshot/DShot.cpp | 1 + 3 files changed, 10 insertions(+) diff --git a/platforms/nuttx/src/px4/stm/stm32_common/dshot/dshot.c b/platforms/nuttx/src/px4/stm/stm32_common/dshot/dshot.c index d8631d732b8e..404e9975c8b4 100644 --- a/platforms/nuttx/src/px4/stm/stm32_common/dshot/dshot.c +++ b/platforms/nuttx/src/px4/stm/stm32_common/dshot/dshot.c @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -567,4 +568,10 @@ void up_dshot_set_erpm_callback(void(*callback)(uint32_t[], size_t, void *), voi _erpm_callback_context = context; } +void print_driver_stats() +{ + PX4_INFO("dshot driver stats: %lu read, %lu failed nibble, %lu failed CRC, %lu invalid/zero", + read_ok, read_fail_nibble, read_fail_crc, read_fail_zero); +} + #endif diff --git a/src/drivers/drv_dshot.h b/src/drivers/drv_dshot.h index ca13b8fb55f0..2f4ca9903a31 100644 --- a/src/drivers/drv_dshot.h +++ b/src/drivers/drv_dshot.h @@ -141,4 +141,6 @@ __EXPORT extern bool up_dshot_get_periods(uint32_t periods[], size_t num_periods __EXPORT extern void up_dshot_set_erpm_callback(void(*callback)(uint32_t[], size_t, void *), void *context); +__EXPORT extern void print_driver_stats(void); + __END_DECLS diff --git a/src/drivers/dshot/DShot.cpp b/src/drivers/dshot/DShot.cpp index 67dccb3d2270..75f32b9c2266 100644 --- a/src/drivers/dshot/DShot.cpp +++ b/src/drivers/dshot/DShot.cpp @@ -738,6 +738,7 @@ int DShot::print_status() PX4_INFO("Outputs on: %s", _outputs_on ? "yes" : "no"); perf_print_counter(_cycle_perf); _mixing_output.printStatus(); + print_driver_stats(); if (_telemetry) { PX4_INFO("telemetry on: %s", _telemetry_device);