static void wwvb_control( int unit, struct refclockstat *in_st, struct refclockstat *out_st, struct peer *peer ) { register struct wwvbunit *up; struct refclockproc *pp; pp = peer->procptr; up = pp->unitptr; if (!(pp->sloppyclockflag & CLK_FLAG1)) { if (!up->ppsapi_tried) return; up->ppsapi_tried = 0; if (!up->ppsapi_lit) return; peer->flags &= ~FLAG_PPS; peer->precision = PRECISION; time_pps_destroy(up->atom.handle); up->atom.handle = 0; up->ppsapi_lit = 0; return; } if (up->ppsapi_tried) return; /* * Light up the PPSAPI interface. */ up->ppsapi_tried = 1; if (refclock_ppsapi(pp->io.fd, &up->atom)) { up->ppsapi_lit = 1; return; } NLOG(NLOG_CLOCKINFO) msyslog(LOG_WARNING, "%s flag1 1 but PPSAPI fails", refnumtoa(&peer->srcadr)); }
/* * atom_start - initialize data for processing */ static bool atom_start( int unit, /* unit number (not used) */ struct peer *peer /* peer structure pointer */ ) { struct refclockproc *pp; struct ppsunit *up; char device[80]; /* * Allocate and initialize unit structure */ pp = peer->procptr; peer->precision = PRECISION; pp->clockdesc = DESCRIPTION; pp->stratum = STRATUM_UNSPEC; memcpy((char *)&pp->refid, REFID, REFIDLEN); peer->sstclktype = CTL_SST_TS_ATOM; up = emalloc(sizeof(struct ppsunit)); memset(up, 0, sizeof(struct ppsunit)); pp->unitptr = up; /* * Open PPS device. This can be any serial or parallel port and * not necessarily the port used for the associated radio. */ snprintf(device, sizeof(device), DEVICE, unit); up->fddev = tty_open(device, O_RDWR, 0777); if (up->fddev <= 0) { msyslog(LOG_ERR, "refclock_atom: %s: %m", device); return false; } /* * Light up the PPSAPI interface. */ return (refclock_ppsapi(up->fddev, &up->atom)); }