summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Dickens <christopher.a.dickens@gmail.com>2020-01-13 12:50:40 -0800
committerChris Dickens <christopher.a.dickens@gmail.com>2020-01-13 12:50:40 -0800
commitcb95e3ad35319eb1898eff791391a696a85775a5 (patch)
treefd5b138d01a464db639852eca686c434b26373a6
parent88ded79caa4c388739de140d709ccba6397ddd14 (diff)
downloadlibusb-cb95e3ad35319eb1898eff791391a696a85775a5.tar.gz
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>
-rwxr-xr-xexamples/testlibusb.c41
-rw-r--r--libusb/version_nano.h2
2 files changed, 16 insertions, 27 deletions
diff --git a/examples/testlibusb.c b/examples/testlibusb.c
index 3eb0fc6..7a29c1a 100755
--- a/examples/testlibusb.c
+++ b/examples/testlibusb.c
@@ -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);
+ if (ret > 0)
+ 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);
+ if (ret > 0)
+ 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 (ret > 0)
+ printf(" Serial Number: %s\n", string);
+ }
}
if (verbose) {
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 26ee5e6..bf39e2b 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11422
+#define LIBUSB_NANO 11423