candump: add option -e to dump error messages in human readable format

If "candump" is called with the option "-e", the error messages are
dumped in human readable format:

  # candump -e any,0:0,#FFFFFFFF
  ...
  can0  20000088  [8] 00 00 80 19 00 00 00 00   ERRORFRAME
        protocol-violation{{error-on-tx}{acknowledge-slot}}
        bus-error
        error-counter{tx{128}rx{97}}
  ...
  can0  2000008C  [8] 00 08 80 19 00 00 00 00   ERRORFRAME
        controller-problem{tx-error-warning}
        protocol-violation{{error-on-tx}{acknowledge-slot}}
        bus-error
        error-counter{tx{128}rx{97}}

"candump" actually calles a library function snprintf_can_error_frame()
to do the formatting. It could be used for other purposes as well.

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
Acked-by: Kurt Van Dijck <kurt.van.dijck@eia.be>
This commit is contained in:
Wolfgang Grandegger
2011-02-14 15:49:27 +00:00
parent c9e79e55c3
commit 796475677a
3 changed files with 199 additions and 4 deletions
+7
View File
@@ -127,6 +127,7 @@ void sprint_canframe(char *buf , struct can_frame *cf, int sep);
#define CANLIB_VIEW_ASCII 0x1
#define CANLIB_VIEW_BINARY 0x2
#define CANLIB_VIEW_SWAP 0x4
#define CANLIB_VIEW_ERROR 0x8
#define SWAP_DELIMITER '`'
@@ -146,3 +147,9 @@ void sprint_long_canframe(char *buf , struct can_frame *cf, int view);
* fprint_long_canframe(stderr, &frame, NULL, 0); // no eol to STDERR
*
*/
void snprintf_can_error_frame(char *buf, int len, struct can_frame *cf,
char *sep);
/*
* Creates a CAN error frame output in user readable format.
*/