From 1f779fa4428115e2f1b9598a943fd5cc6dbb746e Mon Sep 17 00:00:00 2001 From: Henrik Brix Andersen Date: Tue, 3 Oct 2023 11:03:36 +0200 Subject: [PATCH] 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 --- drivers/can/can_shell.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/can/can_shell.c b/drivers/can/can_shell.c index e07de338952..bc0286d2ea6 100644 --- a/drivers/can/can_shell.c +++ b/drivers/can/can_shell.c @@ -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; }