annotate testugen.c @ 71:553c061fda7c

Keep the newer GCC happy.
author darius@Inchoate
date Mon, 19 Jan 2009 22:54:19 +1030
parents d5a265299a4b
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
1 #include <sys/types.h>
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
2 #include <sys/ioctl.h>
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
3 #include <dev/usb/usb.h>
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
4 #include <sys/errno.h>
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
5 #include <sys/uio.h>
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
6 #include <unistd.h>
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
7 #include <fcntl.h>
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
8 #include <stdio.h>
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
9
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
10 int
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
11 main(int argc, char **argv) {
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
12 int endpt2fd, i, len;
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
13 char *endpt2name = "/dev/ugen0.2";
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
14 uint8_t data[256];
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
15
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
16 if ((endpt2fd = open(endpt2name, O_RDWR)) == -1) {
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
17 fprintf(stderr, "Unable to open %s: %s\n", endpt2name, strerror(errno));
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
18 exit(1);
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
19 }
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
20
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
21 i = 1;
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
22 if (ioctl(endpt2fd, USB_SET_SHORT_XFER, &i) == -1) {
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
23 fprintf(stderr, "Unable to set short xfer on end point 2: %s\n", strerror(errno));
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
24 exit(1);
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
25 }
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
26
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
27 while(1) {
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
28 len = read(endpt2fd, data, 256);
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
29 printf("len = %d\n", len);
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
30 if (len == 0) {
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
31 printf("EOF\n");
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
32 continue;
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
33 }
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
34 if (len == -1) {
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
35 printf("read error: %s\n", strerror(errno));
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
36 exit(1);
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
37 }
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
38
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
39 for (i = 0; i < len; i++)
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
40 printf("0x%02x ", data[i]);
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
41 printf("\n");
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
42 }
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
43 }
d5a265299a4b Test programs to talk to the hardware from a PC
darius
parents:
diff changeset
44