GeezerVison is showing github.com — listdevs: Also print portpath for non root hubs · Raghuvardhan-Reddy78/libusb@ebac6ac
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: examples/listdevs.c +15-2Lines changed: 15 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
24 | 24 | static void print_devs(libusb_device **devs) |
25 | 25 | { |
26 | 26 | libusb_device *dev; |
27 | | - int i = 0; |
| 27 | + int i = 0, j = 0; |
| 28 | + uint8_t path[8]; |
28 | 29 |
|
29 | 30 | while ((dev = devs[i++]) != NULL) { |
30 | 31 | struct libusb_device_descriptor desc; |
@@ -34,9 +35,21 @@ static void print_devs(libusb_device **devs) |
34 | 35 | return; |
35 | 36 | } |
36 | 37 |
|
37 | | - printf("%04x:%04x (bus %d, device %d)\n", |
| 38 | + printf("%04x:%04x (bus %d, device %d)", |
38 | 39 | desc.idVendor, desc.idProduct, |
39 | 40 | libusb_get_bus_number(dev), libusb_get_device_address(dev)); |
| 41 | + |
| 42 | + r = libusb_get_port_path(NULL, dev, path, sizeof(path)); |
| 43 | + if (r > 0) |
| 44 | + printf(" path: "); |
| 45 | + j = 0; |
| 46 | + while(j < r) { |
| 47 | + printf("%d", path[j]); |
| 48 | + j++; |
| 49 | + if (j < r) |
| 50 | + printf("."); |
| 51 | + } |
| 52 | + printf("\n"); |
40 | 53 | } |
41 | 54 | } |
42 | 55 |
|
|
Collapse file
Copy file name to clipboard +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
|
1 | | -#define LIBUSB_NANO 10691 |
| 1 | +#define LIBUSB_NANO 10692 |