Lines Matching +full:message +full:- +full:handling +full:- +full:unit

65 #define PRECISION   (-20)                       /* precision assumed (1 us) */
66 #define DESCRIPTION "Spectracom TSYNC-PCI" /* WRU */
142 unsigned char syncOption; /* -M option */
244 * unit control structure
256 static void tsync_poll (int unit, struct peer *);
273 tsync_poll, /* transmit poll message */
313 * IN: unit - not used.
314 * *peer - pointer to this reference clock's peer structure
315 * Returns: 0 - unsuccessful
316 * 1 - successful
319 static int tsync_start(int unit, struct peer *peer)
328 pp = peer->procptr;
329 pp->clockdesc = DESCRIPTION;
330 pp->io.clock_recv = noentry;
331 pp->io.srcclock = peer;
332 pp->io.datalen = 0;
333 peer->precision = PRECISION;
335 // Allocate and initialize unit structure
342 up->refPrefer = peer->flags & FLAG_PREFER;
345 up->refStratum = STRATUM_UNSPEC;
346 strncpy((char *)&up->refId, TSYNC_REF_LOCAL, TSYNC_REF_LEN);
348 // Attach unit structure
349 pp->unitptr = (caddr_t)up;
354 strncpy((char *)&pp->refid, TSYNC_REF_LOCAL, TSYNC_REF_LEN);
358 } /* End - tsync_start() */
367 ** IN: unit - not used.
368 ** *peer - pointer to this reference clock's peer structure
372 static void tsync_shutdown(int unit, struct peer *peer)
375 } /* End - tsync_shutdown() */
383 * IN: unit - not used.
384 * *peer - pointer to this reference clock's peer structure
388 static void tsync_poll(int unit, struct peer *peer)
420 sprintf(device, "%s%d", DEVICE, (int)peer->refclkunit);
422 printf("Polling device number %d...\n", (int)peer->refclkunit);
442 /* Allocate memory for ioctl message */
444 (sizeof(ioctl_trans_di) - DI_PAYLOADS_STARTER_LENGTH) +
449 msyslog(LOG_ERR, "Couldn't allocate transaction memory - Reference");
453 /* Build SS_GetRef ioctl message */
454 it->dest = TSYNC_REF_DEST_ID;
455 it->iid = TSYNC_REF_IID;
456 it->inPayloadOffset = TSYNC_REF_IN_PYLD_OFF;
457 it->inLength = TSYNC_REF_IN_LEN;
458 it->outPayloadOffset = TSYNC_REF_OUT_PYLD_OFF;
459 it->maxOutLength = TSYNC_REF_MAX_OUT_LEN;
460 it->actualOutLength = 0;
461 it->status = 0;
462 memset(it->payloads, 0, TSYNC_REF_MAX_OUT_LEN);
464 /* Read the reference from the TSYNC-PCI device */
469 /* Allocate memory for ioctl message */
471 (sizeof(ioctl_trans_di) - DI_PAYLOADS_STARTER_LENGTH) +
476 msyslog(LOG_ERR, "Couldn't allocate transaction memory - Time Scale");
480 /* Build CS_GetTimeScale ioctl message */
481 it1->dest = TSYNC_TMSCL_DEST_ID;
482 it1->iid = TSYNC_TMSCL_IID;
483 it1->inPayloadOffset = TSYNC_TMSCL_IN_PYLD_OFF;
484 it1->inLength = TSYNC_TMSCL_IN_LEN;
485 it1->outPayloadOffset = TSYNC_TMSCL_OUT_PYLD_OFF;
486 it1->maxOutLength = TSYNC_TMSCL_MAX_OUT_LEN;
487 it1->actualOutLength = 0;
488 it1->status = 0;
489 memset(it1->payloads, 0, TSYNC_TMSCL_MAX_OUT_LEN);
491 /* Read the Time Scale info from the TSYNC-PCI device */
496 /* Allocate memory for ioctl message */
498 (sizeof(ioctl_trans_di) - DI_PAYLOADS_STARTER_LENGTH) +
503 msyslog(LOG_ERR, "Couldn't allocate transaction memory - Leap Second");
507 /* Build CS_GetLeapSec ioctl message */
508 it2->dest = TSYNC_LEAP_DEST_ID;
509 it2->iid = TSYNC_LEAP_IID;
510 it2->inPayloadOffset = TSYNC_LEAP_IN_PYLD_OFF;
511 it2->inLength = TSYNC_LEAP_IN_LEN;
512 it2->outPayloadOffset = TSYNC_LEAP_OUT_PYLD_OFF;
513 it2->maxOutLength = TSYNC_LEAP_MAX_OUT_LEN;
514 it2->actualOutLength = 0;
515 it2->status = 0;
516 memset(it2->payloads, 0, TSYNC_LEAP_MAX_OUT_LEN);
518 /* Read the leap seconds info from the TSYNC-PCI device */
523 pp = peer->procptr;
524 up = (TsyncUnit*)pp->unitptr;
526 /* Read the time from the TSYNC-PCI device */
536 (it->status != 0) || (it1->status != 0) || (it2->status != 0) ||
537 (it->actualOutLength != TSYNC_REF_OUT_LEN) ||
538 (it1->actualOutLength != TSYNC_TMSCL_OUT_LEN) ||
539 (it2->actualOutLength != TSYNC_LEAP_OUT_LEN)) {
547 pRefObj = (void *)it->payloads;
548 memcpy(timeRef, pRefObj->time, TSYNC_REF_LEN);
549 memcpy(ppsRef, pRefObj->pps, TSYNC_REF_LEN);
552 memcpy(&tmscl, it1->payloads, sizeof(tmscl));
561 ((unsigned char*)(it2->payloads))[(i * 4) + (3 - j)];
598 DTOLFP(((double)TimeContext.tv.tv_usec / 1000000.0), &pp->lastrec);
606 pp->lastrec.Ul_i.Xl_ui += (unsigned int)TimeContext.tv.tv_sec +
609 pp->polls++;
614 sprintf(pp->a_lastcode, "%03d %02d:%02d:%02.6f",
618 pp->lencode = strlen (pp->a_lastcode);
619 pp->day = TimeContext.timeObj.days;
620 pp->hour = TimeContext.timeObj.hours;
621 pp->minute = TimeContext.timeObj.minutes;
622 pp->second = (int) seconds;
623 seconds = (seconds - (double) (pp->second / 1.0)) * 1000000000;
624 pp->nsec = (long) seconds;
636 pp->yearstart = caltontp(&jt);
639 offset.l_ui = (long)(((pp->day - 1) * 24) + pp->hour + GMT);
640 offset.l_ui = (offset.l_ui * 60) + (long)pp->minute;
641 offset.l_ui = (offset.l_ui * 60) + (long)pp->second;
642 offset.l_ui = offset.l_ui + (long)pp->yearstart;
644 DTOLFP(pp->nsec / 1e9, &ltemp);
646 refclock_process_offset(pp, offset, pp->lastrec,
647 pp->fudgetime1);
652 ApplyTimeOffset(&(leapSec.utcDate), -1);
663 pp->leap = LEAP_ADDSECOND;
666 else if (leapSec.offset == -1)
668 pp->leap = LEAP_DELSECOND;
670 // Else report no leap second pending (no handling of offsets
671 // other than +1 or -1)
674 pp->leap = LEAP_NOWARNING;
680 pp->leap = LEAP_NOWARNING;
683 peer->leap = pp->leap;
696 peer->flags &= ~FLAG_PREFER;
699 pp->stratum = STRATUM_UNSPEC;
700 peer->stratum = pp->stratum;
706 up->refStratum = sys_peer->stratum;
707 up->refId = addr2refid(&sys_peer->srcadr);
713 peer->flags |= up->refPrefer;
716 up->refStratum = TSYNC_LCL_STRATUM;
717 strncpy((char *)&up->refId, RefIdLookupTbl[j].pRefId,
721 pp->stratum = TSYNC_LCL_STRATUM;
722 peer->stratum = pp->stratum;
726 strncpy((char *)&pp->refid, RefIdLookupTbl[j].pRefId,
728 peer->refid = pp->refid;
734 peer->flags |= up->refPrefer;
737 pp->refid = up->refId;
738 peer->refid = pp->refid;
741 pp->stratum = up->refStratum;
742 peer->stratum = pp->stratum;
748 strncpy((char *)&pp->refid, TSYNC_REF_LOCAL, TSYNC_REF_LEN);
749 peer->refid = pp->refid;
752 pp->leap = LEAP_NOTINSYNC;
753 peer->leap = pp->leap;
756 if (pp->coderecv == pp->codeproc) {
761 record_clock_stats(&peer->srcadr, pp->a_lastcode);
765 pp->polls++;
767 } /* End - tsync_poll() */
814 pSt->seconds = 0;
817 yrs = pDt->year - TSYNC_TIME_BASE_YEAR;
821 pSt->seconds += lyrs * SECSPERLEAPYEAR;
822 pSt->seconds += (yrs - lyrs) * SECSPERYEAR;
825 pSt->seconds += (pDt->doy - 1) * SECSPERDAY;
826 pSt->seconds += pDt->hour * SECSPERHR;
827 pSt->seconds += pDt->minute * SECSPERMIN;
828 pSt->seconds += pDt->second;
831 pSt->ns = pDt->ns;
855 // Convert the seconds count into a signed 64-bit number for calculations
856 secs = (signed long long)(pSt->seconds);
868 secs -= SECSPERYEAR;
876 secs -= SECSPERYEAR;
884 secs -= SECSPERLEAPYEAR;
901 pDt->year = yrs + TSYNC_TIME_BASE_YEAR;
902 pDt->doy = doys;
903 pDt->hour = hrs;
904 pDt->minute = mins;
905 pDt->second = (unsigned int)secs;
906 pDt->ns = pSt->ns;