/* ==================================================================== * Task to read the fifo and output the data for the user. * * ==================================================================== */ #include #include #include #include #include #include #include static int done; static void terminate (int dummy) { done = 1; } int main (void) { int done = 0; int fifo; long interval, error; struct sigaction sigval; sigset_t mask; if ((fifo = open ("/dev/rtf0", O_RDONLY)) < 0) { printf ("Failed to open fifo /dev/rtf0\n"); exit (0); } /* * Set up for termination via control-C. */ sigval.sa_handler = terminate; sigval.sa_sigaction = NULL; sigemptyset (&mask); sigval.sa_mask = mask; sigval.sa_flags = 0; sigval.sa_restorer = NULL; sigaction (SIGINT, &sigval, NULL); /* * Try to read the FIFO and then print the results. * read will block until data is available. */ while (! done) { read (fifo, &interval, sizeof (interval)); read (fifo, &error, sizeof (error)); printf ("Interval = %ld and Error = %ld\n", interval, error); } }