Lines Matching refs:up

160 	jupiter_start,		/* start up driver */
179 struct instance * up;
195 up = emalloc_zero(sizeof(*up));
196 up->peer = peer;
204 free(up);
207 pp->unitptr = up;
216 up->assert = 1;
217 up->hardpps = 0;
222 if (time_pps_create(fd, &up->pps_handle) < 0) {
223 up->pps_handle = 0;
227 else if (!jupiter_ppsapi(up))
231 if (!jupiter_config(up))
234 jupiter_pps(up); /* get current PPS state */
250 struct instance * const up = pp->unitptr;
252 if (!up)
255 if (up->pps_handle) {
256 time_pps_destroy(up->pps_handle);
257 up->pps_handle = 0;
262 free(up);
269 jupiter_config(struct instance * const up)
271 jupiter_debug(up->peer, __func__, "init receiver");
276 up->sloppyclockflag = up->peer->procptr->sloppyclockflag;
277 up->moving = !!(up->sloppyclockflag & CLK_FLAG2);
278 if (up->moving)
279 jupiter_debug(up->peer, __func__, "mobile platform");
281 ZERO(up->rcv_next);
282 ZERO(up->ref_next);
283 ZERO(up->piv_next);
284 up->ssize = 0;
287 jupiter_canmsg(up, JUPITER_ALL);
290 jupiter_reqonemsg(up, JUPITER_O_ID);
293 up->wantid = 1;
296 jupiter_reqmsg(up, JUPITER_O_PULSE, 1);
299 jupiter_reqmsg(up, JUPITER_O_GPOS, 1);
302 if (up->moving)
303 jupiter_platform(up, JUPITER_I_PLAT_MED);
305 jupiter_platform(up, JUPITER_I_PLAT_LOW);
313 struct instance * const up
319 if (jupiter_pps(up) || !up->piv_next.weeks)
323 delta = up->rcv_pps; /* set by jupiter_pps() */
324 L_SUB(&delta, &up->rcv_next); /* recv time pulse message */
326 up->ref_next.weeks = 0; /* consider as consumed... */
330 pp->lastrec = up->rcv_pps;
331 tstamp = ntpfp_from_gpsdatum(&up->ref_next);
332 refclock_process_offset(pp, tstamp, up->rcv_pps, pp->fudgetime1);
333 up->rcvtout = 2;
335 gpscal_to_calendar(&cd, &up->ref_next);
338 up->ref_next.weeks = 0; /* consumed... */
348 struct instance * const up = pp->unitptr;
350 if (!up)
354 jupiter_checkpps(pp, up);
357 if (up->piv_hold && !--up->piv_hold)
358 ZERO(up->piv_next);
360 if (up->rcvtout)
361 --up->rcvtout;
371 struct instance * const up /* unit structure pointer */
376 if (time_pps_getcap(up->pps_handle, &capability) < 0) {
381 memset(&up->pps_params, 0, sizeof(pps_params_t));
382 if (!up->assert)
383 up->pps_params.mode = capability & PPS_CAPTURECLEAR;
385 up->pps_params.mode = capability & PPS_CAPTUREASSERT;
386 if (!(up->pps_params.mode & (PPS_CAPTUREASSERT | PPS_CAPTURECLEAR))) {
389 up->assert);
392 up->pps_params.mode |= PPS_TSFMT_TSPEC;
393 if (time_pps_setparams(up->pps_handle, &up->pps_params) < 0) {
398 if (up->hardpps) {
399 if (time_pps_kcbind(up->pps_handle, PPS_KC_HARDPPS,
400 up->pps_params.mode & ~PPS_TSFMT_TSPEC,
408 /* up->peer->precision = PPS_PRECISION; */
412 time_pps_getparams(up->pps_handle, &up->pps_params);
413 jupiter_debug(up->peer, __func__,
415 capability, up->pps_params.api_version,
416 up->pps_params.mode, up->hardpps);
429 jupiter_pps(struct instance * const up)
438 if (up->pps_handle == 0)
442 memcpy(&pps_info, &up->pps_info, sizeof(pps_info_t));
443 if (time_pps_fetch(up->pps_handle, PPS_TSFMT_TSPEC, &up->pps_info,
446 if (up->pps_params.mode & PPS_CAPTUREASSERT) {
448 up->pps_info.assert_sequence)
450 ts = up->pps_info.assert_timestamp;
451 } else if (up->pps_params.mode & PPS_CAPTURECLEAR) {
453 up->pps_info.clear_sequence)
455 ts = up->pps_info.clear_timestamp;
461 if (L_ISEQU(&tstmp, &up->rcv_pps))
464 up->rcv_pps = tstmp;
475 struct instance * const up = pp->unitptr;
490 jupiter_reqonemsg(up, JUPITER_O_ID);
491 up->wantid = 0;
507 struct instance * const up = pp->unitptr;
511 up->assert = !(pp->sloppyclockflag & CLK_FLAG3);
512 jupiter_ppsapi(up);
514 sloppyclockflag = up->sloppyclockflag;
515 up->sloppyclockflag = pp->sloppyclockflag;
516 if ((up->sloppyclockflag & CLK_FLAG2) !=
520 jupiter_config(up);
534 struct instance * const up = pp->unitptr;
549 if (bpcnt > sizeof(up->sbuf) - up->ssize)
550 bpcnt = sizeof(up->sbuf) - up->ssize;
553 memcpy((u_char *)up->sbuf + up->ssize, bp, bpcnt);
554 up->ssize += bpcnt;
557 while (up->ssize > (int)sizeof(*hp) && (cc = jupiter_recv(up)) > 0) {
558 hp = (struct jheader *)up->sbuf;
565 jupiter_checkpps(pp, up);
588 if ((cp = jupiter_parse_t(up, sp, rbufp->recv_time)) != NULL) {
603 if ((cp = jupiter_parse_gpos(up, sp)) != NULL) {
629 if (up->wantid)
630 up->wantid = 0;
633 jupiter_config(up);
638 up->ssize = cc;
647 up->ssize -= cc;
648 if (up->ssize < 0) {
651 } else if (up->ssize > 0)
652 memcpy(up->sbuf, (u_char *)up->sbuf + cc, up->ssize);
658 struct instance * const up,
675 refclock_report(up->peer, CEVNT_BADTIME);
679 up->rcv_next = rcvtime; /* remember when this happened */
709 if (up->piv_next.weeks) {
710 up->ref_next = gpscal_from_weektime2(
711 sweek, fofs, &up->piv_next);
712 up->piv_next = up->ref_next;
714 up->ref_next = gpscal_from_weektime1(
725 struct instance * const up,
750 up->piv_next = gpscal_from_gpsweek(raw_week, raw_secs,
752 up->piv_hold = 60;
754 gpscal_to_calendar(&tref, &up->piv_next);
756 jupiter_debug(up->peer, __func__,
796 struct instance * const up,
815 if ((cc = write(up->peer->procptr->io.fd, (char *)hp, size)) < 0) {
840 struct instance * const up,
854 if ((cp = jupiter_send(up, hp)) != NULL)
855 jupiter_debug(up->peer, __func__, "%u: %s", id, cp);
867 struct instance * const up,
876 if ((cp = jupiter_send(up, hp)) != NULL)
877 jupiter_debug(up->peer, __func__, "%u: %s", id, cp);
889 struct instance * const up,
898 if ((cp = jupiter_send(up, hp)) != NULL)
899 jupiter_debug(up->peer, __func__, "%u: %s", id, cp);
915 struct instance * const up,
926 if ((cp = jupiter_send(up, hp)) != NULL)
927 jupiter_debug(up->peer, __func__, "%u: %s", platform, cp);
947 struct instance * const up
957 size = up->ssize;
962 sp = up->sbuf;
965 /* Wasn't at the front, sync up */
966 jupiter_debug(up->peer, __func__, "syncing");
972 jupiter_debug(up->peer, __func__,
982 jupiter_debug(up->peer, __func__,
989 jupiter_debug(up->peer, __func__, "\n");
995 up->ssize = size;
1002 jupiter_debug(up->peer, __func__, "bad header checksum!");
1004 up->ssize = 0;
1019 jupiter_debug(up->peer,
1022 up->ssize = 0;