Commit f8fc88aa7576bf3fa52499be36eff347c5016025

Authored by gperson
1 parent 7e2160f8

avancement juste avant de claim, iterations des interfaces

Showing 2 changed files with 34 additions and 11 deletions   Show diff stats
src/libusb_wrapper.c
... ... @@ -126,13 +126,13 @@ void displayDeviceEndpoints(libusb_device_handle* handle) {
126 126  
127 127  
128 128 // lectures des configs?
129   - int configuration = 0; // valueof("bConfigurationValue");
  129 +/* int configuration = 0; // valueof("bConfigurationValue");
130 130 int statusConfig = libusb_set_configuration(handle, configuration);
131 131 if (statusConfig != LIBUSB_SUCCESS) {
132 132 perror("libusb_set_configuration");
133 133 return;
134 134 }
135   -
  135 +*/
136 136  
137 137 // 4.2 configuration du périph usb
138 138 struct libusb_config_descriptor *config;
... ... @@ -146,17 +146,40 @@ void displayDeviceEndpoints(libusb_device_handle* handle) {
146 146 config->bLength, config->bDescriptorType, config->bNumInterfaces);
147 147  
148 148  
149   - // itération de l'interface
150   - for (int indexInterface = 0; indexInterface < config->bNumInterfaces;
151   - indexInterface++) {
152   - // struct libusb_interface * interface =
153   - // &config->interface[indexInterface];
154   - printf("^%d", indexInterface);
155   - printf("Alt%d", config->interface[indexInterface].num_altsetting);
  149 + // itération de l'interface
  150 + printf("Itération de l'interface\n");
  151 + for (int indexInterface = 0; indexInterface < config->bNumInterfaces; indexInterface++) {
  152 + printf("indexInterface=%d\n", indexInterface);
  153 + printf("Altsetting=%d\n", config->interface[indexInterface].num_altsetting);
  154 +
  155 + const struct libusb_interface * interface = &config->interface[indexInterface];
  156 +
  157 +
  158 + //if 1 setting (or more)
  159 + if(interface->num_altsetting != 0) {
  160 + const struct libusb_interface_descriptor * interface_desc = &interface->altsetting[0];
  161 +
  162 + printf("--bNumEndpoints=%d\n", interface_desc->bNumEndpoints);
  163 + printf("--bDescriptorType=%d\n", interface_desc->bDescriptorType);
  164 +
  165 + for(int indexEndpoints = 0; indexEndpoints < interface_desc->bNumEndpoints ; indexEndpoints++){
  166 + const struct libusb_endpoint_descriptor * endpoint_desc = &interface_desc->endpoint[indexEndpoints];
  167 + printf("---bDescriptorType=%d\n", endpoint_desc->bDescriptorType);
  168 + printf("---bEndpointAddress=%d\n", endpoint_desc->bEndpointAddress);
  169 +
  170 + if(endpoint_desc->extra != NULL)
  171 + printf("---extra: %s\n", endpoint_desc->extra);
  172 + if(endpoint_desc->bmAttributes == LIBUSB_TRANSFER_TYPE_INTERRUPT)//TODO AJOUT MASQUE ? (voir doc)
  173 + printf("---is of type INTERRUPT\n");
  174 +
  175 + }
  176 + }
  177 +
  178 +
156 179 }
157 180  
158 181 printf("\n");
159 182  
160 183 libusb_close(handle);
161 184  
162   -}
163 185 \ No newline at end of file
  186 +}
... ...
src/main.c
... ... @@ -34,7 +34,7 @@ int main(int argc, char *argv[]){
34 34 handle = libusb_open_device_with_vid_pid(context, vendor_id, product_id);
35 35 if(handle != NULL){
36 36 printf("Show endpoints of VID:%hu;PID:%hu\n", vendor_id, product_id);
37   - displayDeviceEndpoints(NULL);
  37 + displayDeviceEndpoints(handle);
38 38 }
39 39 else{
40 40 printf("Error while getting handle of VID:%hu;PID:%hu\n", vendor_id, product_id);
... ...