Mercurial > hg > minimon
annotate minimon.c @ 9:c7af696b6221
fix
author | Peter Meerwald <pmeerw@pmeerw.net> |
---|---|
date | Sat, 14 May 2011 23:08:11 +0200 |
parents | bac8ed8d6eb9 |
children | 078dc69945ad |
rev | line source |
---|---|
0
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
1 #include <stdlib.h> |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
2 #include <stdio.h> |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
3 #include <string.h> |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
4 #include <fcntl.h> |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
5 #include <assert.h> |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
6 #include "usb.h" |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
7 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
8 static const char *progname = "minimon"; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
9 |
1 | 10 static int need_switch = 0; |
11 static int have_idx = -1; | |
12 | |
13 typedef struct { | |
14 int mass_id; | |
15 int custom_id; | |
16 const char *name; | |
17 int width; | |
18 int height; | |
19 } id_info_t; | |
20 | |
2
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
1
diff
changeset
|
21 // there are many more, |
1 | 22 static id_info_t ids[] = { |
2
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
1
diff
changeset
|
23 {0x2027, 0x2028, "SPF-107H", 1024, 600}, |
1 | 24 {0xffff, 0xffff, "SPF-75H", 800, 480}, |
2
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
1
diff
changeset
|
25 {0xffff, 0xffff, "SPF-83H", 800, 600}, |
1 | 26 {0xffff, 0xffff, "SPF-85H", 800, 600}, // 85P?? |
27 {0x2033, 0x2034, "SPF-87H", 800, 480}, | |
28 {0x2035, 0x2036, "SPF-107H", 1024, 600}, | |
29 {0, 0, } // end-of-list | |
30 }; | |
31 | |
32 static int in_list(int id, id_info_t *list) { | |
33 if (!list) | |
34 return 0; | |
35 | |
36 int idx = 0; | |
37 while (list->mass_id || list->custom_id) { | |
38 if (id == list->mass_id) { | |
39 // still in mass-storage mode, need to switch | |
40 need_switch = 1; | |
41 return idx; | |
42 } | |
43 else if (id == list->custom_id) { | |
44 need_switch = 0; | |
45 return idx; | |
46 } | |
47 idx++; | |
48 list++; | |
49 } | |
50 | |
51 return -1; | |
52 } | |
53 | |
54 static struct usb_device *find_dev() { | |
0
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
55 struct usb_bus *bus; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
56 struct usb_device *dev; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
57 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
58 usb_init(); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
59 usb_find_busses(); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
60 usb_find_devices(); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
61 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
62 for (bus = usb_busses; bus; bus = bus->next) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
63 for (dev = bus->devices; dev; dev = dev->next) { |
1 | 64 if (dev->descriptor.idVendor == 0x04e8) { |
65 // found a Samsung device, good | |
66 int idx = -1; | |
67 if ((idx = in_list(dev->descriptor.idProduct, ids)) >= 0) { | |
68 have_idx = idx; | |
69 return dev; | |
70 } | |
0
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
71 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
72 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
73 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
74 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
75 return NULL; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
76 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
77 |
1 | 78 static usb_dev_handle *dev_open(struct usb_device *dev) { |
0
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
79 int res = -1; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
80 usb_dev_handle *udev; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
81 int numeps = 0; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
82 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
83 udev = usb_open(dev); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
84 if (!udev) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
85 fprintf(stderr, "%s: failed to open device, exit.\n", progname); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
86 exit(EXIT_FAILURE); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
87 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
88 |
2
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
1
diff
changeset
|
89 // setuid(getuid()); |
0
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
90 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
91 res = usb_set_configuration(udev, 1); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
92 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
93 usb_claim_interface(udev, 0); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
94 numeps = dev->config[0].interface[0].altsetting[0].bNumEndpoints; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
95 if (numeps == 0) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
96 fprintf(stderr, "%s: no endpoints, exit.\n", progname); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
97 exit(EXIT_FAILURE); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
98 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
99 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
100 { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
101 int eplist[] = { 0x2, 0x81, 0x83 }; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
102 int eplength = sizeof(eplist)/sizeof(eplist[0]); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
103 int *endpoint = eplist; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
104 int i; |
1 | 105 for (i = 0; i < eplength; i++) { |
0
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
106 res = usb_resetep(udev, *endpoint); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
107 res = usb_clear_halt(udev, *endpoint); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
108 endpoint++; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
109 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
110 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
111 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
112 return udev; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
113 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
114 |
1 | 115 static void send_jpeg(FILE *f, usb_dev_handle *udev) { |
0
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
116 fseek(f, 0, SEEK_END); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
117 int sz = ftell(f); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
118 fseek(f, 0, SEEK_SET); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
119 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
120 #define URBBUF_MAX 0x20000 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
121 char buf[URBBUF_MAX]; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
122 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
123 #define HDR_LEN 12 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
124 char hdr[HDR_LEN] = {0xa5, 0x5a, 0x18, 0x04, 0xff, 0xff, 0xff, 0xff, 0x48, 0x00, 0x00, 0x00}; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
125 *(int *)(hdr+4) = sz; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
126 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
127 memcpy(buf, hdr, HDR_LEN); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
128 int off = HDR_LEN; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
129 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
130 while(!feof(f)) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
131 int nr = fread(buf+off, 1, URBBUF_MAX - off, f); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
132 if (nr < 0) break; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
133 // pad |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
134 memset(buf + off + nr, 0, URBBUF_MAX - off - nr); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
135 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
136 // write it out chunk by chunk |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
137 int timeout = 1000; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
138 int endpoint = 0x2; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
139 int res = usb_bulk_write(udev, endpoint, buf, URBBUF_MAX, timeout); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
140 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
141 assert(res >= 0); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
142 off = 0; // no header on subsequent chunks |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
143 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
144 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
145 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
146 int main(int argc, char *argv[]) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
147 if (argc != 2) { |
1 | 148 fprintf(stderr, "Usage: %s <.jpg file>\n", progname); |
0
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
149 return EXIT_FAILURE; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
150 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
151 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
152 struct usb_device *dev = find_dev(index); |
1 | 153 if (!dev) { |
154 fprintf(stderr, "%s: no photo frame device found, exit.\n", progname); | |
155 exit(EXIT_FAILURE); | |
156 } | |
157 | |
158 if (need_switch) { | |
159 fprintf(stderr, "%s: found %s, trying to switch to custom product mode...\n", | |
160 ids[have_idx].name, progname); | |
161 | |
162 usb_dev_handle *udev; | |
163 | |
164 udev = usb_open(dev); | |
165 if (!udev) { | |
166 fprintf(stderr, "%s: failed to open device, exit.\n", progname); | |
167 exit(EXIT_FAILURE); | |
168 } | |
169 | |
170 char buf[254]; | |
171 memset(buf, 0, 254); | |
172 | |
173 int res = usb_control_msg(udev, USB_TYPE_STANDARD | USB_ENDPOINT_IN, USB_REQ_GET_DESCRIPTOR, | |
174 0xfe, 0xfe, buf, 0xfe, 1000); | |
175 fprintf(stderr, "%s: usb_control_msg() = %d\n", progname, res); | |
176 | |
177 usb_close(udev); | |
2
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
1
diff
changeset
|
178 usleep(500000); |
1 | 179 } |
180 | |
181 dev = find_dev(index); | |
182 if (!dev || need_switch) { | |
183 fprintf(stderr, "%s: no photo frame device found, exit.\n", progname); | |
184 exit(EXIT_FAILURE); | |
185 } | |
186 | |
187 fprintf(stderr, "%s: found %s (%d x %d)\n", | |
188 progname, ids[have_idx].name, ids[have_idx].width, ids[have_idx].height); | |
0
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
189 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
190 usb_dev_handle *udev = dev_open(dev); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
191 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
192 FILE *f = fopen(argv[1], "rb"); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
193 if (f == NULL) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
194 fprintf(stderr, "%s: failed to open file '%s', exit.\n", progname, argv[1]); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
195 exit(EXIT_FAILURE); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
196 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
197 send_jpeg(f, udev); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
198 fclose(f); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
199 |
2
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
1
diff
changeset
|
200 while (1) { |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
1
diff
changeset
|
201 char buf[2]; |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
1
diff
changeset
|
202 int res = usb_control_msg(udev, USB_TYPE_VENDOR | USB_ENDPOINT_IN, USB_REQ_GET_DESCRIPTOR, |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
1
diff
changeset
|
203 0x0, 0x0, buf, 0x2, 1000); |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
1
diff
changeset
|
204 fprintf(stderr, "%s: usb_control_msg() = %d\n", progname, res); |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
1
diff
changeset
|
205 |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
1
diff
changeset
|
206 usleep(500000); |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
1
diff
changeset
|
207 } |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
1
diff
changeset
|
208 |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
1
diff
changeset
|
209 usb_close(udev); |
bac8ed8d6eb9
add jpeg coding and test stuff
Peter Meerwald <pmeerw@pmeerw.net>
parents:
1
diff
changeset
|
210 |
0
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
211 return EXIT_SUCCESS; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
212 } |