3 Try to run this program to see what the PPS-API finds. You give it the
4 device as argument and you may have to modify the pp.mode = BLA assignment.
14 #include <sys/types.h>
16 #include <sys/timepps.h>
17 #include <sys/termios.h>
19 #define timespecsub(vvp, uvp) \
21 (vvp)->tv_sec -= (uvp)->tv_sec; \
22 (vvp)->tv_nsec -= (uvp)->tv_nsec; \
23 if ((vvp)->tv_nsec < 0) { \
25 (vvp)->tv_nsec += 1000000000; \
31 Chew(struct timespec *tsa, struct timespec *tsc, unsigned sa, unsigned sc)
36 printf("%d.%09d ", tsa->tv_sec, tsa->tv_nsec);
37 printf("%d.%09d ", tsc->tv_sec, tsc->tv_nsec);
38 printf("%u %u ", sa, sc);
42 printf("%.9f ", ts.tv_sec + ts.tv_nsec / 1e9);
48 main(int argc, char **argv)
60 argv[1] = "/dev/cuaa1";
62 fd = open(argv[1], O_RDONLY);
65 i = time_pps_create(fd, &ph);
67 err(1, "time_pps_create");
69 i = time_pps_getcap(ph, &mode);
71 err(1, "time_pps_getcap");
73 pp.mode = PPS_CAPTUREASSERT | PPS_ECHOASSERT;
74 pp.mode = PPS_CAPTUREBOTH;
75 /* pp.mode = PPS_CAPTUREASSERT; */
77 i = time_pps_setparams(ph, &pp);
79 err(1, "time_pps_setparams");
84 i = time_pps_fetch(ph, PPS_TSFMT_TSPEC, &pi, &to);
86 err(1, "time_pps_fetch");
87 if (olda == pi.assert_sequence &&
88 oldc == pi.clear_sequence) {
93 Chew(&pi.assert_timestamp, &pi.clear_timestamp,
94 pi.assert_sequence, pi.clear_sequence);
95 olda = pi.assert_sequence;
96 oldc = pi.clear_sequence;