#include #include #include // arduino ID vendor and product #define ID_VENDOR 0x2341 #define ID_PRODUCT 0x01 // gcc file.c -l usb-1.0 int main(){ // init libusb_context *context; int status = libusb_init(&context); if(status != 0){perror("libusb_init"); exit(-1);} // devices list libusb_device **devices; ssize_t devices_count = libusb_get_device_list(context, &devices); if(devices_count < 0){perror("libusb_get_device_list"); exit(-1);} for(int i=0; ibConfigurationValue; // detach kernel for(int j=0; jbNumInterfaces; j++){ int interface = config_desc->interface[j].altsetting[0].bInterfaceNumber; if(libusb_kernel_driver_active(handle, interface)){ status = libusb_detach_kernel_driver(handle, interface); if(status != 0){ perror("libusb_detach_kernel_driver"); exit(-1); } } } // use config status = libusb_set_configuration(handle, configuration); if(status != 0){ perror("libusb_set_configuration"); exit(-1); } // claim interfaces for(int j=0; jbNumInterfaces; j++){ struct libusb_interface_descriptor interface_desc = config_desc->interface[j].altsetting[0]; int interface = interface_desc.bInterfaceNumber; status = libusb_claim_interface(handle, interface); if(status != 0){ perror("libusb_claim_interface"); exit(-1); } // find endpoints for(int k=0; k