diff --git a/src/GetUsbInfos.c b/src/GetUsbInfos.c index f94fd8c..47da89c 100644 --- a/src/GetUsbInfos.c +++ b/src/GetUsbInfos.c @@ -45,36 +45,37 @@ int main() { perror("libusb_open"); 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); - } - } + /* + // 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);*/ - /* } -*/ + // 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; uint8_t desc_idx = 2; uint16_t langid = 16; unsigned char data[200]; - - for(desc_idx = 0; desc_idx < 5; desc_idx++){ - libusb_get_string_descriptor_ascii(handle, desc_idx, - data, MAXLEN_DESCRIPTOR_STRING); - - printf("Descriptor string : %s\n", data); -} + // TEST 16 + for (desc_idx = 0; desc_idx < 16; desc_idx++) { + int statusAscii = libusb_get_string_descriptor_ascii( + handle, desc_idx, data, MAXLEN_DESCRIPTOR_STRING); + if (statusAscii == -9) // TEST seems to be LIBUSB_ERROR + break; + printf("Descriptor string : %s ; %i\n", data, statusAscii); + } /* ... some ... code */ libusb_close(handle); } -- libgit2 0.21.2