@@ -126,6 +126,10 @@ options:
126126 -T, --systime Print system time for each line received. The time
127127 is the absolute local time when the first character
128128 of each line is received by %s
129+ -F, --timeformat=<val> Specifies system time format for each received line
130+ e.g.
131+ -F \" %%Y-%%m-%%d %%H:%%M%%S.%%f\"
132+ (default \" %%H:%%M:%%S.%%f\" )
129133 -m, --match=<pat> Specify a regular expression pattern to match to
130134 set a base time. Time values for lines after the
131135 line matching the pattern will be relative to
@@ -143,6 +147,7 @@ options:
143147 -V, --version Show version number and exit
144148 -S, --skip Skip sanity checking of the serial device.
145149 May be needed for some devices.
150+ -n, --nodelta Skip printing delta between read lines.
146151 --crtonewline Promote a carriage return to be treated as a
147152 newline
148153
@@ -213,7 +218,7 @@ def grab(arglist, outputfd=sys.stdout):
213218 try :
214219 opts , args = getopt .getopt (
215220 arglist ,
216- "hli:d:b:B:w:p:s:xrfc:taTm :e:o:QvVq:S" , [
221+ "hli:d:b:B:w:p:s:xrfc:taTF:m :e:o:QvVq:S" , [
217222 "help" ,
218223 "launchtime" ,
219224 "instantpat=" ,
@@ -229,6 +234,7 @@ def grab(arglist, outputfd=sys.stdout):
229234 "time" ,
230235 "again" ,
231236 "systime" ,
237+ "timeformat=" ,
232238 "match=" ,
233239 "endtime=" ,
234240 "output=" ,
@@ -271,6 +277,8 @@ def grab(arglist, outputfd=sys.stdout):
271277 cr_to_nl = 0
272278 restart = False
273279 quiet = False
280+ systime_format = "%H:%M:%S.%f"
281+ use_delta = True
274282
275283 for opt , arg in opts :
276284 if opt in ["-h" , "--help" ]:
@@ -336,6 +344,8 @@ def grab(arglist, outputfd=sys.stdout):
336344 if opt in ["-T" , "--systime" ]:
337345 show_time = 0
338346 show_systime = 1
347+ if opt in ["-F" , "--timeformat" ]:
348+ systime_format = arg
339349 if opt in ["-m" , "--match" ]:
340350 basepat = arg
341351 if opt in ["-i" , "--instantpat" ]:
@@ -367,8 +377,10 @@ def grab(arglist, outputfd=sys.stdout):
367377 print ("grabserial version %d.%d.%d" % VERSION )
368378 sd .close ()
369379 sys .exit (0 )
370- if opt in ["-S" ]:
380+ if opt in ["-S" , "--skip" ]:
371381 skip_device_check = 1
382+ if opt in ["-n" , "--nodelta" ]:
383+ use_delta = False
372384 if opt in ["--crtonewline" ]:
373385 cr_to_nl = 1
374386
@@ -503,10 +515,13 @@ def grab(arglist, outputfd=sys.stdout):
503515
504516 if show_systime and newline :
505517 linetime = time .time ()
506- linetimestr = datetime .datetime .now ().strftime ("%H:%M:%S.%f" )
518+ linetimestr = datetime .datetime .now ().strftime (systime_format )
507519 elapsed = linetime - basetime
508- delta = elapsed - prev1
509- msg = "[%s %2.6f] " % (linetimestr , delta )
520+ if use_delta :
521+ delta = elapsed - prev1
522+ msg = "[%s %2.6f] " % (linetimestr , delta )
523+ else :
524+ msg = "[%s] " % (linetimestr )
510525 if not quiet :
511526 outputfd .write (msg )
512527 if out :
0 commit comments