quick shell script hack for tethered shooting with qiv
[alphamote.git] / aperture_dec.c
blob9e56f942b294be2e3cd1695a10c87d64796203b0
1 /* This file is generated with usbsnoop2libusb.pl from a usbsnoop log file. */
2 /* Latest version of the script should be in http://iki.fi/lindi/usb/usbsnoop2libusb.pl */
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
6 #include <assert.h>
7 #include <signal.h>
8 #include <ctype.h>
9 #include <usb.h>
10 #include "alphamote.h"
12 int main(int argc, char **argv) {
13 int ret;
14 char buf[65535];
16 init_usb();
18 ret = usb_get_descriptor(devh, 0x0000001, 0x0000000, buf, 0x0000012);
19 usleep(4*1000);
20 ret = usb_get_descriptor(devh, 0x0000002, 0x0000000, buf, 0x0000009);
21 usleep(3*1000);
22 ret = usb_get_descriptor(devh, 0x0000002, 0x0000000, buf, 0x0000027);
23 usleep(4*1000);
24 ret = usb_release_interface(devh, 0);
25 if (ret != 0) printf("failed to release interface before set_configuration: %d\n", ret);
26 ret = usb_set_configuration(devh, 0x0000001);
27 ret = usb_claim_interface(devh, 0);
28 if (ret != 0) printf("claim after set_configuration failed with error %d\n", ret);
29 ret = usb_set_altinterface(devh, 0);
31 // 9207: open up aperture
32 usleep(6*1000);
33 memcpy(buf, "\x10\x00\x00\x00\x01\x00\x07\x92\x78\x00\x00\x00\x07\x50\x00\x00", 0x0000010);
34 ret = usb_bulk_write(devh, 0x00000001, buf, 0x0000010, 1000);
35 usleep(4*1000);
36 memcpy(buf, "\x0d\x00\x00\x00\x02\x00\x07\x92\x78\x00\x00\x00\xff", 0x000000d);
37 ret = usb_bulk_write(devh, 0x00000001, buf, 0x000000d, 1000);
38 ret = usb_release_interface(devh, 0);
39 assert(ret == 0);
40 ret = usb_close(devh);
41 assert(ret == 0);
42 return 0;