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 <socketcan@hartkopp.net>
pull/269/head
Oliver Hartkopp 2020-11-01 20:48:24 +01:00
parent a272fd2082
commit 11edd1d05e
1 changed files with 7 additions and 2 deletions

View File

@ -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 (Don't exit if a \"detected\" can device goes down.\n");
fprintf(stderr, " -d (monitor dropped CAN frames)\n"); fprintf(stderr, " -d (monitor dropped CAN frames)\n");
fprintf(stderr, " -e (dump CAN error frames in human-readable format)\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, " -x (print extra message infos, rx/tx brs esi)\n");
fprintf(stderr, " -T <msecs> (terminate after <msecs> without any reception)\n"); fprintf(stderr, " -T <msecs> (terminate after <msecs> without any reception)\n");
fprintf(stderr, "\n"); fprintf(stderr, "\n");
@ -255,7 +256,7 @@ int main(int argc, char **argv)
last_tv.tv_sec = 0; last_tv.tv_sec = 0;
last_tv.tv_usec = 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) { switch (opt) {
case 't': case 't':
timestamp = optarg[0]; timestamp = optarg[0];
@ -291,6 +292,10 @@ int main(int argc, char **argv)
view |= CANLIB_VIEW_ERROR; view |= CANLIB_VIEW_ERROR;
break; break;
case '8':
view |= CANLIB_VIEW_LEN8_DLC;
break;
case 's': case 's':
silent = atoi(optarg); silent = atoi(optarg);
if (silent > SILENT_ON) { if (silent > SILENT_ON) {
@ -359,7 +364,7 @@ int main(int argc, char **argv)
} }
if (logfrmt && view) { 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); exit(0);
} }