A script to reset USB dongle
Need to compile the following
resetusb.c- include <stdio.h>
- #include <usb.h>
- int main(void)
- {
- struct usb_bus *busses;
- usb_init();
- usb_find_busses();
- usb_find_devices();
- busses = usb_get_busses();
- struct usb_bus *bus;
- int c, i, a;
- /* ... */
- for (bus = busses; bus; bus = bus->next) {
- struct usb_device *dev;
- int val;
- usb_dev_handle *junk;
- for (dev = bus->devices; dev; dev = dev->next) {
- char buf[1024];
- junk = usb_open ( dev );
- usb_get_string_simple(junk,2,buf,1023);
- if ( junk == NULL ){
- printf("Can't open %p (%s)\n", dev, buf );
- } else {
- if ((dev->descriptor.idVendor == 0x12d1) && (dev->descriptor.idProduct == 0x1001)) {
- printf( "reset %p %d (%s) ", dev, val, buf );
- printf( "vendor %x ",dev->descriptor.idVendor);
- printf( "product %x\n",dev->descriptor.idProduct);
- val = usb_reset(junk);
- }
- else {
- printf( "leave alone %p %d (%s) ", dev, val, buf );
- printf( "vendor %x ",dev->descriptor.idVendor);
- printf( "product %x\n",dev->descriptor.idProduct);
- }
- }
- usb_close(junk);
- }
- }
- }
複製代碼 Ref: https://github.com/dirkholz/resetusb/blob/master/src/resetusb.c |