]> rtime.felk.cvut.cz Git - can-utils.git/commitdiff
canbusload: print bitstuffing mode when showing current time is enabled
authorOliver Hartkopp <socketcan@hartkopp.net>
Sat, 1 Feb 2014 20:30:12 +0000 (21:30 +0100)
committerOliver Hartkopp <socketcan@hartkopp.net>
Sat, 1 Feb 2014 20:30:12 +0000 (21:30 +0100)
When printing the current time on the first line the bitstuffing mode is
displayed depending on the command line settings.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
canbusload.c

index fb177d2d1e2e681c3a04ca569ccc4055b396e39f..8f6b10dc2ccb878a17e7035cda20906e971e0833 100644 (file)
@@ -108,7 +108,7 @@ void print_usage(char *prg)
        fprintf(stderr, "(interface) (received CAN frames) (used bits total) (used bits for payload)\n");
        fprintf(stderr, "\nExample:\n");
        fprintf(stderr, "\nuser$> canbusload can0@100000 can1@500000 can2@500000 can3@500000 -r -t -b -c\n\n");
-       fprintf(stderr, "%s 2008-05-27 15:18:49\n", prg);
+       fprintf(stderr, "%s 2014-02-01 21:13:16 (worst case bitstuffing)\n", prg);
        fprintf(stderr, " can0@100000   805   74491  36656  74%% |XXXXXXXXXXXXXX......|\n");
        fprintf(stderr, " can1@500000   796   75140  37728  15%% |XXX.................|\n");
        fprintf(stderr, " can2@500000     0       0      0   0%% |....................|\n");
@@ -139,7 +139,7 @@ void printstats(int signo)
 
                localtime_r(&currtime, &now);
 
-               printf("%s %04d-%02d-%02d %02d:%02d:%02d\n",
+               printf("%s %04d-%02d-%02d %02d:%02d:%02d ",
                       prg,
                       now.tm_year + 1900,
                       now.tm_mon + 1,
@@ -147,6 +147,28 @@ void printstats(int signo)
                       now.tm_hour,
                       now.tm_min,
                       now.tm_sec);
+
+               switch (mode) {
+
+               case CFL_NO_BITSTUFFING:
+                       /* plain bit calculation without bitstuffing */
+                       printf("(ignore bitstuffing)\n");
+                       break;
+
+               case CFL_WORSTCASE:
+                       /* worst case estimation - see above */
+                       printf("(worst case bitstuffing)\n");
+                       break;
+
+               case CFL_EXACT:
+                       /* exact calculation of stuffed bits based on frame content and CRC */
+                       printf("(exact bitstuffing)\n");
+                       break;
+
+               default:
+                       printf("(unknown bitstuffing)\n");
+                       break;
+               }
        }
 
        for (i=0; i<currmax; i++) {