aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@s-opensource.com>2016-08-29 14:57:27 -0300
committerMauro Carvalho Chehab <mchehab@s-opensource.com>2016-08-29 14:59:11 -0300
commit3c73620b74cdce6b7abdf9e6715f2b03e134a3ce (patch)
treedf8e875b02e996fdd42ffb6a30953598ab547605 /contrib
parentd58543c21c2493ec4f74b1a54aaaf348f5eb3097 (diff)
parse_tcpdump_log.pl: fix logic that lists available devices
Right now, the list of devices doesn't help much if there are multiple devices on a hub. Fix it to suggest the syntax to filter just one device. Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/parse_tcpdump_log.pl38
1 files changed, 21 insertions, 17 deletions
diff --git a/contrib/parse_tcpdump_log.pl b/contrib/parse_tcpdump_log.pl
index 33fb50ed..32f88fe6 100755
--- a/contrib/parse_tcpdump_log.pl
+++ b/contrib/parse_tcpdump_log.pl
@@ -551,28 +551,32 @@ sub sigint_handler {
exit(0);
}
}
-
#
-# Ancillary routines to list what's connected to each USB port
+# Ancillary routine to list what's connected to each USB port
#
-sub parse_devices {
- my $file = $File::Find::name;
-
- return if (!($file =~ m/product/));
- return if (!($file =~ m/[0-9]+\-[0-9]+/));
- return if (($file =~ m/subsystem/));
-
- my $name = qx(cat $file);
- $name =~ s/\n//g;
- my ($bus, $port);
- ($bus, $port) = ($1, $2) if ($file =~ m/([0-9]+)\-([0-9]+)/);
+if ($list_devices) {
+ my ($bus, $dev, $name, $usb, $lastname);
- printf("usbmon%s ==> %s (level %s)\n",$bus, $name, $port);
-}
+ open IN, "/sys/kernel/debug/usb/devices";
+ while (<IN>) {
+ if (m/T:\s+Bus=(\d+).*Dev\#\=\s*(\d+)/) {
+ $bus = $1 + 0;
+ $dev = $2 + 0;
+ }
+ if (m/S:\s+Product=(.*)/) {
+ $name = $1;
+ }
+ if (m/P:\s+Vendor=(\S+)\s+ProdID=(\S+)\s+Rev=(\S+)/) {
+ $usb = "($1:$2 rev $3)";
+ }
+ if ($name && m/^$/) {
+ printf("For %-36s%-22s ==> $0 --device usbmon%s --usbdev %s\n", $name, $usb, $bus, $dev);
+ $lastname = $name;
+ }
+ }
+ printf("For %-36s%-22s ==> $0 --device usbmon%s --usbdev %s\n", $name, $usb, $bus, $dev) if ($lastname ne $name);
-if ($list_devices) {
- find({follow => 1, follow_skip => 2, wanted => \&parse_devices, no_chdir => 1}, "/sys/bus/usb/devices/");
exit;
}

Privacy Policy