author | Mike Sullivan <Mike.Sullivan@Oracle.COM> |
Fri, 15 Jan 2016 13:34:30 -0800 | |
changeset 5289 | 255be830c2e5 |
parent 229 | 1fd565334dfc |
permissions | -rw-r--r-- |
229
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
1 |
/* |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
2 |
* testlibusb.c |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
3 |
* |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
4 |
* Test suite program |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
5 |
*/ |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
6 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
7 |
#include <stdio.h> |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
8 |
#include "usb.h" |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
9 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
10 |
void |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
11 |
dump_data(unsigned char *data, int size) |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
12 |
{ |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
13 |
int i; |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
14 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
15 |
if (size) { |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
16 |
printf("data dump:"); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
17 |
for (i = 0; i < size; i++) { |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
18 |
if (i % 16 == 0) { |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
19 |
printf("\n%08x ", i); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
20 |
} |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
21 |
printf("%02x ", (uchar_t)data[i]); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
22 |
} |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
23 |
printf("\n"); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
24 |
} |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
25 |
} |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
26 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
27 |
void print_endpoint(struct usb_endpoint_descriptor *endpoint) |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
28 |
{ |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
29 |
printf(" Endpoint descriptor:\n"); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
30 |
printf(" bEndpointAddress: %02xh\n", endpoint->bEndpointAddress); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
31 |
printf(" bmAttributes: %02xh\n", endpoint->bmAttributes); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
32 |
printf(" wMaxPacketSize: %d\n", endpoint->wMaxPacketSize); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
33 |
printf(" bInterval: %d\n", endpoint->bInterval); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
34 |
printf(" bRefresh: %d\n", endpoint->bRefresh); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
35 |
printf(" bSynchAddress: %d\n", endpoint->bSynchAddress); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
36 |
printf(" extralen: %d\n", endpoint->extralen); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
37 |
dump_data(endpoint->extra, endpoint->extralen); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
38 |
} |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
39 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
40 |
void print_altsetting(struct usb_interface_descriptor *interface) |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
41 |
{ |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
42 |
int i; |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
43 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
44 |
printf(" Interface descriptor:\n"); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
45 |
printf(" bInterfaceNumber: %d\n", interface->bInterfaceNumber); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
46 |
printf(" bAlternateSetting: %d\n", interface->bAlternateSetting); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
47 |
printf(" bNumEndpoints: %d\n", interface->bNumEndpoints); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
48 |
printf(" bInterfaceClass: %d\n", interface->bInterfaceClass); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
49 |
printf(" bInterfaceSubClass: %d\n", interface->bInterfaceSubClass); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
50 |
printf(" bInterfaceProtocol: %d\n", interface->bInterfaceProtocol); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
51 |
printf(" iInterface: %d\n", interface->iInterface); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
52 |
printf(" extralen: %d\n", interface->extralen); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
53 |
dump_data(interface->extra, interface->extralen); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
54 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
55 |
for (i = 0; i < interface->bNumEndpoints; i++) |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
56 |
print_endpoint(&interface->endpoint[i]); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
57 |
} |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
58 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
59 |
void print_interface(struct usb_interface *interface) |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
60 |
{ |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
61 |
int i; |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
62 |
printf("num_altsetting: %d\n", interface->num_altsetting); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
63 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
64 |
for (i = 0; i < interface->num_altsetting; i++) |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
65 |
print_altsetting(&interface->altsetting[i]); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
66 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
67 |
printf("\n"); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
68 |
} |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
69 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
70 |
void print_configuration(struct usb_config_descriptor *config) |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
71 |
{ |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
72 |
int i; |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
73 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
74 |
printf(" Configuration descriptor:\n"); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
75 |
printf(" wTotalLength: %d\n", config->wTotalLength); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
76 |
printf(" bNumInterfaces: %d\n", config->bNumInterfaces); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
77 |
printf(" bConfigurationValue: %d\n", config->bConfigurationValue); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
78 |
printf(" iConfiguration: %d\n", config->iConfiguration); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
79 |
printf(" bmAttributes: %02xh\n", config->bmAttributes); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
80 |
printf(" MaxPower: %d\n", config->MaxPower); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
81 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
82 |
printf(" extralen: %d\n", config->extralen); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
83 |
dump_data(config->extra, config->extralen); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
84 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
85 |
for (i = 0; i < config->bNumInterfaces; i++) |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
86 |
print_interface(&config->interface[i]); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
87 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
88 |
printf("\n"); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
89 |
} |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
90 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
91 |
void print_device_descriptor(struct usb_device_descriptor *dev) |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
92 |
{ |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
93 |
printf(" Device descriptor:\n"); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
94 |
printf(" bLength: %d\n", dev->bLength); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
95 |
printf(" bDescriptorType: %xh\n", dev->bDescriptorType); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
96 |
printf(" bcdUSB: %xh\n", dev->bcdUSB); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
97 |
printf(" bDeviceClass: %xh\n", dev->bDeviceClass); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
98 |
printf(" bDeviceSubClass: %xh\n", dev->bDeviceSubClass); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
99 |
printf(" bDeviceProtocol: %xh\n", dev->bDeviceProtocol); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
100 |
printf(" bMaxPacketSize0: %xh\n", dev->bMaxPacketSize0); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
101 |
printf(" idVendor: %xh\n", dev->idVendor); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
102 |
printf(" idProduct: %xh\n", dev->bcdDevice); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
103 |
printf(" bcdDevice: %xh\n", dev->bcdDevice); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
104 |
printf(" iManufacturer: %xh\n", dev->iManufacturer); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
105 |
printf(" iProduct: %xh\n", dev->iProduct); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
106 |
printf(" iSerialNumber: %xh\n", dev->iSerialNumber); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
107 |
printf(" bNumConfigurations: %xh\n", dev->bNumConfigurations); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
108 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
109 |
printf("\n"); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
110 |
} |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
111 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
112 |
int main(void) |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
113 |
{ |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
114 |
struct usb_bus *bus; |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
115 |
struct usb_device *dev; |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
116 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
117 |
usb_init(); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
118 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
119 |
usb_find_busses(); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
120 |
usb_find_devices(); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
121 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
122 |
printf("bus/device idVendor/idProduct\n"); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
123 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
124 |
for (bus = usb_busses; bus; bus = bus->next) { |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
125 |
for (dev = bus->devices; dev; dev = dev->next) { |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
126 |
int i, ret; |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
127 |
char string[256]; |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
128 |
usb_dev_handle *udev; |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
129 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
130 |
printf("%s/%s %04X/%04X\n", bus->dirname, dev->filename, |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
131 |
dev->descriptor.idVendor, dev->descriptor.idProduct); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
132 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
133 |
udev = usb_open(dev); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
134 |
if (udev) { |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
135 |
if (dev->descriptor.iManufacturer) { |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
136 |
ret = usb_get_string_simple(udev, dev->descriptor.iManufacturer, string, sizeof(string)); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
137 |
if (ret > 0) |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
138 |
printf("- Manufacturer : %s\n", string); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
139 |
else |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
140 |
printf("- Unable to fetch manufacturer string %d\n", ret); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
141 |
} |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
142 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
143 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
144 |
if (dev->descriptor.iProduct) { |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
145 |
ret = usb_get_string_simple(udev, dev->descriptor.iProduct, string, sizeof(string)); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
146 |
if (ret > 0) |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
147 |
printf("- Product : %s\n", string); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
148 |
else |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
149 |
printf("- Unable to fetch product string\n"); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
150 |
} |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
151 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
152 |
if (dev->descriptor.iSerialNumber) { |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
153 |
ret = usb_get_string_simple(udev, dev->descriptor.iSerialNumber, string, sizeof(string)); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
154 |
if (ret > 0) |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
155 |
printf("- Serial Number: %s\n", string); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
156 |
else |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
157 |
printf("- Unable to fetch serial number string\n"); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
158 |
} |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
159 |
usb_close(udev); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
160 |
} |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
161 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
162 |
if (!dev->config) { |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
163 |
printf(" Couldn't retrieve descriptors\n"); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
164 |
continue; |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
165 |
} |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
166 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
167 |
print_device_descriptor(&dev->descriptor); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
168 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
169 |
for (i = 0; i < dev->descriptor.bNumConfigurations; i++) { |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
170 |
print_configuration(&dev->config[i]); |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
171 |
} |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
172 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
173 |
} |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
174 |
} |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
175 |
|
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
176 |
return 0; |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
177 |
} |
1fd565334dfc
7043696 libusb should move to userland
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff
changeset
|
178 |