drivers: can: shell: print CAN statistics when showing CAN details

Print the CAN statistics when showing CAN controller details.

Signed-off-by: Henrik Brix Andersen <hebad@vestas.com>
This commit is contained in:
Henrik Brix Andersen 2023-10-03 11:03:36 +02:00 committed by Carles Cufí
parent 8beb0a3564
commit 1f779fa442
1 changed files with 11 additions and 0 deletions

View File

@ -362,6 +362,17 @@ static int cmd_can_show(const struct shell *sh, size_t argc, char **argv)
timing_min->prescaler, timing_max->prescaler);
}
#ifdef CONFIG_CAN_STATS
shell_print(sh, "statistics:");
shell_print(sh, " bit0 errors: %u", can_stats_get_bit0_errors(dev));
shell_print(sh, " bit1 errors: %u", can_stats_get_bit1_errors(dev));
shell_print(sh, " stuff errors: %u", can_stats_get_stuff_errors(dev));
shell_print(sh, " crc errors: %u", can_stats_get_crc_errors(dev));
shell_print(sh, " form errors: %u", can_stats_get_form_errors(dev));
shell_print(sh, " ack errors: %u", can_stats_get_ack_errors(dev));
shell_print(sh, " rx overruns: %u", can_stats_get_rx_overruns(dev));
#endif /* CONFIG_CAN_STATS */
return 0;
}