Skip to content

Commit

Permalink
xusb: Only retrieve BOS descriptor for bcdUSB 0x0201 or higher
Browse files Browse the repository at this point in the history
The "Binary device Object Store" (BOS) descriptor was introduced with
bcdUSB revision 0x0201.

References libusb#1492

Signed-off-by: Tormod Volden <[email protected]>
  • Loading branch information
tormodvolden committed May 26, 2024
1 parent 42e8a9f commit 34d2ca5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions examples/xusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -854,7 +854,6 @@ static int test_device(uint16_t vid, uint16_t pid)
libusb_device_handle *handle;
libusb_device *dev;
uint8_t bus, port_path[8];
struct libusb_bos_descriptor *bos_desc;
struct libusb_config_descriptor *conf_desc;
const struct libusb_endpoint_descriptor *endpoint;
int i, j, k, r;
Expand Down Expand Up @@ -908,14 +907,18 @@ static int test_device(uint16_t vid, uint16_t pid)
string_index[1] = dev_desc.iProduct;
string_index[2] = dev_desc.iSerialNumber;

printf("\nReading BOS descriptor: ");
if (libusb_get_bos_descriptor(handle, &bos_desc) == LIBUSB_SUCCESS) {
printf("%d caps\n", bos_desc->bNumDeviceCaps);
for (i = 0; i < bos_desc->bNumDeviceCaps; i++)
print_device_cap(bos_desc->dev_capability[i]);
libusb_free_bos_descriptor(bos_desc);
} else {
printf("no descriptor\n");
if (dev_desc.bcdUSB >= 0x0201) {
struct libusb_bos_descriptor *bos_desc;

printf("\nReading BOS descriptor: ");
if (libusb_get_bos_descriptor(handle, &bos_desc) == LIBUSB_SUCCESS) {
printf("%d caps\n", bos_desc->bNumDeviceCaps);
for (i = 0; i < bos_desc->bNumDeviceCaps; i++)
print_device_cap(bos_desc->dev_capability[i]);
libusb_free_bos_descriptor(bos_desc);
} else {
printf("no descriptor\n");
}
}

printf("\nReading first configuration descriptor:\n");
Expand Down
2 changes: 1 addition & 1 deletion libusb/version_nano.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define LIBUSB_NANO 11902
#define LIBUSB_NANO 11903

0 comments on commit 34d2ca5

Please sign in to comment.