Commit 0cd64dcdca78a1e303cbe77b850892c611360fbb

Authored by gperson
1 parent 5c076d06

communication avec la manette OK !

Showing 2 changed files with 13 additions and 11 deletions   Show diff stats
src/libusb_wrapper.c
... ... @@ -18,11 +18,12 @@ void usbclose(libusb_context *context) {
18 18 void interfaceclaim(libusb_device_handle *handle, struct libusb_interface *interface){
19 19 const struct libusb_interface_descriptor * interface_desc = &interface->altsetting[0]; //TODO enlever cette ligne, refactor
20 20  
21   - if(interface_desc->bInterfaceClass == LIBUSB_CLASS_VENDOR_SPEC)//ON PEUT VERIFIER LA CLASS
22   - printf("> NOT vendor specific class\n");
  21 + if(interface_desc->bInterfaceClass == LIBUSB_CLASS_VENDOR_SPEC){//ON PEUT VERIFIER LA CLASS
  22 + printf("> vendor specific class\n");
23 23  
24   - int status=libusb_claim_interface(handle, interface_desc->bInterfaceNumber);
25   - if(status!=0){ perror("libusb_claim_interface"); exit(-1); }
  24 + int status=libusb_claim_interface(handle, interface_desc->bInterfaceNumber);
  25 + if(status!=0){ perror("libusb_claim_interface"); exit(-1); }
  26 + }
26 27 }
27 28  
28 29 void interfaceclose(libusb_device_handle *handle, struct libusb_interface *interface){
... ... @@ -286,4 +287,4 @@ char getOnlyEndpoint(struct libusb_interface * interface){
286 287 printf("> is NOT of type INTERRUPT\n");
287 288  
288 289 return (char)endpoint_desc->bEndpointAddress;
289   -}
290 290 \ No newline at end of file
  291 +}
... ...
src/main.c
... ... @@ -96,16 +96,17 @@ int main(int argc, char *argv[]){
96 96  
97 97  
98 98 /*LE CODE UTILE*/
99   -/*
100   - char data[MAX_DATA]; // data to send or to receive
101   - int size=...; // size to send or maximum size to receive
102   - int timeout=...; // timeout in ms
  99 +while(1){
  100 + unsigned char data[2] = {0xff,0xff}; // data to send or to receive
  101 + int size=2; // size to send or maximum size to receive
  102 + int timeout=1000; // timeout in ms
103 103  
104 104 //OUT interrupt, from host to device
105 105 int bytes_out;
106   - int status=libusb_interrupt_transfer(handle,endpoint_out,data,size,&bytes_out,timeout);
  106 + printf("%p %02X\n",device_handle,endpoint_leds);
  107 + int status=libusb_interrupt_transfer(device_handle,endpoint_leds,data,size,&bytes_out,timeout);
107 108 if(status!=0){ perror("libusb_interrupt_transfer"); exit(-1); }
108   -*/
  109 +}
109 110 /*FIN DU CODE UTILE*/
110 111  
111 112 //Close
... ...