Commit 32bf1efeaf058d5233de5c97a30530e564c0a17b

Authored by root
1 parent 8e1b403a

correction du script de test pour les endpoints

Showing 1 changed file with 11 additions and 10 deletions   Show diff stats
tests/test_list_endpoints.c
@@ -2,8 +2,9 @@ @@ -2,8 +2,9 @@
2 #include <stdio.h> 2 #include <stdio.h>
3 #include <stdlib.h> 3 #include <stdlib.h>
4 4
5 -#define ID_VENDOR 0x0951  
6 -#define ID_PRODUCT 0x01666 5 +// arduino ID vendor and product
  6 +#define ID_VENDOR 0x2341
  7 +#define ID_PRODUCT 0x43
7 8
8 // gcc file.c -l usb-1.0 9 // gcc file.c -l usb-1.0
9 10
@@ -26,8 +27,8 @@ int main(){ @@ -26,8 +27,8 @@ int main(){
26 if(status != 0) continue; 27 if(status != 0) continue;
27 28
28 // search for device 29 // search for device
29 - if(desc.idVendor != 0x0951  
30 - || desc.idProduct != 0x01666) 30 + if(desc.idVendor != ID_VENDOR
  31 + || desc.idProduct != ID_PRODUCT)
31 continue; 32 continue;
32 33
33 // open connection 34 // open connection
@@ -56,20 +57,20 @@ int main(){ @@ -56,20 +57,20 @@ int main(){
56 57
57 // claim interfaces 58 // claim interfaces
58 for(int j=0; j<config_desc->bNumInterfaces; j++){ 59 for(int j=0; j<config_desc->bNumInterfaces; j++){
59 - libusb_interface_descriptor *interface_desc = config_desc->interface[j].altsetting[0]; 60 + struct libusb_interface_descriptor interface_desc = config_desc->interface[j].altsetting[0];
60 61
61 - int interface = interface_desc->bInterfaceNumber; 62 + int interface = interface_desc.bInterfaceNumber;
62 status = libusb_claim_interface(handle, interface); 63 status = libusb_claim_interface(handle, interface);
63 if(status != 0){ perror("libusb_claim_interface"); exit(-1); } 64 if(status != 0){ perror("libusb_claim_interface"); exit(-1); }
64 65
65 // find endpoints 66 // find endpoints
66 - for(int k=0; k<interface_desc->bNumEndpoints; k++){  
67 - libusb_endpoint_descriptor *endpoint_desc = interface_desc->endpoints[k]; 67 + for(int k=0; k<interface_desc.bNumEndpoints; k++){
  68 + struct libusb_endpoint_descriptor endpoint_desc = interface_desc.endpoint[k];
68 69
69 // list endpoints bEndpointAddress and bmAttributes 70 // list endpoints bEndpointAddress and bmAttributes
70 printf("Endpoint inter. %d, num. %d\n", j, k); 71 printf("Endpoint inter. %d, num. %d\n", j, k);
71 - printf("bEndpointAddress = 0x%x\n", endpoint_desc->bEndpointAddress);  
72 - printf("bmAttributes = 0x%x\n", endpoint_desc->bmAttributes); 72 + printf("bEndpointAddress = 0x%x\n", endpoint_desc.bEndpointAddress);
  73 + printf("bmAttributes = 0x%x\n", endpoint_desc.bmAttributes);
73 } 74 }
74 75
75 // release interfaces 76 // release interfaces