diff options
author | Hans de Goede <hdegoede@redhat.com> | 2013-05-16 22:36:26 +0200 |
---|---|---|
committer | Hans de Goede <hdegoede@redhat.com> | 2013-05-16 22:36:26 +0200 |
commit | ebac6ac1b30aea6e9190cce336eb75dc0f1c5ce7 (patch) | |
tree | 62f9df572ab092e5257a7faafe4723c7f7acb850 /examples | |
parent | 6391d86e818bf4ed63842cad278c2fb2572dc5d8 (diff) | |
download | libusb-ebac6ac1b30aea6e9190cce336eb75dc0f1c5ce7.tar.gz |
listdevs: Also print portpath for non root hubs
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/listdevs.c | 17 |
1 files changed, 15 insertions, 2 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"); } } |