Commit c8f6b1784566c8291e1257ef660cff33042aa706

Authored by achemin1
1 parent b208acc5

Affichage valeur de la configuration active

Showing 1 changed file with 19 additions and 4 deletions   Show diff stats
src/GetUsbInfos.c
... ... @@ -45,18 +45,18 @@ int main() {
45 45 perror("libusb_open");
46 46 exit(-1);
47 47 }
48   - /*
  48 +
49 49 // Si le méchant noyau est passé avant vous :
50   - int interface = 0; // TEST : FONCTIONNE MAIS CORRESPOND A QUOI?
  50 + /*int interface = 0; // TEST : FONCTIONNE MAIS CORRESPOND A QUOI?
51 51 if (libusb_kernel_driver_active(handle, interface)) {
52 52 int statusKDriver = libusb_detach_kernel_driver(handle, interface);
53 53 if (statusKDriver != 0) {
54 54 perror("libusb_detach_kernel_driver");
55 55 exit(-1);
56 56 }
57   - }
  57 + }*/
58 58  
59   - // lectures des configs?
  59 + /*// lectures des configs?
60 60 int configuration = 0; // valueof("bConfigurationValue");
61 61 int statusConfig = libusb_set_configuration(handle, configuration);
62 62 if (statusConfig != 0) {
... ... @@ -76,6 +76,21 @@ int main() {
76 76 break;
77 77 printf("Descriptor string : %s ; %i\n", data, statusAscii);
78 78 }
  79 +
  80 +
  81 + //4.2 configuration du périph usb
  82 + struct libusb_config_descriptor * config;
  83 + int statusFetchConfig = libusb_get_active_config_descriptor(device, &config);
  84 + if (statusFetchConfig != 0) {
  85 + perror("libusb_get_active_config_descriptor");
  86 + //exit(-1);
  87 + }
  88 + printf("Config.bConfigurationValue : %d\n", config->bConfigurationValue);
  89 + printf("Config/ bLength:%d;bDescriptorType:%d;bNumInterfaces:%d\n",
  90 + config->bLength, config->bDescriptorType, config->bNumInterfaces);
  91 +
  92 +
  93 +
79 94 /* ... some ... code */
80 95 libusb_close(handle);
81 96 }
... ...