Commit 3d1c65064bdb848ecb40dcf2fa60ecce3a9231a0

Authored by achemin1
1 parent c8f6b178

Affichage de l'existence des interfaces

Showing 1 changed file with 45 additions and 22 deletions   Show diff stats
src/GetUsbInfos.c
... ... @@ -46,21 +46,21 @@ int main() {
46 46 exit(-1);
47 47 }
48 48  
49   - // Si le méchant noyau est passé avant vous :
50   - /*int interface = 0; // TEST : FONCTIONNE MAIS CORRESPOND A QUOI?
51   - if (libusb_kernel_driver_active(handle, interface)) {
52   - int statusKDriver = libusb_detach_kernel_driver(handle, interface);
53   - if (statusKDriver != 0) {
54   - perror("libusb_detach_kernel_driver");
55   - exit(-1);
56   - }
57   - }*/
58   -
59   - /*// lectures des configs?
60   - int configuration = 0; // valueof("bConfigurationValue");
61   - int statusConfig = libusb_set_configuration(handle, configuration);
62   - if (statusConfig != 0) {
63   - perror("libusb_set_configuration"); /*exit(-1);*/
  49 + // Si le méchant noyau est passé avant vous :
  50 + /*int interface = 0; // TEST : FONCTIONNE MAIS CORRESPOND A QUOI?
  51 + if (libusb_kernel_driver_active(handle, interface)) {
  52 + int statusKDriver = libusb_detach_kernel_driver(handle, interface);
  53 + if (statusKDriver != 0) {
  54 + perror("libusb_detach_kernel_driver");
  55 + exit(-1);
  56 + }
  57 + }*/
  58 +
  59 + /*// lectures des configs?
  60 + int configuration = 0; // valueof("bConfigurationValue");
  61 + int statusConfig = libusb_set_configuration(handle, configuration);
  62 + if (statusConfig != 0) {
  63 + perror("libusb_set_configuration"); /*exit(-1);*/
64 64 /* }
65 65 */
66 66 int MAXLEN_DESCRIPTOR_STRING = 200;
... ... @@ -77,19 +77,42 @@ int main() {
77 77 printf("Descriptor string : %s ; %i\n", data, statusAscii);
78 78 }
79 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);
  80 + // 4.2 configuration du périph usb
  81 + struct libusb_config_descriptor *config;
  82 + int statusFetchConfig =
  83 + libusb_get_active_config_descriptor(device, &config);
84 84 if (statusFetchConfig != 0) {
85 85 perror("libusb_get_active_config_descriptor");
86   - //exit(-1);
  86 + // exit(-1);
87 87 }
88 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);
  89 + printf("Config/ bLength:%d;bDescriptorType:%d;bNumInterfaces:%d",
  90 + config->bLength, config->bDescriptorType, config->bNumInterfaces);
  91 +
  92 + // itération de l'interface
  93 +
  94 + for (int indexInterface = 0; indexInterface < config->bNumInterfaces;
  95 + indexInterface++) {
  96 + // struct libusb_interface * interface =
  97 + // &config->interface[indexInterface];
  98 + printf("^%d", indexInterface);
  99 + printf("Alt%d", config->interface[indexInterface].num_altsetting);
  100 + }
  101 +
  102 + printf("\n");
  103 + /*
  104 + //appropriation de l'interface
  105 +
  106 + int statusClaimInterface=libusb_claim_interface(handle,interface);
  107 + if(status!=0){ perror("libusb_claim_interface"); exit(-1); }
  108 + /* ... some code ... */
  109 + /*
  110 +
91 111  
92 112  
  113 + status=libusb_release_interface(handle,interface);
  114 + if(status!=0){ perror("libusb_release_interface"); exit(-1); }
  115 + */
93 116  
94 117 /* ... some ... code */
95 118 libusb_close(handle);
... ...