quick shell script hack for tethered shooting with qiv
[alphamote.git] / init.c
blobc5216789461290a0a209c50b1894c455234bf7b0
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 memcpy(buf, "\x10\x00\x00\x00\x01\x00\x02\x10\x00\x00\x00\x00\x01\x00\x00\x00", 0x0000010);
19 ret = usb_bulk_write(devh, 0x00000001, buf, 0x0000010, 1000);
20 usleep(4*1000);
21 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
22 if (buf[6] == 1) {
23 printf("initializing ...\n");
25 else {
26 printf("already initialized, no need to do it again\n");
27 exit(0);
29 usleep(5*1000);
30 memcpy(buf, "\x0c\x00\x00\x00\x01\x00\x01\x10\x01\x00\x00\x00", 0x000000c);
31 ret = usb_bulk_write(devh, 0x00000001, buf, 0x000000c, 1000);
32 usleep(1*1000);
33 ret = usb_interrupt_read(devh, 0x00000083, buf, 0x0000008, 1000);
34 usleep(4*1000);
35 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
36 usleep(3*1000);
37 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
38 usleep(5*1000);
39 memcpy(buf, "\x0c\x00\x00\x00\x01\x00\x04\x10\x02\x00\x00\x00", 0x000000c);
40 ret = usb_bulk_write(devh, 0x00000001, buf, 0x000000c, 1000);
41 usleep(4*1000);
42 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
43 usleep(4*1000);
44 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
45 memcpy(buf, "\x0c\x00\x00\x00\x01\x00\x03\x10\x03\x00\x00\x00", 0x000000c);
46 ret = usb_bulk_write(devh, 0x00000001, buf, 0x000000c, 1000);
47 usleep(4*1000);
48 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
49 memcpy(buf, "\x10\x00\x00\x00\x01\x00\x02\x10\x00\x00\x00\x00\x01\x00\x00\x00", 0x0000010);
50 ret = usb_bulk_write(devh, 0x00000001, buf, 0x0000010, 1000);
51 usleep(6*1000);
52 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
53 usleep(5*1000);
54 memcpy(buf, "\x0c\x00\x00\x00\x01\x00\x01\x10\x01\x00\x00\x00", 0x000000c);
55 ret = usb_bulk_write(devh, 0x00000001, buf, 0x000000c, 1000);
56 usleep(3*1000);
57 ret = usb_interrupt_read(devh, 0x00000083, buf, 0x0000008, 1000);
58 usleep(3*1000);
59 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
60 usleep(4*1000);
61 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
62 usleep(4*1000);
63 memcpy(buf, "\x0c\x00\x00\x00\x01\x00\x04\x10\x02\x00\x00\x00", 0x000000c);
64 ret = usb_bulk_write(devh, 0x00000001, buf, 0x000000c, 1000);
65 usleep(8*1000);
66 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
67 usleep(4*1000);
68 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
69 usleep(17*1000);
70 memcpy(buf, "\x18\x00\x00\x00\x01\x00\x01\x92\x03\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 0x0000018);
71 ret = usb_bulk_write(devh, 0x00000001, buf, 0x0000018, 1000);
72 usleep(10*1000);
73 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
74 usleep(9*1000);
75 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
76 usleep(10*1000);
77 memcpy(buf, "\x18\x00\x00\x00\x01\x00\x01\x92\x04\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 0x0000018);
78 ret = usb_bulk_write(devh, 0x00000001, buf, 0x0000018, 1000);
79 usleep(4*1000);
80 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
81 usleep(4*1000);
82 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
83 usleep(4*1000);
84 memcpy(buf, "\x0c\x00\x00\x00\x01\x00\x02\x92\x05\x00\x00\x00", 0x000000c);
85 ret = usb_bulk_write(devh, 0x00000001, buf, 0x000000c, 1000);
86 usleep(6*1000);
87 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
88 usleep(7*1000);
89 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
90 usleep(6*1000);
91 memcpy(buf, "\x18\x00\x00\x00\x01\x00\x01\x92\x06\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 0x0000018);
92 ret = usb_bulk_write(devh, 0x00000001, buf, 0x0000018, 1000);
93 usleep(4*1000);
94 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
95 ret = usb_bulk_read(devh, 0x00000082, buf, 0x0000200, 1030);
96 ret = usb_release_interface(devh, 0);
97 assert(ret == 0);
98 ret = usb_close(devh);
99 assert(ret == 0);
100 return 0;