1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 |
| #include <libusb-1.0/libusb.h> | int main(int argc, char *argv[]) | { | //preamble | libusb_context* ctx = 0; | libusb_init((libusb_context**)&ctx); | | libusb_device_handle* dev_handle = libusb_open_device_with_vid_pid(ctx, 1, 2); | libusb_device* dev = libusb_get_device(dev_handle); | struct libusb_endpoint_descriptor endpoint = { | .bLength = 'R', | .bDescriptorType = 'S', | .bEndpointAddress = 'T', | .bmAttributes = 'U', | .wMaxPacketSize = 4, | .bInterval = 'V', | .bRefresh = 'W', | .bSynchAddress = 'X', | .extra = (unsigned char const*) "extra", | .extra_length = 4}; | struct libusb_interface_descriptor altsetting [] = { | (struct libusb_interface_descriptor) { | .bLength = 'I', | .bDescriptorType = 'J', | .bInterfaceNumber = 'K', | .bAlternateSetting = 'L', | .bNumEndpoints = 'M', | .bInterfaceClass = 'N', | .bInterfaceSubClass = 'O', | .bInterfaceProtocol = 'P', | .iInterface = 'Q', | .endpoint = &endpoint, | .extra = (unsigned char const*) "extra", | .extra_length = 4}, | (struct libusb_interface_descriptor) { | .bLength = 'Y', | .bDescriptorType = 'Z', | .bInterfaceNumber = 'A', | .bAlternateSetting = 'B', | .bNumEndpoints = 'C', | .bInterfaceClass = 'D', | .bInterfaceSubClass = 'E', | .bInterfaceProtocol = 'F', | .iInterface = 'G', | .endpoint = &endpoint, | .extra = (unsigned char const*) "extra", | .extra_length = 4}, | (struct libusb_interface_descriptor) { | .bLength = 'H', | .bDescriptorType = 'I', | .bInterfaceNumber = 'J', | .bAlternateSetting = 'K', | .bNumEndpoints = 'L', | .bInterfaceClass = 'M', | .bInterfaceSubClass = 'N', | .bInterfaceProtocol = 'O', | .iInterface = 'P', | .endpoint = &endpoint, | .extra = (unsigned char const*) "extra", | .extra_length = 4}, | (struct libusb_interface_descriptor) { | .bLength = 'Q', | .bDescriptorType = 'R', | .bInterfaceNumber = 'S', | .bAlternateSetting = 'T', | .bNumEndpoints = 'U', | .bInterfaceClass = 'V', | .bInterfaceSubClass = 'W', | .bInterfaceProtocol = 'X', | .iInterface = 'Y', | .endpoint = &endpoint, | .extra = (unsigned char const*) "extra", | .extra_length = 4}, | (struct libusb_interface_descriptor) {0}}; | struct libusb_interface interface = {.altsetting = altsetting, .num_altsetting = 3}; | struct libusb_config_descriptor config_descriptor = { | .bLength = 'B', | .bDescriptorType = 'C', | .wTotalLength = 4, | .bNumInterfaces = 'D', | .bConfigurationValue = 'E', | .iConfiguration = 'F', | .bmAttributes = 'G', | .MaxPower = 'H', | .interface = &interface, | .extra = (unsigned char const*) "extra", | .extra_length = 4}; | struct libusb_config_descriptor* config [] = { | &config_descriptor, | &config_descriptor, | &config_descriptor, | &config_descriptor, | 0}; | libusb_get_config_descriptor(dev, 'A', config); //target call | | //finalization | libusb_exit(ctx); | | return 0; | } |
|