本文整理汇总了C++中refclock_report函数的典型用法代码示例。如果您正苦于以下问题:C++ refclock_report函数的具体用法?C++ refclock_report怎么用?C++ refclock_report使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了refclock_report函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: as2201_poll
/*
* as2201_poll - called by the transmit procedure
*
* We go to great pains to avoid changing state here, since there may be
* more than one eavesdropper receiving the same timecode.
*/
static void
as2201_poll(
int unit,
struct peer *peer
)
{
struct refclockproc *pp;
/*
* Send a "\r*toc\r" to get things going. We go to great pains
* to avoid changing state, since there may be more than one
* eavesdropper watching the radio.
*/
pp = peer->procptr;
if (write(pp->io.fd, "\r*toc\r", 6) != 6) {
refclock_report(peer, CEVNT_FAULT);
} else {
pp->polls++;
if (!(pp->sloppyclockflag & CLK_FLAG2))
get_systime(&pp->lastrec);
}
if (pp->coderecv == pp->codeproc) {
refclock_report(peer, CEVNT_TIMEOUT);
return;
}
refclock_receive(peer);
}
示例2: dumbclock_poll
/*
* dumbclock_poll - called by the transmit procedure
*/
static void
dumbclock_poll(
int unit,
struct peer *peer
)
{
register struct dumbclock_unit *up;
struct refclockproc *pp;
char pollchar;
/*
* Time to poll the clock. The Chrono-log clock is supposed to
* respond to a 'T' by returning a timecode in the format(s)
* specified above. Ours does (can?) not, but this seems to be
* an installation-specific problem. This code is dyked out,
* but may be re-enabled if anyone ever finds a Chrono-log that
* actually listens to this command.
*/
#if 0
pp = peer->procptr;
up = pp->unitptr;
if (peer->reach == 0)
refclock_report(peer, CEVNT_TIMEOUT);
if (up->linect > 0)
pollchar = 'R';
else
pollchar = 'T';
if (write(pp->io.fd, &pollchar, 1) != 1)
refclock_report(peer, CEVNT_FAULT);
else
pp->polls++;
#endif
}
示例3: hpgps_poll
/*
* hpgps_poll - called by the transmit procedure
*/
static void
hpgps_poll(
int unit,
struct peer *peer
)
{
register struct hpgpsunit *up;
struct refclockproc *pp;
/*
* Time to poll the clock. The HP 58503A responds to a
* ":PTIME:TCODE?" by returning a timecode in the format specified
* above. If nothing is heard from the clock for two polls,
* declare a timeout and keep going.
*/
pp = peer->procptr;
up = (struct hpgpsunit *)pp->unitptr;
if (up->pollcnt == 0)
refclock_report(peer, CEVNT_TIMEOUT);
else
up->pollcnt--;
if (write(pp->io.fd, ":PTIME:TCODE?\r", 14) != 14) {
refclock_report(peer, CEVNT_FAULT);
}
else
pp->polls++;
}
示例4: fg_poll
/*
* fg_poll - called by the transmit procedure
*/
static void
fg_poll(
int unit,
struct peer *peer
)
{
struct refclockproc *pp;
pp = peer->procptr;
/*
* Time to poll the clock. The FG clock responds to a
* "<DLE>D<DLE><CR>" by returning a timecode in the format specified
* above. If nothing is heard from the clock for two polls,
* declare a timeout and keep going.
*/
if (write(pp->io.fd, fgdate, LENFG) != LENFG)
refclock_report(peer, CEVNT_FAULT);
else
pp->polls++;
/*
if (pp->coderecv == pp->codeproc) {
refclock_report(peer, CEVNT_TIMEOUT);
return;
}
*/
record_clock_stats(&peer->srcadr, pp->a_lastcode);
return;
}
示例5: atom_poll
/*
* atom_poll - called by the transmit procedure
*/
static void
atom_poll(
int unit, /* unit number (not used) */
struct peer *peer /* peer structure pointer */
)
{
struct refclockproc *pp;
/*
* Don't wiggle the clock until some other driver has numbered
* the seconds.
*/
if (sys_leap == LEAP_NOTINSYNC)
return;
pp = peer->procptr;
pp->polls++;
if (pp->codeproc == pp->coderecv) {
peer->flags &= ~FLAG_PPS;
refclock_report(peer, CEVNT_TIMEOUT);
return;
}
pp->lastref = pp->lastrec;
refclock_receive(peer);
}
示例6: fg_start
/*
* fg_start - open the device and initialize data for processing
*/
static int
fg_start(
int unit,
struct peer *peer
)
{
struct refclockproc *pp;
struct fgunit *up;
int fd;
char device[20];
/*
* Open device file for reading.
*/
snprintf(device, sizeof(device), DEVICE, unit);
DPRINTF(1, ("starting FG with device %s\n",device));
fd = refclock_open(device, SPEED232, LDISC_CLK);
if (fd <= 0)
return (0);
/*
* Allocate and initialize unit structure
*/
up = emalloc(sizeof(struct fgunit));
memset(up, 0, sizeof(struct fgunit));
pp = peer->procptr;
pp->unitptr = up;
pp->io.clock_recv = fg_receive;
pp->io.srcclock = peer;
pp->io.datalen = 0;
pp->io.fd = fd;
if (!io_addclock(&pp->io)) {
close(fd);
pp->io.fd = -1;
return 0;
}
/*
* Initialize miscellaneous variables
*/
peer->precision = PRECISION;
pp->clockdesc = DESCRIPTION;
memcpy(&pp->refid, REFID, 3);
up->pollnum = 0;
/*
* Setup dating station to use GPS receiver.
* GPS receiver should work before this operation.
*/
if(!fg_init(pp->io.fd))
refclock_report(peer, CEVNT_FAULT);
return (1);
}
示例7: gpsd_poll
static void
gpsd_poll(
int unit,
peerT * peer)
{
clockprocT * const pp = peer->procptr;
gpsd_unitT * const up = (gpsd_unitT *)pp->unitptr;
u_int tc_max;
++pp->polls;
/* find the dominant error */
tc_max = max(up->tc_btime, up->tc_bdate);
tc_max = max(tc_max, up->tc_breply);
if (pp->coderecv != pp->codeproc) {
/* all is well */
pp->lastref = pp->lastrec;
refclock_receive(peer);
} else {
/* not working properly, admit to it */
peer->flags &= ~FLAG_PPS;
peer->precision = PRECISION;
if (-1 == pp->io.fd) {
/* not connected to GPSD: clearly not working! */
refclock_report(peer, CEVNT_FAULT);
} else if (tc_max == up->tc_breply) {
refclock_report(peer, CEVNT_BADREPLY);
} else if (tc_max == up->tc_btime) {
refclock_report(peer, CEVNT_BADTIME);
} else if (tc_max == up->tc_bdate) {
refclock_report(peer, CEVNT_BADDATE);
} else {
refclock_report(peer, CEVNT_TIMEOUT);
}
}
if (pp->sloppyclockflag & CLK_FLAG4)
gpsd_clockstats(unit, peer);
/* clear tallies for next round */
up->tc_good = up->tc_btime = up->tc_bdate =
up->tc_breply = up->tc_recv = 0;
}
示例8: arb_poll
/*
* arb_poll - called by the transmit procedure
*/
static void
arb_poll(
int unit,
struct peer *peer
)
{
register struct arbunit *up;
struct refclockproc *pp;
/*
* Time to poll the clock. The Arbiter clock responds to a "B5"
* by returning a timecode in the format specified above.
* Transmission occurs once per second, unless turned off by a
* "B0". Note there is no checking on state, since this may not
* be the only customer reading the clock. Only one customer
* need poll the clock; all others just listen in.
*/
pp = peer->procptr;
up = pp->unitptr;
pp->polls++;
up->tcswitch = 0;
if (write(pp->io.fd, "TQ", 2) != 2)
refclock_report(peer, CEVNT_FAULT);
/*
* Process median filter samples. If none received, declare a
* timeout and keep going.
*/
if (pp->coderecv == pp->codeproc) {
refclock_report(peer, CEVNT_TIMEOUT);
return;
}
refclock_receive(peer);
record_clock_stats(&peer->srcadr, pp->a_lastcode);
#ifdef DEBUG
if (debug)
printf("arbiter: timecode %d %s\n",
pp->lencode, pp->a_lastcode);
#endif
}
示例9: shm_poll
/*
* shm_poll - called by the transmit procedure
*/
static void
shm_poll(
int unit,
struct peer *peer
)
{
struct refclockproc * const pp = peer->procptr;
struct shmunit * const up = pp->unitptr;
int major_error;
pp->polls++;
/* get dominant reason if we have no samples at all */
major_error = max(up->notready, up->bad);
major_error = max(major_error, up->clash);
/*
* Process median filter samples. If none received, see what
* happened, tell the core and keep going.
*/
if (pp->coderecv != pp->codeproc) {
/* have some samples, everything OK */
pp->lastref = pp->lastrec;
refclock_receive(peer);
} else if (NULL == up->shm) { /* is this possible at all? */
/* we're out of business without SHM access */
refclock_report(peer, CEVNT_FAULT);
} else if (major_error == up->clash) {
/* too many collisions is like a bad signal */
refclock_report(peer, CEVNT_PROP);
} else if (major_error == up->bad) {
/* too much stale/bad/garbled data */
refclock_report(peer, CEVNT_BADREPLY);
} else {
/* in any other case assume it's just a timeout */
refclock_report(peer, CEVNT_TIMEOUT);
}
/* shm_clockstats() clears the tallies, so it must be last... */
shm_clockstats(unit, peer);
}
示例10: pst_poll
/*
* pst_poll - called by the transmit procedure
*/
static void
pst_poll(
int unit,
struct peer *peer
)
{
register struct pstunit *up;
struct refclockproc *pp;
/*
* Time to poll the clock. The PSTI/Traconex clock responds to a
* "QTQDQMT" by returning a timecode in the format specified
* above. Note there is no checking on state, since this may not
* be the only customer reading the clock. Only one customer
* need poll the clock; all others just listen in. If the clock
* becomes unreachable, declare a timeout and keep going.
*/
pp = peer->procptr;
up = (struct pstunit *)pp->unitptr;
up->tcswitch = 0;
up->lastptr = pp->a_lastcode;
if (write(pp->io.fd, "QTQDQMT", 6) != 6)
refclock_report(peer, CEVNT_FAULT);
if (peer->burst > 0)
return;
if (pp->coderecv == pp->codeproc) {
refclock_report(peer, CEVNT_TIMEOUT);
return;
}
refclock_receive(peer);
record_clock_stats(&peer->srcadr, pp->a_lastcode);
#ifdef DEBUG
if (debug)
printf("pst: timecode %d %s\n", pp->lencode,
pp->a_lastcode);
#endif
peer->burst = MAXSTAGE;
pp->polls++;
}
示例11: refclock_receive
/*
* refclock_receive - simulate the receive and packet procedures
*
* This routine simulates the NTP receive and packet procedures for a
* reference clock. This provides a mechanism in which the ordinary NTP
* filter, selection and combining algorithms can be used to suppress
* misbehaving radios and to mitigate between them when more than one is
* available for backup.
*/
void
refclock_receive(
struct peer *peer /* peer structure pointer */
)
{
struct refclockproc *pp;
#ifdef DEBUG
if (debug)
printf("refclock_receive: at %lu %s\n",
current_time, ntoa(&peer->srcadr));
#endif
/*
* Do a little sanity dance and update the peer structure. Groom
* the median filter samples and give the data to the clock
* filter.
*/
peer->received++;
pp = peer->procptr;
peer->processed++;
peer->timereceived = current_time;
peer->leap = pp->leap;
if (peer->leap == LEAP_NOTINSYNC) {
refclock_report(peer, CEVNT_FAULT);
return;
}
if (!peer->reach)
report_event(EVNT_REACH, peer);
peer->reach |= 1;
peer->reftime = peer->org = pp->lastrec;
peer->rootdispersion = pp->disp + SQRT(pp->jitter);
get_systime(&peer->rec);
if (!refclock_sample(pp))
return;
clock_filter(peer, pp->offset, 0., pp->jitter);
clock_select();
record_peer_stats(&peer->srcadr, ctlpeerstatus(peer),
peer->offset, peer->delay, clock_phi * (current_time -
peer->epoch), SQRT(peer->jitter));
if (cal_enable && last_offset < MINDISPERSE) {
#ifdef KERNEL_PLL
if (peer != sys_peer || pll_status & STA_PPSTIME)
#else
if (peer != sys_peer)
#endif /* KERNEL_PLL */
pp->fudgetime1 -= pp->offset * FUDGEFAC;
else
pp->fudgetime1 -= pp->fudgetime1 * FUDGEFAC;
}
}
示例12: wwvb_timer
/*
* wwvb_timer - called once per second by the transmit procedure
*/
static void
wwvb_timer(
int unit,
struct peer *peer
)
{
register struct wwvbunit *up;
struct refclockproc *pp;
char pollchar; /* character sent to clock */
#ifdef DEBUG
l_fp now;
#endif
/*
* Time to poll the clock. The Spectracom clock responds to a
* 'T' by returning a timecode in the format(s) specified above.
* Note there is no checking on state, since this may not be the
* only customer reading the clock. Only one customer need poll
* the clock; all others just listen in.
*/
pp = peer->procptr;
up = pp->unitptr;
if (up->linect > 0)
pollchar = 'R';
else
pollchar = 'T';
if (write(pp->io.fd, &pollchar, 1) != 1)
refclock_report(peer, CEVNT_FAULT);
#ifdef DEBUG
get_systime(&now);
if (debug)
printf("%c poll at %s\n", pollchar, prettydate(&now));
#endif
#ifdef HAVE_PPSAPI
if (up->ppsapi_lit &&
refclock_pps(peer, &up->atom, pp->sloppyclockflag) > 0) {
up->pcount++,
peer->flags |= FLAG_PPS;
peer->precision = PPS_PRECISION;
}
#endif /* HAVE_PPSAPI */
}
示例13: atom_poll
/*
* atom_poll - called by the transmit procedure
*/
static void
atom_poll(
int unit, /* unit number (not used) */
struct peer *peer /* peer structure pointer */
)
{
struct ppsunit *up;
struct refclockproc *pp;
UNUSED_ARG(unit);
pp = peer->procptr;
up = (struct ppsunit *)pp->unitptr;
/*
* Don't wiggle the clock until some other driver has numbered
* the seconds.
*/
if (sys_leap == LEAP_NOTINSYNC) {
pp->codeproc = pp->coderecv; // xxx ??
up->pcount = up->scount = up->kcount = up->rcount = 0;
return;
}
pp->polls++;
mprintf_clock_stats(&peer->srcadr,
"%ld %d %d %d %d",
up->atom.sequence,
up->pcount, up->scount, up->kcount, up->rcount);
up->pcount = up->scount = up->kcount = up->rcount = 0;
if (pp->codeproc == pp->coderecv) {
peer->flags &= ~FLAG_PPS;
refclock_report(peer, CEVNT_TIMEOUT);
return;
}
pp->lastref = pp->lastrec;
refclock_receive(peer);
}
示例14: request_time
static void
request_time(
int unit,
struct peer *peer
)
{
struct refclockproc *pp = peer->procptr;
register struct arcunit *up = (struct arcunit *)pp->unitptr;
#ifdef DEBUG
if(debug) { printf("arc: unit %d: requesting time.\n", unit); }
#endif
if (!send_slow(up, pp->io.fd, "o\r")) {
#ifdef DEBUG
if (debug) {
printf("arc: unit %d: problem sending", unit);
}
#endif
pp->lencode = 0;
refclock_report(peer, CEVNT_FAULT);
return;
}
pp->polls++;
}
示例15: refclock_pps
/*
* refclock_pps - called once per second
*
* This routine is called once per second. It snatches the PPS
* timestamp from the kernel and saves the sign-extended fraction in
* a circular buffer for processing at the next poll event.
*/
int
refclock_pps(
struct peer *peer, /* peer structure pointer */
struct refclock_atom *ap, /* atom structure pointer */
int mode /* mode bits */
)
{
struct refclockproc *pp;
pps_info_t pps_info;
struct timespec timeout;
double dtemp;
/*
* We require the clock to be synchronized before setting the
* parameters. When the parameters have been set, fetch the
* most recent PPS timestamp.
*/
pp = peer->procptr;
if (ap->handle == 0)
return (0);
if (ap->pps_params.mode == 0 && sys_leap != LEAP_NOTINSYNC) {
if (refclock_params(pp->sloppyclockflag, ap) < 1)
return (0);
}
timeout.tv_sec = 0;
timeout.tv_nsec = 0;
memset(&pps_info, 0, sizeof(pps_info_t));
if (time_pps_fetch(ap->handle, PPS_TSFMT_TSPEC, &pps_info,
&timeout) < 0) {
refclock_report(peer, CEVNT_FAULT);
return (0);
}
timeout = ap->ts;
if (ap->pps_params.mode & PPS_CAPTUREASSERT)
ap->ts = pps_info.assert_timestamp;
else if (ap->pps_params.mode & PPS_CAPTURECLEAR)
ap->ts = pps_info.clear_timestamp;
else
return (0);
/*
* There can be zero, one or two PPS pulses between polls,
* depending on the poll interval relative to the PPS interval.
* The pulse must be newer and within the range gate relative
* to the last pulse.
*/
if (ap->ts.tv_sec <= timeout.tv_sec || abs(ap->ts.tv_nsec -
timeout.tv_nsec) > RANGEGATE)
return (0);
/*
* Convert to signed fraction offset and stuff in median filter.
*/
pp->lastrec.l_ui = (u_int32)ap->ts.tv_sec + JAN_1970;
dtemp = ap->ts.tv_nsec / 1e9;
pp->lastrec.l_uf = (u_int32)(dtemp * FRAC);
if (dtemp > .5)
dtemp -= 1.;
SAMPLE(-dtemp + pp->fudgetime1);
#ifdef DEBUG
if (debug > 1)
printf("refclock_pps: %lu %f %f\n", current_time,
dtemp, pp->fudgetime1);
#endif
return (1);
}