>>>>> "Oliver" == Oliver Hartkopp <[email protected]> writes:


    Oliver> generally a reasonable idea. But your patch breaks the number of
    Oliver> items a shell script might expect to read when parsing a line.

What about an optional field width after -td, like
./candump -td2 any
 ( 0.000000)  can0   7042000  [8] 03 03 00 00 02 01 00 80
 ( 2.742890)  can0   7042000  [8] 03 03 00 00 02 01 00 80

-- 
Uwe Bonnes                [email protected]

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------
Index: trunk/can-utils/candump.c
===================================================================
--- trunk/can-utils/candump.c   (Revision 1230)
+++ trunk/can-utils/candump.c   (Arbeitskopie)
@@ -108,6 +108,7 @@
        fprintf(stderr, "\nUsage: %s [options] <CAN interface>+\n", prg);
        fprintf(stderr, "  (use CTRL-C to terminate %s)\n\n", prg);
        fprintf(stderr, "Options: -t <type>   (timestamp: 
(a)bsolute/(d)elta/(z)ero/(A)bsolute w date)\n");
+       fprintf(stderr, "                     ((opt) number after (d) specifies 
field width for seconds)\n");
        fprintf(stderr, "         -c          (increment color mode level)\n");
        fprintf(stderr, "         -i          (binary output - may exceed 80 
chars/line)\n");
        fprintf(stderr, "         -a          (enable additional ASCII 
output)\n");
@@ -203,6 +204,7 @@
        int bridge = 0;
        useconds_t bridge_delay = 0;
        unsigned char timestamp = 0;
+       unsigned char timestamp_width = 0xff;
        unsigned char dropmonitor = 0;
        unsigned char silent = SILENT_INI;
        unsigned char silentani = 0;
@@ -239,6 +241,10 @@
                switch (opt) {
                case 't':
                        timestamp = optarg[0];
+                        if(optarg[1]>= '0' && optarg[1] <= '9')
+                        {
+                            timestamp_width = optarg[1] - '0';
+                        }
                        if ((timestamp != 'a') && (timestamp != 'A') &&
                            (timestamp != 'd') && (timestamp != 'z')) {
                                fprintf(stderr, "%s: unknown timestamp mode 
'%c' - ignored\n",
@@ -716,8 +722,10 @@
                                                diff.tv_sec--, diff.tv_usec += 
1000000;
                                        if (diff.tv_sec < 0)
                                                diff.tv_sec = diff.tv_usec = 0;
-                                       printf("(%ld.%06ld) ", diff.tv_sec, 
diff.tv_usec);
-                               
+                                        if (timestamp_width == 0xff)
+                                            printf("(%ld.%06ld) ", 
diff.tv_sec, diff.tv_usec);
+                                        else
+                                            printf("(%*ld.%06ld) ", 
timestamp_width, diff.tv_sec, diff.tv_usec);
                                        if (timestamp == 'd')
                                                last_tv = tv; /* update for 
delta calculation */
                                }
_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core

Reply via email to