2 #include <sys/select.h>
10 int main (int argc, char **argv) {
16 fd = open(argv[1], O_RDWR);
17 log = fopen("bicat.log", "w");
23 FD_SET(STDIN_FILENO, &rfds);
29 retval = select(fd+1, &rfds, NULL, NULL, &tv);
34 if (FD_ISSET(fd, &rfds)) {
35 numread = read(fd, buf, 1);
36 if (numread==0) return;
37 if (numread<0) perror("read()");
38 //fprintf(log, "fpga->host: %d\n", buf[0]);
39 write(STDOUT_FILENO, buf, numread);
40 if ((buf[0] & (3<<6)) == 0) {
44 } else if (FD_ISSET(STDIN_FILENO, &rfds)) {
45 numread = read(STDIN_FILENO, buf, 1);
46 if (numread==0) return;
47 if (numread<0) perror("read()");
48 //fprintf(log, "host->fpga: %d\n", buf[0]);
49 write(fd, buf, numread);
50 } else if (FD_ISSET(fd, &rfds)) {
54 //fprintf(log, "sleep\n");