From e5068e1f1d7e6262782564004c26ca4e149e8384 Mon Sep 17 00:00:00 2001 From: Jacob Dahl Date: Tue, 10 Feb 2026 14:06:27 -0900 Subject: [PATCH] cleanup print_status, rename perf counters --- .../src/px4/stm/stm32_common/dshot/dshot.c | 13 ++-------- src/drivers/dshot/DShot.cpp | 24 +++++++++---------- src/drivers/dshot/DShot.h | 8 +++---- src/drivers/dshot/DShotTelemetry.cpp | 6 ++--- 4 files changed, 21 insertions(+), 30 deletions(-) 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 4f65150228..6115d2c83c 100644 --- a/platforms/nuttx/src/px4/stm/stm32_common/dshot/dshot.c +++ b/platforms/nuttx/src/px4/stm/stm32_common/dshot/dshot.c @@ -1038,24 +1038,15 @@ void up_bdshot_status(void) if (_bdshot_channel_mask) { PX4_INFO("BDShot channel mask: 0x%2x", (unsigned)_bdshot_channel_mask); - // Show timer configuration - for (int i = 0; i < MAX_IO_TIMERS; i++) { - if (timer_configs[i].enabled) { - PX4_INFO("Timer %d: enabled=%d init=%d bidir=%d cap_ch=%d", - i, timer_configs[i].enabled, timer_configs[i].initialized, - timer_configs[i].bidirectional, timer_configs[i].capture_channel); - } - } - // Always show read counters for BDShot for (int i = 0; i < MAX_TIMER_IO_CHANNELS; i++) { if (_bdshot_channel_mask & (1 << i)) { if (_bdshot_capture_supported[i]) { - PX4_INFO("Output %u: read_ok %lu, fail_crc %lu", + PX4_INFO("Ch%u: read_ok %lu, fail_crc %lu", i, read_ok[i], read_fail_crc[i]); } else { - PX4_INFO("Output %u: no DMA for capture", i); + PX4_INFO("Ch%u: no DMA for capture", i); } } } diff --git a/src/drivers/dshot/DShot.cpp b/src/drivers/dshot/DShot.cpp index 72e0c042f2..393dc2259d 100644 --- a/src/drivers/dshot/DShot.cpp +++ b/src/drivers/dshot/DShot.cpp @@ -61,10 +61,10 @@ DShot::~DShot() perf_free(_cycle_perf); perf_free(_bdshot_success_perf); perf_free(_bdshot_error_perf); - perf_free(_telem_success_perf); - perf_free(_telem_error_perf); - perf_free(_telem_timeout_perf); - perf_free(_telem_allsampled_perf); + perf_free(_serial_telem_success_perf); + perf_free(_serial_telem_error_perf); + perf_free(_serial_telem_timeout_perf); + perf_free(_serial_telem_allsampled_perf); } int DShot::init() @@ -480,7 +480,7 @@ bool DShot::process_serial_telemetry() if (_serial_telem_online_mask & (1 << motor_index)) { consume_esc_data(esc, TelemetrySource::Serial); all_telem_sampled = set_next_telemetry_index(); - perf_count(_telem_success_perf); + perf_count(_serial_telem_success_perf); } else { hrt_abstime now = hrt_absolute_time(); @@ -507,7 +507,7 @@ bool DShot::process_serial_telemetry() // Consume an empty EscData to zero the data consume_esc_data(esc, TelemetrySource::Serial); all_telem_sampled = set_next_telemetry_index(); - perf_count(_telem_timeout_perf); + perf_count(_serial_telem_timeout_perf); break; case TelemetryStatus::ParseError: @@ -520,7 +520,7 @@ bool DShot::process_serial_telemetry() consume_esc_data(esc, TelemetrySource::Serial); all_telem_sampled = set_next_telemetry_index(); _serial_telem_delay_until = hrt_absolute_time() + 1_s; - perf_count(_telem_error_perf); + perf_count(_serial_telem_error_perf); break; } } @@ -549,7 +549,7 @@ bool DShot::set_next_telemetry_index() // Check if all motors have been sampled if (count_set_bits(_telemetry_requested_mask) >= count_set_bits(_output_mask)) { _telemetry_requested_mask = 0; - perf_count(_telem_allsampled_perf); + perf_count(_serial_telem_allsampled_perf); return true; } @@ -1131,10 +1131,10 @@ int DShot::print_status() } if (_serial_telemetry_enabled) { - perf_print_counter(_telem_success_perf); - perf_print_counter(_telem_error_perf); - perf_print_counter(_telem_timeout_perf); - perf_print_counter(_telem_allsampled_perf); + perf_print_counter(_serial_telem_success_perf); + perf_print_counter(_serial_telem_error_perf); + perf_print_counter(_serial_telem_timeout_perf); + perf_print_counter(_serial_telem_allsampled_perf); } print_spacer(); diff --git a/src/drivers/dshot/DShot.h b/src/drivers/dshot/DShot.h index 71d300025c..220ed0b524 100644 --- a/src/drivers/dshot/DShot.h +++ b/src/drivers/dshot/DShot.h @@ -179,10 +179,10 @@ private: perf_counter_t _cycle_perf{perf_alloc(PC_ELAPSED, MODULE_NAME": cycle")}; perf_counter_t _bdshot_success_perf{perf_alloc(PC_COUNT, MODULE_NAME": bdshot success")}; perf_counter_t _bdshot_error_perf{perf_alloc(PC_COUNT, MODULE_NAME": bdshot error")}; - perf_counter_t _telem_success_perf{perf_alloc(PC_COUNT, MODULE_NAME": telem success")}; - perf_counter_t _telem_error_perf{perf_alloc(PC_COUNT, MODULE_NAME": telem error")}; - perf_counter_t _telem_timeout_perf{perf_alloc(PC_COUNT, MODULE_NAME": telem timeout")}; - perf_counter_t _telem_allsampled_perf{perf_alloc(PC_COUNT, MODULE_NAME": telem all sampled")}; + perf_counter_t _serial_telem_success_perf{perf_alloc(PC_COUNT, MODULE_NAME": serial telem success")}; + perf_counter_t _serial_telem_error_perf{perf_alloc(PC_COUNT, MODULE_NAME": serial telem error")}; + perf_counter_t _serial_telem_timeout_perf{perf_alloc(PC_COUNT, MODULE_NAME": serial telem timeout")}; + perf_counter_t _serial_telem_allsampled_perf{perf_alloc(PC_COUNT, MODULE_NAME": serial telem all sampled")}; // Commands struct DShotCommand { diff --git a/src/drivers/dshot/DShotTelemetry.cpp b/src/drivers/dshot/DShotTelemetry.cpp index d547b61b3b..74d595486c 100644 --- a/src/drivers/dshot/DShotTelemetry.cpp +++ b/src/drivers/dshot/DShotTelemetry.cpp @@ -299,7 +299,7 @@ bool DShotTelemetry::telemetryResponseFinished() void DShotTelemetry::printStatus() const { - PX4_INFO("Number of successful ESC frames: %i", _num_successful_responses); - PX4_INFO("Number of timeouts: %i", _num_timeouts); - PX4_INFO("Number of CRC errors: %i", _num_checksum_errors); + PX4_INFO("Successful ESC frames: %i", _num_successful_responses); + PX4_INFO("Timeouts: %i", _num_timeouts); + PX4_INFO("CRC errors: %i", _num_checksum_errors); }