examples: testlibusb: Always print VID and PID in addition to strings
Previously the program would only print the VID when the manufacturer string is unavailable and the PID when the product string is unavailable. Change this to print the VID and PID unconditionally and print the manufacturer and product strings similar to how the serial number string is being printed. In addition, line up the string values with the rest of the output. Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
This commit is contained in:
parent
88ded79caa
commit
cb95e3ad35
2 changed files with 16 additions and 27 deletions
|
@ -178,40 +178,29 @@ static void print_device(libusb_device *dev)
|
|||
return;
|
||||
}
|
||||
|
||||
printf("Dev (bus %u, device %u): ",
|
||||
libusb_get_bus_number(dev), libusb_get_device_address(dev));
|
||||
printf("Dev (bus %u, device %u): %04X - %04X\n",
|
||||
libusb_get_bus_number(dev), libusb_get_device_address(dev),
|
||||
desc.idVendor, desc.idProduct);
|
||||
|
||||
ret = libusb_open(dev, &handle);
|
||||
if (LIBUSB_SUCCESS == ret) {
|
||||
if (desc.iManufacturer)
|
||||
if (desc.iManufacturer) {
|
||||
ret = libusb_get_string_descriptor_ascii(handle, desc.iManufacturer, string, sizeof(string));
|
||||
else
|
||||
ret = LIBUSB_ERROR_NOT_FOUND;
|
||||
|
||||
if (ret > 0)
|
||||
printf("%s - ", string);
|
||||
else
|
||||
printf("%04X - ", desc.idVendor);
|
||||
printf(" Manufacturer: %s\n", string);
|
||||
}
|
||||
|
||||
if (desc.iProduct)
|
||||
if (desc.iProduct) {
|
||||
ret = libusb_get_string_descriptor_ascii(handle, desc.iProduct, string, sizeof(string));
|
||||
else
|
||||
ret = LIBUSB_ERROR_NOT_FOUND;
|
||||
|
||||
if (ret > 0)
|
||||
printf("%s\n", string);
|
||||
else
|
||||
printf("%04X\n", desc.idProduct);
|
||||
printf(" Product: %s\n", string);
|
||||
}
|
||||
|
||||
if (desc.iSerialNumber && verbose)
|
||||
if (desc.iSerialNumber && verbose) {
|
||||
ret = libusb_get_string_descriptor_ascii(handle, desc.iSerialNumber, string, sizeof(string));
|
||||
else
|
||||
ret = LIBUSB_ERROR_NOT_FOUND;
|
||||
|
||||
if (ret > 0)
|
||||
printf(" Serial Number: %s\n", string);
|
||||
} else {
|
||||
printf("%04X - %04X\n", desc.idVendor, desc.idProduct);
|
||||
}
|
||||
}
|
||||
|
||||
if (verbose) {
|
||||
|
|
|
@ -1 +1 @@
|
|||
#define LIBUSB_NANO 11422
|
||||
#define LIBUSB_NANO 11423
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue