ppsapitest.c (123303) | ppsapitest.c (126820) |
---|---|
1/*- 2 * Copyright (c) 1998-2003 Poul-Henning Kamp 3 * 4 * Please see src/share/examples/etc/bsd-style-copyright. 5 * 6 */ 7 8#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 1998-2003 Poul-Henning Kamp 3 * 4 * Please see src/share/examples/etc/bsd-style-copyright. 5 * 6 */ 7 8#include <sys/cdefs.h> |
9__FBSDID("$FreeBSD: head/tools/test/ppsapi/ppsapitest.c 123303 2003-12-08 20:49:40Z phk $"); | 9__FBSDID("$FreeBSD: head/tools/test/ppsapi/ppsapitest.c 126820 2004-03-10 20:30:19Z phk $"); |
10 11#include <stdio.h> 12#include <stdint.h> 13#include <stdlib.h> 14#include <unistd.h> 15#include <fcntl.h> 16#include <err.h> 17#include <sys/timepps.h> --- 8 unchanged lines hidden (view full) --- 26 if (uflag) 27 fflush(stdout); 28} 29 30int 31main(int argc, char **argv) 32{ 33 int fd; | 10 11#include <stdio.h> 12#include <stdint.h> 13#include <stdlib.h> 14#include <unistd.h> 15#include <fcntl.h> 16#include <err.h> 17#include <sys/timepps.h> --- 8 unchanged lines hidden (view full) --- 26 if (uflag) 27 fflush(stdout); 28} 29 30int 31main(int argc, char **argv) 32{ 33 int fd; |
34 FILE *fdo; |
|
34 pps_info_t pi; 35 pps_params_t pp; 36 pps_handle_t ph; 37 int i, mode; 38 u_int olda, oldc; 39 struct timespec to; | 35 pps_info_t pi; 36 pps_params_t pp; 37 pps_handle_t ph; 38 int i, mode; 39 u_int olda, oldc; 40 struct timespec to; |
41 char const *ofn; |
|
40 | 42 |
41 while ((i = getopt(argc, argv, "aAbBcCeuv")) != -1) { | 43 ofn = NULL; 44 while ((i = getopt(argc, argv, "aAbBcCeo:uv")) != -1) { |
42 switch (i) { 43 case 'a': aflag = 1; break; 44 case 'A': Aflag = 1; break; 45 case 'b': aflag = 1; cflag = 1; break; 46 case 'B': Aflag = 1; Cflag = 1; break; 47 case 'c': cflag = 1; break; 48 case 'C': Cflag = 1; break; 49 case 'e': eflag = 1; break; | 45 switch (i) { 46 case 'a': aflag = 1; break; 47 case 'A': Aflag = 1; break; 48 case 'b': aflag = 1; cflag = 1; break; 49 case 'B': Aflag = 1; Cflag = 1; break; 50 case 'c': cflag = 1; break; 51 case 'C': Cflag = 1; break; 52 case 'e': eflag = 1; break; |
53 case 'o': ofn = optarg; break; |
|
50 case 'u': uflag = 1; break; 51 case 'v': vflag = 1; break; 52 case '?': 53 default: 54 fprintf(stderr, 55 "Usage: ppsapitest [-aAcC] device\n"); 56 exit (1); 57 } 58 } | 54 case 'u': uflag = 1; break; 55 case 'v': vflag = 1; break; 56 case '?': 57 default: 58 fprintf(stderr, 59 "Usage: ppsapitest [-aAcC] device\n"); 60 exit (1); 61 } 62 } |
63 if (ofn != NULL) { 64 fdo = fopen(ofn, "w"); 65 if (fdo == NULL) 66 err(1, "Cannot open %s", ofn); 67 } else { 68 fdo = NULL; 69 } |
|
59 argc -= optind; 60 argv += optind; 61 if (argc > 0) { 62 fd = open(argv[0], O_RDONLY); 63 if (fd < 0) 64 err(1, argv[0]); 65 } else { 66 fd = 0; --- 91 unchanged lines hidden (view full) --- 158 if (oldc != pi.clear_sequence && Cflag) 159 ; 160 else if (olda != pi.assert_sequence && Aflag) 161 ; 162 else { 163 usleep(10000); 164 continue; 165 } | 70 argc -= optind; 71 argv += optind; 72 if (argc > 0) { 73 fd = open(argv[0], O_RDONLY); 74 if (fd < 0) 75 err(1, argv[0]); 76 } else { 77 fd = 0; --- 91 unchanged lines hidden (view full) --- 169 if (oldc != pi.clear_sequence && Cflag) 170 ; 171 else if (olda != pi.assert_sequence && Aflag) 172 ; 173 else { 174 usleep(10000); 175 continue; 176 } |
177 if (fdo != NULL) { 178 if (fwrite(&pi, sizeof pi, 1, fdo) != 1) 179 err(1, "Write error on %s", ofn); 180 if (uflag) 181 fflush(fdo); 182 } |
|
166 Chew(&pi.assert_timestamp, &pi.clear_timestamp, 167 pi.assert_sequence, pi.clear_sequence); 168 olda = pi.assert_sequence; 169 oldc = pi.clear_sequence; 170 } 171 return(0); 172} | 183 Chew(&pi.assert_timestamp, &pi.clear_timestamp, 184 pi.assert_sequence, pi.clear_sequence); 185 olda = pi.assert_sequence; 186 oldc = pi.clear_sequence; 187 } 188 return(0); 189} |