589
585
(void)sprintf(device1, DEVICE1, unit);
590
586
(void)sprintf(device2, DEVICE2, unit);
592
#ifdef PPS_HAVE_FINDSOURCE
593
/* Try to find the PPS source (by using "index = -1"
594
* we ask just for a generic source)
598
if ((num=time_pps_findsource(num, device2, STRING_LEN, id, STRING_LEN)) < 0) {
599
sprintf(Msg, "No available PPS source in the system");
600
record_clock_stats(&(instance->peer->srcadr), Msg);
604
sprintf(Msg, "Found PPS source #%d \"%s\" on \"%s\"", num, id, device2);
605
record_clock_stats(&(instance->peer->srcadr), Msg);
607
/* there are two cases here:
608
* either there is a device name in device2 and we must open it,
609
* or there is not, and and it is not a device, and there is nothing
611
* in either case we must use refclock_open to get fd1 opened raw.
614
if (strlen(device2)) {
615
if (stat(device1, &stat1)) {
616
sprintf(Msg, "Can't stat fd1 (%s)\n", device1);
617
record_clock_stats(&(instance->peer->srcadr), Msg);
621
if (stat(device2, &stat2)) {
622
sprintf(Msg, "Can't stat fd2 (%s)\n", device2);
623
record_clock_stats(&(instance->peer->srcadr), Msg);
627
if ((stat1.st_dev != stat2.st_dev) || (stat1.st_ino != stat2.st_ino)) {
628
if ((ret=open(device2, O_RDWR)) < 0) { /* different devices here */
629
sprintf(Msg, "Can't open fd2 (%s)\n", device2);
630
record_clock_stats(&(instance->peer->srcadr), Msg);
636
if ((fd1=refclock_open(device1, SPEED, LDISC_RAW)) < 0) {
637
sprintf(Msg, "Can't open fd1 (%s)\n", device1);
638
record_clock_stats(&(instance->peer->srcadr), Msg);
643
588
/* OPEN DEVICES */
644
589
/* opening different devices for fd1 and fd2 presents no problems */
645
590
/* opening the SAME device twice, seems to be OS dependent.
2424
2369
dt1 = instance->saw_tooth + instance->offset; /* dt this time step */
2425
instance->saw_tooth = (s_char) instance->BEHn[10]; /* update for next time Hn[10] */
2370
instance->saw_tooth = (s_char) instance->BEHn[14]; /* update for next time Hn[14] */
2426
2371
dt2 = instance->saw_tooth + instance->offset; /* dt next time step */
2428
2373
if (instance->BEHn[21]) /* bad TRAIM */
2431
2376
dt1 = instance->saw_tooth + instance->offset; /* dt this time step */
2432
instance->saw_tooth = (s_char) instance->BEHn[25]; /* update for next time */
2377
instance->saw_tooth = (s_char) instance->BEHn[25]; /* update for next time Bn[25], En[25] */
2433
2378
dt2 = instance->saw_tooth + instance->offset; /* dt next time step */
2972
2917
sprintf(Msg, "ONCORE[%d]: Leap second (%d) scheduled for %d%s%d at %d:%d:%d",
2973
2918
instance->unit,
2974
dt, buf[9], Month[buf[8]], 256*buf[6]+buf[7],
2919
dt, buf[9], Month[buf[8]-1], 256*buf[6]+buf[7],
2975
2920
buf[15], buf[16], buf[17]);
2976
2921
record_clock_stats(&(instance->peer->srcadr), Msg);