Skip to content

Commit

Permalink
dshot: add driver stats to dshot status command
Browse files Browse the repository at this point in the history
  • Loading branch information
julianoes committed Mar 12, 2023
1 parent 3247fd9 commit f31898e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions platforms/nuttx/src/px4/stm/stm32_common/dshot/dshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

#include <px4_platform_common/px4_config.h>
#include <px4_platform_common/micro_hal.h>
#include <px4_platform_common/log.h>
#include <stm32_dma.h>
#include <stm32_tim.h>
#include <px4_arch/dshot.h>
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions src/drivers/drv_dshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions src/drivers/dshot/DShot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f31898e

Please sign in to comment.