From ebac6ac1b30aea6e9190cce336eb75dc0f1c5ce7 Mon Sep 17 00:00:00 2001 From: Hans de Goede Date: Thu, 16 May 2013 22:36:26 +0200 Subject: [PATCH] listdevs: Also print portpath for non root hubs Signed-off-by: Hans de Goede --- examples/listdevs.c | 17 +++++++++++++++-- libusb/version_nano.h | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/examples/listdevs.c b/examples/listdevs.c index e3d7ef0..05b3998 100644 --- a/examples/listdevs.c +++ b/examples/listdevs.c @@ -24,7 +24,8 @@ static void print_devs(libusb_device **devs) { libusb_device *dev; - int i = 0; + int i = 0, j = 0; + uint8_t path[8]; while ((dev = devs[i++]) != NULL) { struct libusb_device_descriptor desc; @@ -34,9 +35,21 @@ static void print_devs(libusb_device **devs) return; } - printf("%04x:%04x (bus %d, device %d)\n", + printf("%04x:%04x (bus %d, device %d)", desc.idVendor, desc.idProduct, libusb_get_bus_number(dev), libusb_get_device_address(dev)); + + r = libusb_get_port_path(NULL, dev, path, sizeof(path)); + if (r > 0) + printf(" path: "); + j = 0; + while(j < r) { + printf("%d", path[j]); + j++; + if (j < r) + printf("."); + } + printf("\n"); } } diff --git a/libusb/version_nano.h b/libusb/version_nano.h index 3940d93..bc585fc 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 10691 +#define LIBUSB_NANO 10692 -- 2.34.1