The open source OpenXR runtime
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

st/prober: Use and expose usb serial and manufacturer

authored by

Jakob Bornecrantz and committed by
Ryan Pavlik
b2c98794 80dd8929

+53 -18
+27 -16
src/xrt/state_trackers/prober/p_dump.c
··· 74 74 75 75 printf("\t% 3i: 0x%04x:0x%04x\n", id, pdev->base.vendor_id, 76 76 pdev->base.product_id); 77 - printf("\t\tptr: %p\n", (void *)pdev); 78 - printf("\t\tusb_dev_class: %02x\n", pdev->base.usb_dev_class); 77 + printf("\t\tptr: %p\n", (void *)pdev); 78 + printf("\t\tusb_dev_class: %02x\n", pdev->base.usb_dev_class); 79 + 80 + 81 + if (pdev->usb.serial != NULL || pdev->usb.product != NULL || 82 + pdev->usb.manufacturer != NULL) { 83 + printf("\t\tusb.product: %s\n", pdev->usb.product); 84 + printf("\t\tusb.manufacturer: %s\n", pdev->usb.manufacturer); 85 + printf("\t\tusb.serial: %s\n", pdev->usb.serial); 86 + } 79 87 80 88 if (pdev->usb.bus != 0 || pdev->usb.addr != 0) { 81 - printf("\t\tusb.bus: %i\n", pdev->usb.bus); 82 - printf("\t\tusb.addr: %i\n", pdev->usb.addr); 89 + printf("\t\tusb.bus: %i\n", pdev->usb.bus); 90 + printf("\t\tusb.addr: %i\n", pdev->usb.addr); 83 91 } 84 92 85 93 if (pdev->bluetooth.id != 0) { 86 - printf("\t\tbluetooth.id: %012" PRIx64 "\n", 94 + printf("\t\tbluetooth.id: %012" PRIx64 "\n", 87 95 pdev->bluetooth.id); 88 96 } 89 97 90 98 int num = pdev->usb.num_ports; 91 99 if (print_ports(tmp, ARRAY_SIZE(tmp), pdev->usb.ports, num)) { 92 - printf("\t\tport%s %s\n", num > 1 ? "s:" : ": ", tmp); 100 + printf("\t\tport%s %s\n", num > 1 ? "s:" : ": ", 101 + tmp); 93 102 } 94 103 95 104 #ifdef XRT_HAVE_LIBUSB 96 105 if (pdev->usb.dev != NULL) { 97 - printf("\t\tlibusb: %p\n", (void *)pdev->usb.dev); 106 + printf("\t\tlibusb: %p\n", (void *)pdev->usb.dev); 98 107 } 99 108 #endif 100 109 ··· 103 112 if (uvc_dev != NULL) { 104 113 struct uvc_device_descriptor *desc; 105 114 106 - printf("\t\tlibuvc: %p\n", (void *)uvc_dev); 115 + printf("\t\tlibuvc: %p\n", (void *)uvc_dev); 107 116 108 117 uvc_get_device_descriptor(uvc_dev, &desc); 109 118 110 119 if (desc->product != NULL) { 111 120 112 - printf("\t\tproduct: '%s'\n", desc->product); 121 + printf("\t\tproduct: '%s'\n", desc->product); 113 122 } 114 123 if (desc->manufacturer != NULL) { 115 124 116 - printf("\t\tmanufacturer: '%s'\n", desc->manufacturer); 125 + printf("\t\tmanufacturer: '%s'\n", 126 + desc->manufacturer); 117 127 } 118 128 if (desc->serialNumber != NULL) { 119 129 120 - printf("\t\tserial: '%s'\n", desc->serialNumber); 130 + printf("\t\tserial: '%s'\n", 131 + desc->serialNumber); 121 132 } 122 133 123 134 uvc_free_device_descriptor(desc); ··· 129 140 for (size_t j = 0; j < pdev->num_v4ls; j++) { 130 141 struct prober_v4l *v4l = &pdev->v4ls[j]; 131 142 132 - printf("\t\tv4l.iface: %i\n", (int)v4l->usb_iface); 133 - printf("\t\tv4l.index: %i\n", (int)v4l->v4l_index); 134 - printf("\t\tv4l.path: '%s'\n", v4l->path); 143 + printf("\t\tv4l.iface: %i\n", (int)v4l->usb_iface); 144 + printf("\t\tv4l.index: %i\n", (int)v4l->v4l_index); 145 + printf("\t\tv4l.path: '%s'\n", v4l->path); 135 146 } 136 147 #endif 137 148 ··· 139 150 for (size_t j = 0; j < pdev->num_hidraws; j++) { 140 151 struct prober_hidraw *hidraw = &pdev->hidraws[j]; 141 152 142 - printf("\t\thidraw.iface: %i\n", (int)hidraw->interface); 143 - printf("\t\thidraw.path: '%s'\n", hidraw->path); 153 + printf("\t\thidraw.iface: %i\n", (int)hidraw->interface); 154 + printf("\t\thidraw.path: '%s'\n", hidraw->path); 144 155 } 145 156 #endif 146 157 }
+12 -1
src/xrt/state_trackers/prober/p_prober.c
··· 378 378 pdev->usb.product = NULL; 379 379 } 380 380 381 + if (pdev->usb.manufacturer != NULL) { 382 + free((char *)pdev->usb.manufacturer); 383 + pdev->usb.manufacturer = NULL; 384 + } 385 + 386 + if (pdev->usb.serial != NULL) { 387 + free((char *)pdev->usb.serial); 388 + pdev->usb.serial = NULL; 389 + } 390 + 381 391 if (pdev->usb.path != NULL) { 382 392 free((char *)pdev->usb.path); 383 393 pdev->usb.path = NULL; ··· 726 736 fill_out_product(p, pdev); 727 737 } 728 738 729 - cb(xp, &pdev->base, pdev->usb.product, NULL, NULL, ptr); 739 + cb(xp, &pdev->base, pdev->usb.product, pdev->usb.manufacturer, 740 + pdev->usb.serial, ptr); 730 741 } 731 742 732 743 return 0;
+2
src/xrt/state_trackers/prober/p_prober.h
··· 93 93 94 94 #ifdef XRT_OS_LINUX 95 95 const char *product; 96 + const char *manufacturer; 97 + const char *serial; 96 98 const char *path; 97 99 #endif 98 100
+12 -1
src/xrt/state_trackers/prober/p_udev.c
··· 41 41 p_udev_add_usb(struct prober_device *pdev, 42 42 uint8_t dev_class, 43 43 const char *product, 44 + const char *manufacturer, 45 + const char *serial, 44 46 const char *path); 45 47 46 48 static void ··· 234 236 } 235 237 236 238 // Add info to usb device. 237 - p_udev_add_usb(pdev, dev_class, product, dev_path); 239 + p_udev_add_usb(pdev, dev_class, product, manufacturer, serial, 240 + dev_path); 238 241 239 242 next: 240 243 udev_device_unref(raw_dev); ··· 247 250 p_udev_add_usb(struct prober_device *pdev, 248 251 uint8_t dev_class, 249 252 const char *product, 253 + const char *manufacturer, 254 + const char *serial, 250 255 const char *path) 251 256 { 252 257 pdev->base.usb_dev_class = dev_class; 253 258 254 259 if (product != NULL) { 255 260 pdev->usb.product = strdup(product); 261 + } 262 + if (manufacturer != NULL) { 263 + pdev->usb.manufacturer = strdup(manufacturer); 264 + } 265 + if (serial != NULL) { 266 + pdev->usb.serial = strdup(serial); 256 267 } 257 268 if (path != NULL) { 258 269 pdev->usb.path = strdup(path);