diff options
author | etobi <git@e-tobi.net> | 2013-09-03 09:48:38 +0200 |
---|---|---|
committer | etobi <git@e-tobi.net> | 2013-09-03 09:48:38 +0200 |
commit | 6e40287e2f39a80fc72bd8d0fbc1a8334d688c2d (patch) | |
tree | 024bef311226653bdd1da4fa588becf5098bcff7 /util/ttusb_dec_reset/ttusb_dec_reset.c | |
download | linux-dvb-apps-6e40287e2f39a80fc72bd8d0fbc1a8334d688c2d.tar.gz |
Imported Upstream version 1.1.0upstream/1.1.0
Diffstat (limited to 'util/ttusb_dec_reset/ttusb_dec_reset.c')
-rw-r--r-- | util/ttusb_dec_reset/ttusb_dec_reset.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/util/ttusb_dec_reset/ttusb_dec_reset.c b/util/ttusb_dec_reset/ttusb_dec_reset.c new file mode 100644 index 0000000..51ddfc7 --- /dev/null +++ b/util/ttusb_dec_reset/ttusb_dec_reset.c @@ -0,0 +1,53 @@ +#include <stdio.h> +#include <usb.h> + +void dec_reset(struct usb_device *dev) +{ + char message[] = {0xaa, 0x00, 0xf1, 0x01, 0x00}; + usb_dev_handle *handle = usb_open(dev); + + printf("Device found.\n"); + + if (handle) { + if (!usb_claim_interface(handle, 0)) { + int result; + printf("Reseting device.. "); + result = usb_bulk_write(handle, 3, message, + sizeof(message), 1000); + if (result >= 0) + printf("succeeded.\n"); + else + printf("failed. (Error code: %d)\n", result); + } else { + printf("Couldn't claim interface.\n"); + } + usb_close(handle); + } +} + +int main() +{ + struct usb_bus *busses; + struct usb_bus *bus; + + usb_init(); + usb_find_busses(); + usb_find_devices(); + + busses = usb_get_busses(); + + for (bus = busses; bus; bus = bus->next) { + struct usb_device *dev; + + for (dev = bus->devices; dev; dev = dev->next) { + if (dev->descriptor.idVendor == 0x0b48 && + (dev->descriptor.idProduct == 0x1006 || + dev->descriptor.idProduct == 0x1008 || + dev->descriptor.idProduct == 0x1009)) { + dec_reset(dev); + } + } + } + + return 0; +} |