AP_HAL_ChibiOS: record error states in CANFDIface and CANIface
This commit is contained in:
parent
a6f00e4f80
commit
ad9a8c8bd9
@ -886,6 +886,7 @@ void CANIface::pollErrorFlagsFromISR()
|
||||
const uint8_t cel = can_->ECR >> 16;
|
||||
|
||||
if (cel != 0) {
|
||||
stats.ecr = can_->ECR;
|
||||
for (int i = 0; i < NumTxMailboxes; i++) {
|
||||
if (!pending_tx_[i].abort_on_error || pending_tx_[i].aborted) {
|
||||
continue;
|
||||
@ -1041,7 +1042,8 @@ void CANIface::get_stats(ExpandingString &str)
|
||||
"rx_overflow: %lu\n"
|
||||
"rx_errors: %lu\n"
|
||||
"num_busoff_err: %lu\n"
|
||||
"num_events: %lu\n",
|
||||
"num_events: %lu\n"
|
||||
"ECR: %lx\n",
|
||||
stats.tx_requests,
|
||||
stats.tx_rejected,
|
||||
stats.tx_success,
|
||||
@ -1051,7 +1053,8 @@ void CANIface::get_stats(ExpandingString &str)
|
||||
stats.rx_overflow,
|
||||
stats.rx_errors,
|
||||
stats.num_busoff_err,
|
||||
stats.num_events);
|
||||
stats.num_events,
|
||||
stats.ecr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -159,6 +159,7 @@ class ChibiOS::CANIface : public AP_HAL::CANIface
|
||||
uint32_t rx_errors;
|
||||
uint32_t num_busoff_err;
|
||||
uint32_t num_events;
|
||||
uint32_t ecr;
|
||||
} stats;
|
||||
|
||||
public:
|
||||
|
@ -153,6 +153,7 @@ class ChibiOS::CANIface : public AP_HAL::CANIface
|
||||
uint32_t rx_errors;
|
||||
uint32_t num_busoff_err;
|
||||
uint32_t num_events;
|
||||
uint32_t esr;
|
||||
} stats;
|
||||
#endif
|
||||
|
||||
|
@ -590,6 +590,9 @@ void CANIface::pollErrorFlagsFromISR()
|
||||
{
|
||||
const uint8_t lec = uint8_t((can_->ESR & bxcan::ESR_LEC_MASK) >> bxcan::ESR_LEC_SHIFT);
|
||||
if (lec != 0) {
|
||||
#if !defined(HAL_BUILD_AP_PERIPH) && !defined(HAL_BOOTLOADER_BUILD)
|
||||
stats.esr = can_->ESR; // Record error status
|
||||
#endif
|
||||
can_->ESR = 0;
|
||||
|
||||
// Serving abort requests
|
||||
@ -950,7 +953,8 @@ void CANIface::get_stats(ExpandingString &str)
|
||||
"rx_overflow: %lu\n"
|
||||
"rx_errors: %lu\n"
|
||||
"num_busoff_err: %lu\n"
|
||||
"num_events: %lu\n",
|
||||
"num_events: %lu\n"
|
||||
"ESR: %lx\n",
|
||||
stats.tx_requests,
|
||||
stats.tx_rejected,
|
||||
stats.tx_success,
|
||||
@ -960,8 +964,8 @@ void CANIface::get_stats(ExpandingString &str)
|
||||
stats.rx_overflow,
|
||||
stats.rx_errors,
|
||||
stats.num_busoff_err,
|
||||
stats.num_events);
|
||||
memset(&stats, 0, sizeof(stats));
|
||||
stats.num_events,
|
||||
stats.esr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user