aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Schodet2019-09-22 01:54:56 +0200
committerNicolas Schodet2019-09-22 01:54:56 +0200
commit20f45939aabfcb8e07591b2490aeba713f237639 (patch)
tree766779d063b38c2092c2efc7824228321a72d2d2
parent569ff7eb1dd8ffb66e708069f118ef0f96dce2b4 (diff)
Add -t to display time difference instead of time stamp
-rw-r--r--usbdump.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/usbdump.c b/usbdump.c
index d747a7e..4f9d1bd 100644
--- a/usbdump.c
+++ b/usbdump.c
@@ -42,6 +42,7 @@
int opt_unique_num = 0;
int opt_data_limit = -1;
int opt_control_only = 0;
+int opt_ts_diff = 0;
int64_t start_ts = 0;
int32_t start_ts_us = 0;
@@ -112,6 +113,10 @@ void process_packet(struct usbmon_packet *hdr, char *data)
ts -= 1;
ts_us = 1000000 + ts_us;
}
+ if (opt_ts_diff) {
+ start_ts = hdr->ts_sec;
+ start_ts_us = hdr->ts_usec;
+ }
if (hdr->epnum & USB_DIR_IN)
snprintf(linebuf+strlen(linebuf), LINEBUF_LEN-strlen(linebuf), "%d<-- ", hdr->epnum & 0x7f);
@@ -306,7 +311,7 @@ void usage(void)
{
printf("usbdump Copyright (C) 2011 Bert Vermeulen <bert@biot.com>\n");
- printf("usage: usbdump -d <vid:pid> [-u <num lines>] [-l <data limit>] [-c]\n");
+ printf("usage: usbdump -d <vid:pid> [-u <num lines>] [-l <data limit>] [-c] [-t]\n");
}
@@ -316,7 +321,7 @@ int main(int argc, char **argv)
char *device, *entry;
device = NULL;
- while ((opt = getopt(argc, argv, "d:u:l:c")) != -1) {
+ while ((opt = getopt(argc, argv, "d:u:l:ct")) != -1) {
switch (opt) {
case 'd':
if (strlen(optarg) != 9 || strspn(optarg, "01234567890abcdef:") != 9)
@@ -333,6 +338,9 @@ int main(int argc, char **argv)
case 'c':
opt_control_only = 1;
break;
+ case 't':
+ opt_ts_diff = 1;
+ break;
}
}