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 */
11 #include "alphamote.h"
13 void print_bytes(char *bytes
, int len
) {
16 for (i
=0; i
<len
; i
++) {
17 printf("%02x ", (int)((unsigned char)bytes
[i
]));
20 for (i
=0; i
<len
; i
++) {
21 printf("%c", isprint(bytes
[i
]) ? bytes
[i
] : '.');
28 int main(int argc
, char **argv
) {
31 char *filename
= "/tmp/foo.jpg";
33 // command line options
35 while ((c
= getopt(argc
, argv
, "o:")) != -1) {
45 printf("filename: %s", filename
);
51 memcpy(buf
, "\x10\x00\x00\x00\x01\x00\x08\x10\xfa\x06\x00\x00\x01\xc0\xff\xff", 0x0000010);
52 ret
= usb_bulk_write(devh
, 0x00000001, buf
, 0x0000010, 1000);
53 printf("5469 bulk write returned %d, bytes: ", ret
);
54 print_bytes(buf
, ret
);
57 // 5470 contains the filename
58 ret
= usb_bulk_read(devh
, 0x00000082, buf
, 0x0000200, 1030);
59 printf("5470 bulk read returned %d, bytes: ", ret
);
60 print_bytes(buf
, ret
);
63 ret
= usb_bulk_read(devh
, 0x00000082, buf
, 0x0000200, 1030);
64 printf("5471 bulk read returned %d, bytes: ", ret
);
65 print_bytes(buf
, ret
);
68 ret
= usb_interrupt_read(devh
, 0x00000083, buf
, 0x0000008, 1000);
69 printf("5472 interrupt read returned %d, bytes: ", ret
);
70 print_bytes(buf
, ret
);
73 memcpy(buf
, "\x10\x00\x00\x00\x01\x00\x09\x10\xfb\x06\x00\x00\x01\xc0\xff\xff", 0x0000010);
74 ret
= usb_bulk_write(devh
, 0x00000001, buf
, 0x0000010, 1000);
75 printf("5473 bulk write returned %d, bytes: ", ret
);
76 print_bytes(buf
, ret
);
80 out
= fopen("/tmp/foo.jpg", "w"); // TODO - error handling
81 // here, the actual image data starts (ignore 12 byte ptp headers)
82 ret
= usb_bulk_read(devh
, 0x00000082, buf
, 0x0000200, 4932);
84 for (j
= 12; j
< ret
; j
++) {
89 // something to read left
90 ret
= usb_bulk_read(devh
, 0x00000082, buf
, 0x0000200, 4932);
93 for (i
= 0; i
< ret
; i
++) {
98 ret
= usb_release_interface(devh
, 0);
100 ret
= usb_close(devh
);