Skip to content

Commit

Permalink
HAL_ChibiOS: fixed CAN statistics on F4/L4/F3/F7
Browse files Browse the repository at this point in the history
  • Loading branch information
tridge committed Sep 14, 2023
1 parent ee316f0 commit e6e35ff
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions libraries/AP_HAL_ChibiOS/CANIface.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,17 @@ 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
*/
const bus_stats_t *get_statistics(void) const override {
return &stats;
}
#endif

/************************************
* Methods used inside interrupt *
************************************/
Expand Down
3 changes: 2 additions & 1 deletion libraries/AP_HAL_ChibiOS/CanIface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
}

Expand Down

0 comments on commit e6e35ff

Please sign in to comment.