chiark / gitweb /
fix up silly compiler warning and improve readability a bit
[trains.git] / parport / readlots.c
1 /**/
2
3 #include <assert.h>
4 #include <stdlib.h>
5 #include <unistd.h>
6 #include <stdio.h>
7
8 #include <sys/time.h>
9 #include <sys/ioctl.h>
10 #include <linux/ppdev.h>
11
12 #include "lib.h"
13
14 static void badusage(void) {
15   fprintf(stderr,
16           "usage: readlots <&parport\n"
17           "options: none\n");
18 }         
19
20 int main(int argc, const char *const *argv) {
21   unsigned char v;
22   struct timeval tv;
23   int r;
24
25   argc--;
26   argv++;
27   if (argc>=1) badusage();
28
29   for (;;) {
30     r= gettimeofday(&tv,0); assert(!r);
31     doioctl(PPRSTATUS, &v, 0);
32     printf("%10lu.%06lu %02x\n", tv.tv_sec, tv.tv_usec, v);
33   }
34 }