From e6e35ff48b6db65617149bccc8de514959c013a6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 14 Sep 2023 08:18:57 +1000 Subject: [PATCH] HAL_ChibiOS: fixed CAN statistics on F4/L4/F3/F7 --- libraries/AP_HAL_ChibiOS/CANIface.h | 3 +++ libraries/AP_HAL_ChibiOS/CanIface.cpp | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libraries/AP_HAL_ChibiOS/CANIface.h b/libraries/AP_HAL_ChibiOS/CANIface.h index ebda8635ec77d..47809fa79b35a 100644 --- a/libraries/AP_HAL_ChibiOS/CANIface.h +++ b/libraries/AP_HAL_ChibiOS/CANIface.h @@ -218,7 +218,9 @@ class ChibiOS::CANIface : public AP_HAL::CANIface // fetch stats text and return the size of the same, // results available via @SYS/can0_stats.txt or @SYS/can1_stats.txt void get_stats(ExpandingString &str) override; +#endif +#if !defined(HAL_BOOTLOADER_BUILD) /* return statistics structure */ @@ -226,6 +228,7 @@ class ChibiOS::CANIface : public AP_HAL::CANIface return &stats; } #endif + /************************************ * Methods used inside interrupt * ************************************/ diff --git a/libraries/AP_HAL_ChibiOS/CanIface.cpp b/libraries/AP_HAL_ChibiOS/CanIface.cpp index f7edd221982f3..677f484804943 100644 --- a/libraries/AP_HAL_ChibiOS/CanIface.cpp +++ b/libraries/AP_HAL_ChibiOS/CanIface.cpp @@ -292,6 +292,7 @@ int16_t CANIface::send(const AP_HAL::CANFrame& frame, uint64_t tx_deadline, if (frame.isErrorFrame() || frame.dlc > 8) { return -1; } + PERF_STATS(stats.tx_requests); /* * Normally we should perform the same check as in @ref canAcceptNewTxFrame(), because @@ -323,7 +324,7 @@ int16_t CANIface::send(const AP_HAL::CANFrame& frame, uint64_t tx_deadline, } else if ((can_->TSR & bxcan::TSR_TME2) == bxcan::TSR_TME2) { txmailbox = 2; } else { - PERF_STATS(stats.tx_rejected); + PERF_STATS(stats.tx_overflow); return 0; // No transmission for you. }