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 30d23672cb66..757c8d28a8eb 100644 --- a/platforms/nuttx/src/px4/stm/stm32_common/dshot/dshot.c +++ b/platforms/nuttx/src/px4/stm/stm32_common/dshot/dshot.c @@ -512,7 +512,10 @@ void process_capture_results(void *arg) } if (_erpm_callback != NULL) { - _erpm_callback(_erpms, 4, _erpm_callback_context); + // Only publish every 4th time once all measurements have come in. + if (_motor_to_capture == 3) { + _erpm_callback(_erpms, 4, _erpm_callback_context); + } } _motor_to_capture = (_motor_to_capture + 1) % 4; diff --git a/src/drivers/dshot/DShot.cpp b/src/drivers/dshot/DShot.cpp index 2cd046dde684..3cd14b4787d1 100644 --- a/src/drivers/dshot/DShot.cpp +++ b/src/drivers/dshot/DShot.cpp @@ -622,6 +622,7 @@ void DShot::erpm_trampoline(uint32_t erpms[], size_t num_erpms, void *context) void DShot::erpm(uint32_t erpms[], size_t num_erpms) { + // TODO: this is hard-coded to 4 motors esc_status_s &esc_status = _esc_status_pub.get(); esc_status = {}; esc_status.timestamp = hrt_absolute_time();