Commit fef0523768663e28e72fddcf80a2c7a55c0cefae
1 parent
533260c1
ajout condition pour mieux afficher les string
Showing
1 changed file
with
25 additions
and
24 deletions
Show diff stats
src/GetUsbInfos.c
@@ -45,36 +45,37 @@ int main() { | @@ -45,36 +45,37 @@ int main() { | ||
45 | perror("libusb_open"); | 45 | perror("libusb_open"); |
46 | exit(-1); | 46 | exit(-1); |
47 | } | 47 | } |
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 | - } | 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 | 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 | - /* } | ||
65 | -*/ | 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 | + /* } | ||
65 | + */ | ||
66 | int MAXLEN_DESCRIPTOR_STRING = 200; | 66 | int MAXLEN_DESCRIPTOR_STRING = 200; |
67 | uint8_t desc_idx = 2; | 67 | uint8_t desc_idx = 2; |
68 | uint16_t langid = 16; | 68 | uint16_t langid = 16; |
69 | unsigned char data[200]; | 69 | unsigned char data[200]; |
70 | 70 | ||
71 | - | ||
72 | - for(desc_idx = 0; desc_idx < 5; desc_idx++){ | ||
73 | - libusb_get_string_descriptor_ascii(handle, desc_idx, | ||
74 | - data, MAXLEN_DESCRIPTOR_STRING); | ||
75 | - | ||
76 | - printf("Descriptor string : %s\n", data); | ||
77 | -} | 71 | + // TEST 16 |
72 | + for (desc_idx = 0; desc_idx < 16; desc_idx++) { | ||
73 | + int statusAscii = libusb_get_string_descriptor_ascii( | ||
74 | + handle, desc_idx, data, MAXLEN_DESCRIPTOR_STRING); | ||
75 | + if (statusAscii == -9) // TEST seems to be LIBUSB_ERROR | ||
76 | + break; | ||
77 | + printf("Descriptor string : %s ; %i\n", data, statusAscii); | ||
78 | + } | ||
78 | /* ... some ... code */ | 79 | /* ... some ... code */ |
79 | libusb_close(handle); | 80 | libusb_close(handle); |
80 | } | 81 | } |