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 */
10 #include "alphamote.h"
12 void print_bytes(char *bytes
, int len
) {
16 for (i
=0; i
<len
; i
++) {
17 printf("%02x ", (int)((unsigned char)bytes
[i
]));
18 if ((i
+ 1) % 10 == 0) {
20 printf("%02d: ", (i
/ 10) + 1);
27 void print_interpretation(char *buf
) {
28 // byte 35 and 36 are 100 * fstop
29 long fstop_scaled
= buf
[35] & 255;
30 fstop_scaled
|= (buf
[36] << 8);
32 fstop
= (fstop_scaled
/ 100.0);
33 printf("f%2.1f\n", fstop
);
37 // byte 93 and 94 are 1/time
38 printf("using 1/s\n");
39 long time
= (buf
[93] & 255) | (buf
[94] << 8);
40 printf("1/%ds\n", time
);
43 // byte 95 and 96 are 10*s (or bulb if 0)
44 long time
= (buf
[95] & 255) | (buf
[96] << 8);
47 time_s
= (time
/ 10.0);
48 printf("%2.1fs\n", time_s
);
54 // byte 41 identifies the focusing type
58 else if (buf
[41] == 4) {
61 else if (buf
[41] == 5) {
64 else if (buf
[41] == 2) {
68 // bytes 71/72 identify drive/bracketing type
70 printf("Singleshot\n");
72 else if (buf
[71] == 2) {
73 printf("Continuous drive (high)\n");
75 else if (buf
[71] == 0x12) {
76 printf("Continuous drive (low)\n");
78 else if (buf
[71] == 4) {
79 printf("Timer (10s)\n");
81 else if (buf
[71] == 5) {
82 printf("Timer (2s)\n");
84 else if (buf
[71] == '\x37' && buf
[72] == '\x83') {
85 printf("Continuous bracketing (0.3 f-stops, 3 pictures)\n");
87 else if (buf
[71] == '\x37' && buf
[72] == '\x85') {
88 printf("Continuous bracketing (0.3 f-stops, 5 pictures)\n");
90 else if (buf
[71] == '\x57' && buf
[72] == '\x83') {
91 printf("Continuous bracketing (0.5 f-stops, 3 pictures)\n");
93 else if (buf
[71] == '\x57' && buf
[72] == '\x85') {
94 printf("Continuous bracketing (0.5 f-stops, 5 pictures)\n");
96 else if (buf
[71] == '\x77' && buf
[72] == '\x83') {
97 printf("Continuous bracketing (0.7 f-stops, 3 pictures)\n");
99 else if (buf
[71] == '\x77' && buf
[72] == '\x85') {
100 printf("Continuous bracketing (0.7 f-stops, 5 pictures)\n");
102 else if (buf
[71] == '\x47') {
103 printf("Continuous bracketing (2 f-stops, 3 pictures)\n");
105 else if (buf
[71] == '\x29') {
106 printf("DR-+ bracketing (high)\n");
108 else if (buf
[71] == '\x19') {
109 printf("DR-+ bracketing (low)\n");
111 else if (buf
[71] == '\x36' && buf
[72] == '\x83') {
112 printf("Single bracketing (0.3 f-stops, 3 pictures)\n");
114 else if (buf
[71] == '\x36' && buf
[72] == '\x85') {
115 printf("Single bracketing (0.3 f-stops, 5 pictures)\n");
117 else if (buf
[71] == '\x56' && buf
[72] == '\x83') {
118 printf("Single bracketing (0.5 f-stops, 3 pictures)\n");
120 else if (buf
[71] == '\x56' && buf
[72] == '\x85') {
121 printf("Single bracketing (0.5 f-stops, 5 pictures)\n");
123 else if (buf
[71] == '\x76' && buf
[72] == '\x83') {
124 printf("Single bracketing (0.7 f-stops, 3 pictures)\n");
126 else if (buf
[71] == '\x76' && buf
[72] == '\x85') {
127 printf("Single bracketing (0.7 f-stops, 5 pictures)\n");
129 else if (buf
[71] == '\x46') {
130 printf("Single bracketing (2 f-stops, 3 pictures)\n");
132 else if (buf
[71] == '\x28') {
133 printf("WB bracketing (high)\n");
135 else if (buf
[71] == '\x18') {
136 printf("WB bracketing (low)\n");
138 else if (buf
[71] == '\x0a') {
139 printf("Remote control\n");
143 int main(int argc
, char **argv
) {
149 ret
= usb_get_descriptor(devh
, 0x0000001, 0x0000000, buf
, 0x0000012);
151 ret
= usb_get_descriptor(devh
, 0x0000002, 0x0000000, buf
, 0x0000009);
153 ret
= usb_get_descriptor(devh
, 0x0000002, 0x0000000, buf
, 0x0000027);
155 ret
= usb_release_interface(devh
, 0);
156 if (ret
!= 0) printf("failed to release interface before set_configuration: %d\n", ret
);
157 ret
= usb_set_configuration(devh
, 0x0000001);
158 ret
= usb_claim_interface(devh
, 0);
159 if (ret
!= 0) printf("claim after set_configuration failed with error %d\n", ret
);
160 ret
= usb_set_altinterface(devh
, 0);
162 // get info (bulk read 62)
164 memcpy(buf
, "\x0c\x00\x00\x00\x01\x00\x08\x92\x0f\x00\x00\x00", 0x000000c);
165 ret
= usb_bulk_write(devh
, 0x00000001, buf
, 0x000000c, 1000);
167 ret
= usb_bulk_read(devh
, 0x00000082, buf
, 0x0000200, 1030);
169 print_interpretation(buf
);
171 print_bytes(buf
, ret
);
173 ret
= usb_bulk_read(devh
, 0x00000082, buf
, 0x0000200, 1030);
174 ret
= usb_release_interface(devh
, 0);
176 ret
= usb_close(devh
);