Mercurial > hg > minimon
annotate playusb.c @ 8:66c77f9ba9b9
convert rgba -> rgb
author | Peter Meerwald <pmeerw@pmeerw.net> |
---|---|
date | Sat, 14 May 2011 21:05:59 +0200 |
parents | 71b9540bdd23 |
children |
rev | line source |
---|---|
0
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
1 /** |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
2 * based on usbreplay.c |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
3 * -- takes a list of jpeg filenames (on stdin) and sends them to the device index X |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
4 * |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
5 */ |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
6 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
7 #include <usb.h> |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
8 #include <stdlib.h> |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
9 #include <stdio.h> |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
10 #include <string.h> |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
11 #include <fcntl.h> |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
12 #include <assert.h> |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
13 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
14 struct usb_device *find_pvr(int index) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
15 struct usb_bus *bus; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
16 struct usb_device *dev; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
17 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
18 usb_init(); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
19 //usb_set_debug(999999); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
20 usb_find_busses(); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
21 usb_find_devices(); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
22 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
23 while(index >= 0) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
24 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
|
25 for (dev = bus->devices; dev; dev = dev->next) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
26 if (dev->descriptor.idVendor == 0x04e8 && |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
27 dev->descriptor.idProduct == 0x2028) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
28 if (index == 0) |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
29 return dev; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
30 --index; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
31 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
32 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
33 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
34 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
35 return NULL; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
36 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
37 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
38 usb_dev_handle *dev_open(struct usb_device *dev) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
39 int res = -1; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
40 char buf[256]; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
41 usb_dev_handle *udev; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
42 int numeps = 0; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
43 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
44 udev = usb_open(dev); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
45 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
46 setuid(getuid()); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
47 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
48 res = usb_set_configuration(udev, 1); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
49 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
50 usb_claim_interface(udev, 0); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
51 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
|
52 if (numeps == 0) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
53 fprintf(stderr, "** Did you forget to initialize the FX2 firmware with usbreplay -i?\n"); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
54 exit(1); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
55 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
56 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
57 strcpy(buf, "** no string **"); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
58 res = usb_get_string_simple(udev, dev->descriptor.iManufacturer, buf, sizeof(buf)); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
59 fprintf(stderr, "usb_get_string_simple => %d, %s\n", res, buf); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
60 |
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 int eplist[] = { 0x2, 0x81, 0x83 }; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
63 int eplength = sizeof(eplist)/sizeof(eplist[0]); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
64 int *endpoint = eplist; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
65 int i; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
66 for (i=0; i<eplength; i++) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
67 res = usb_resetep(udev, *endpoint); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
68 res = usb_clear_halt(udev, *endpoint); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
69 endpoint++; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
70 } |
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 return udev; |
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 |
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 void send_jpeg(FILE *f, usb_dev_handle *udev) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
78 fseek(f, 0, SEEK_END); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
79 int sz = ftell(f); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
80 fseek(f, 0, SEEK_SET); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
81 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
82 #define URBBUF_MAX 0x20000 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
83 char buf[URBBUF_MAX]; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
84 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
85 #define HDR_LEN 12 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
86 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
|
87 *(int *)(hdr+4) = sz; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
88 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
89 memcpy(buf, hdr, HDR_LEN); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
90 int off = HDR_LEN; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
91 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
92 //printf("new file of size %d\n", sz); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
93 while(!feof(f)) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
94 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
|
95 if (nr < 0) break; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
96 // pad |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
97 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
|
98 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
99 // write it out chunk by chunk |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
100 int timeout = 1000; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
101 int endpoint = 0x2; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
102 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
|
103 //printf("writing chunk\n"); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
104 assert(res >= 0); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
105 off = 0; // no header on subsequent chunks |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
106 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
107 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
108 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
109 int main(int argc, char *argv[]) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
110 int index = 0; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
111 if (argc > 1) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
112 if (sscanf(argv[1], "%d", &index) != 1) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
113 fprintf(stderr, "Usage: %s [device index] < filelist", argv[0]); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
114 return -1; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
115 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
116 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
117 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
118 struct usb_device *dev = find_pvr(index); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
119 assert (dev != NULL); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
120 |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
121 usb_dev_handle *udev = dev_open(dev); |
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 while(1) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
124 // for each file in the list |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
125 while(!feof(stdin)) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
126 char fn[256]; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
127 fgets(fn, 256, stdin); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
128 int nn = strlen(fn); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
129 if (nn > 0) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
130 if (fn[nn-1] == '\n') |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
131 fn[nn-1] = 0; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
132 FILE *f = fopen(fn, "r"); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
133 if (f == NULL) { |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
134 fprintf(stderr, "file %s not found\n", fn); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
135 return 2; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
136 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
137 send_jpeg(f, udev); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
138 fclose(f); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
139 } |
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 fseek(stdin, 0, SEEK_SET); |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
142 } |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
143 return 0; |
71b9540bdd23
starting, importing Woo's code and adding minimon
Peter Meerwald <pmeerw@pmeerw.net>
parents:
diff
changeset
|
144 } |