From 11edd1d05e6fac6f45706d98ccb9ddd621621874 Mon Sep 17 00:00:00 2001 From: Oliver Hartkopp Date: Sun, 1 Nov 2020 20:48:24 +0100 Subject: [PATCH] candump: support len8_dlc for standard candump output The display of Classical CAN raw DLC values is an expert feature which is not enabled by default to not break toolchains that use the candump standard output for further processing. (N.B. using the log file format and the functions from lib.h/lib.c provide convenient CAN frame conversions) After enabling the raw DLC for Classical CAN with the '-8' option the raw DLC value is printed in 'unusual' curly braces {}. Signed-off-by: Oliver Hartkopp --- candump.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/candump.c b/candump.c index 41f680c..ca7d067 100644 --- a/candump.c +++ b/candump.c @@ -134,6 +134,7 @@ void print_usage(char *prg) fprintf(stderr, " -D (Don't exit if a \"detected\" can device goes down.\n"); fprintf(stderr, " -d (monitor dropped CAN frames)\n"); fprintf(stderr, " -e (dump CAN error frames in human-readable format)\n"); + fprintf(stderr, " -8 (display raw DLC values in {} for Classical CAN)\n"); fprintf(stderr, " -x (print extra message infos, rx/tx brs esi)\n"); fprintf(stderr, " -T (terminate after without any reception)\n"); fprintf(stderr, "\n"); @@ -255,7 +256,7 @@ int main(int argc, char **argv) last_tv.tv_sec = 0; last_tv.tv_usec = 0; - while ((opt = getopt(argc, argv, "t:HciaSs:lDdxLn:r:heT:?")) != -1) { + while ((opt = getopt(argc, argv, "t:HciaSs:lDdxLn:r:he8T:?")) != -1) { switch (opt) { case 't': timestamp = optarg[0]; @@ -291,6 +292,10 @@ int main(int argc, char **argv) view |= CANLIB_VIEW_ERROR; break; + case '8': + view |= CANLIB_VIEW_LEN8_DLC; + break; + case 's': silent = atoi(optarg); if (silent > SILENT_ON) { @@ -359,7 +364,7 @@ int main(int argc, char **argv) } if (logfrmt && view) { - fprintf(stderr, "Log file format selected: Please disable ASCII/BINARY/SWAP options!\n"); + fprintf(stderr, "Log file format selected: Please disable ASCII/BINARY/SWAP/RAWDLC options!\n"); exit(0); }