]> git.rkrishnan.org Git - dttsp.git/blob - jDttSP/metermon.c
1bd875b27ec6da16c580ac8061c2e64f52fc0c4e
[dttsp.git] / jDttSP / metermon.c
1 /* metermon.c */
2
3 #include <chan.h>
4
5 #define METERPATH "./IPC/SDR-1000-0-meter.chan"
6 #define METERMULT (24)
7 #define SLEEP (500000)
8
9 jmp_buf here;
10
11 void
12 onsig(int sig) {
13   signal(SIGHUP, SIG_IGN);
14   signal(SIGINT, SIG_IGN);
15   signal(SIGQUIT, SIG_IGN);
16   longjmp(here, TRUE);
17 }
18
19 int
20 main(int argc, char **argv) {
21   Chan ch = 0;
22   int i = 0;
23   REAL val = 0.0;
24
25   signal(SIGHUP, onsig);
26   signal(SIGINT, onsig);
27   signal(SIGQUIT, onsig);
28
29   if (!(ch = openChan(METERPATH, METERMULT * sizeof(REAL))))
30     perror("openChan"), exit(1);
31
32   while (!setjmp(here)) {
33     if (getChan_nowait(ch, (char *) &val, sizeof(REAL))) {
34       printf("(%d)", i++);
35       do
36         printf(" %f", val);
37       while (getChan_nowait(ch, (char *) &val, sizeof(REAL)));
38       putchar('\n');
39     }
40     usleep(SLEEP);
41   }
42
43   closeChan(ch);
44 }