From 3d1c65064bdb848ecb40dcf2fa60ecce3a9231a0 Mon Sep 17 00:00:00 2001 From: Axel CHEMIN Date: Thu, 12 Nov 2020 15:19:10 +0100 Subject: [PATCH] Affichage de l'existence des interfaces --- src/GetUsbInfos.c | 67 +++++++++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 22 deletions(-) diff --git a/src/GetUsbInfos.c b/src/GetUsbInfos.c index 2abccc1..43ddb13 100644 --- a/src/GetUsbInfos.c +++ b/src/GetUsbInfos.c @@ -46,21 +46,21 @@ int main() { exit(-1); } - // Si le méchant noyau est passé avant vous : - /*int interface = 0; // TEST : FONCTIONNE MAIS CORRESPOND A QUOI? - if (libusb_kernel_driver_active(handle, interface)) { - int statusKDriver = libusb_detach_kernel_driver(handle, interface); - if (statusKDriver != 0) { - perror("libusb_detach_kernel_driver"); - exit(-1); - } - }*/ - - /*// lectures des configs? - int configuration = 0; // valueof("bConfigurationValue"); - int statusConfig = libusb_set_configuration(handle, configuration); - if (statusConfig != 0) { - perror("libusb_set_configuration"); /*exit(-1);*/ + // Si le méchant noyau est passé avant vous : + /*int interface = 0; // TEST : FONCTIONNE MAIS CORRESPOND A QUOI? + if (libusb_kernel_driver_active(handle, interface)) { + int statusKDriver = libusb_detach_kernel_driver(handle, interface); + if (statusKDriver != 0) { + perror("libusb_detach_kernel_driver"); + exit(-1); + } + }*/ + + /*// lectures des configs? + int configuration = 0; // valueof("bConfigurationValue"); + int statusConfig = libusb_set_configuration(handle, configuration); + if (statusConfig != 0) { + perror("libusb_set_configuration"); /*exit(-1);*/ /* } */ int MAXLEN_DESCRIPTOR_STRING = 200; @@ -77,19 +77,42 @@ int main() { printf("Descriptor string : %s ; %i\n", data, statusAscii); } - - //4.2 configuration du périph usb - struct libusb_config_descriptor * config; - int statusFetchConfig = libusb_get_active_config_descriptor(device, &config); + // 4.2 configuration du périph usb + struct libusb_config_descriptor *config; + int statusFetchConfig = + libusb_get_active_config_descriptor(device, &config); if (statusFetchConfig != 0) { perror("libusb_get_active_config_descriptor"); - //exit(-1); + // exit(-1); } printf("Config.bConfigurationValue : %d\n", config->bConfigurationValue); - printf("Config/ bLength:%d;bDescriptorType:%d;bNumInterfaces:%d\n", - config->bLength, config->bDescriptorType, config->bNumInterfaces); + printf("Config/ bLength:%d;bDescriptorType:%d;bNumInterfaces:%d", + config->bLength, config->bDescriptorType, config->bNumInterfaces); + + // itération de l'interface + + for (int indexInterface = 0; indexInterface < config->bNumInterfaces; + indexInterface++) { + // struct libusb_interface * interface = + // &config->interface[indexInterface]; + printf("^%d", indexInterface); + printf("Alt%d", config->interface[indexInterface].num_altsetting); + } + + printf("\n"); + /* + //appropriation de l'interface + + int statusClaimInterface=libusb_claim_interface(handle,interface); + if(status!=0){ perror("libusb_claim_interface"); exit(-1); } + /* ... some code ... */ + /* + + status=libusb_release_interface(handle,interface); + if(status!=0){ perror("libusb_release_interface"); exit(-1); } + */ /* ... some ... code */ libusb_close(handle); -- libgit2 0.21.2