From 444e48596a76c573feeac9a1f6ef1db812fb67d2 Mon Sep 17 00:00:00 2001 From: Oliver Hartkopp Date: Fri, 8 Dec 2023 17:29:04 +0100 Subject: [PATCH] isotpsniffer: simplify option for CAN FD link layer As the tx_dl and flags struct elements are not relevant for listen-only sockets, simplify the CAN FD command line option switch. Signed-off-by: Oliver Hartkopp --- isotpsniffer.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/isotpsniffer.c b/isotpsniffer.c index d118772..6ca29ae 100644 --- a/isotpsniffer.c +++ b/isotpsniffer.c @@ -77,8 +77,8 @@ void print_usage(char *prg) fprintf(stderr, " -c (color mode)\n"); fprintf(stderr, " -t (timestamp: (a)bsolute/(d)elta/(z)ero/(A)bsolute w date)\n"); fprintf(stderr, " -f (1 = HEX, 2 = ASCII, 3 = HEX & ASCII - default: %d)\n", FORMAT_DEFAULT); - fprintf(stderr, " -L :: (link layer options for CAN FD)\n"); - fprintf(stderr, " -h (head: print only first bytes)\n"); + fprintf(stderr, " -L (set link layer options for CAN FD)\n"); + fprintf(stderr, " -h (head: print only first bytes)\n"); fprintf(stderr, "\nCAN IDs and addresses are given and expected in hexadecimal values.\n"); fprintf(stderr, "\n"); } @@ -197,7 +197,7 @@ int main(int argc, char **argv) unsigned char buffer[4096]; int nbytes; - while ((opt = getopt(argc, argv, "s:d:x:X:h:ct:f:L:?")) != -1) { + while ((opt = getopt(argc, argv, "s:d:x:X:h:ct:f:L?")) != -1) { switch (opt) { case 's': src = strtoul(optarg, NULL, 16); @@ -226,14 +226,9 @@ int main(int argc, char **argv) break; case 'L': - if (sscanf(optarg, "%hhu:%hhu:%hhu", - &llopts.mtu, - &llopts.tx_dl, - &llopts.tx_flags) != 3) { - printf("unknown link layer options '%s'.\n", optarg); - print_usage(basename(argv[0])); - exit(1); - } + llopts.mtu = CANFD_MTU; + llopts.tx_dl = CANFD_MAX_DLEN; + llopts.tx_flags = CANFD_BRS; break; case 'h':