Skip to content

Instantly share code, notes, and snippets.

@innateessence
Last active July 24, 2018 23:36
Show Gist options
  • Save innateessence/43b7a757deebab23628eb783e60b6571 to your computer and use it in GitHub Desktop.
Save innateessence/43b7a757deebab23628eb783e60b6571 to your computer and use it in GitHub Desktop.
usb_reset.c
// stolen
#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 {
val = usb_reset(junk);
printf( "reset %p %d (%s)\n", dev, val, buf );
}
usb_close(junk);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment