Lines Matching +full:up +full:-

4  * - NeoClock4X driver for DCF77 or FIA Timecode
6 * Date: 2009-12-04 v1.16
57 * NTP version 4.20 change the pp->msec field to pp->nsec.
105 #define NEOCLOCK4X_DRIVER_VERSION "1.16 (2009-12-04)"
151 neoclock4x_start, /* start up driver */
164 struct neoclock4x_unit *up;
176 (void) snprintf(dev, sizeof(dev)-1, "/dev/neoclock4x-%d", unit);
181 fd = refclock_open(&peer->srcadr, dev, B2400, LDISC_STD);
262 if(ioctl(fd, TIOCMGET, (caddr_t)&sl232) == -1)
273 if(ioctl(fd, TIOCMSET, (caddr_t)&sl232) == -1)
286 up = (struct neoclock4x_unit *) emalloc(sizeof(struct neoclock4x_unit));
287 if(!(up))
294 memset((char *)up, 0, sizeof(struct neoclock4x_unit));
295 pp = peer->procptr;
296 pp->clockdesc = "NeoClock4X";
297 pp->unitptr = up;
298 pp->io.clock_recv = neoclock4x_receive;
299 pp->io.srcclock = peer;
300 pp->io.datalen = 0;
301 pp->io.fd = fd;
309 pp->fudgetime1 = (NEOCLOCK4X_TIMECODELEN * 11) / 2400.0;
314 peer->precision = -10;
315 memcpy((char *)&pp->refid, "neol", 4);
317 up->leap_status = 0;
318 up->unit = unit;
319 strlcpy(up->firmware, "?", sizeof(up->firmware));
320 up->firmwaretag = '?';
321 strlcpy(up->serial, "?", sizeof(up->serial));
322 strlcpy(up->radiosignal, "?", sizeof(up->radiosignal));
323 up->timesource = '?';
324 up->dststatus = '?';
325 up->quarzstatus = '?';
326 up->antenna1 = -1;
327 up->antenna2 = -1;
328 up->utc_year = 0;
329 up->utc_month = 0;
330 up->utc_day = 0;
331 up->utc_hour = 0;
332 up->utc_minute = 0;
333 up->utc_second = 0;
334 up->utc_msec = 0;
338 strlcpy(up->firmware, "(c) 2002 NEOL S.A. FRANCE / L0.01 NDF:A:* (compile time)",
339 sizeof(up->firmware));
340 up->firmwaretag = 'A';
345 pp->io.fd = -1;
346 free(pp->unitptr);
347 pp->unitptr = NULL;
355 /* wait 3 seconds for receiver to power up */
357 if(neol_query_firmware(pp->io.fd, up->unit, up->firmware, sizeof(up->firmware)))
364 if(!neol_check_firmware(up->unit, up->firmware, &up->firmwaretag))
367 pp->io.fd = -1;
368 free(pp->unitptr);
369 pp->unitptr = NULL;
374 if(!io_addclock(&pp->io))
378 pp->io.fd = -1;
379 free(pp->unitptr);
380 pp->unitptr = NULL;
394 struct neoclock4x_unit *up;
400 pp = peer->procptr;
403 up = pp->unitptr;
404 if(up != NULL)
406 if(-1 != pp->io.fd)
411 if(ioctl(pp->io.fd, TIOCMGET, (caddr_t)&sl232) == -1)
423 if(ioctl(pp->io.fd, TIOCMSET, (caddr_t)&sl232) == -1)
429 io_closeclock(&pp->io);
431 free(up);
432 pp->unitptr = NULL;
446 struct neoclock4x_unit *up;
457 peer = rbufp->recv_peer;
458 pp = peer->procptr;
459 up = pp->unitptr;
462 if(0 == up->recvnow)
466 up->recvnow = 0;
469 pp->lencode = refclock_gtlin(rbufp, pp->a_lastcode, BMAX, &pp->lastrec);
470 pp->leap = LEAP_NOWARNING;
472 if(NEOCLOCK4X_TIMECODELEN != pp->lencode)
476 up->unit, NEOCLOCK4X_TIMECODELEN, pp->lencode, pp->a_lastcode);
481 neol_hexatoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_CRC], &recv_chksum, 2);
487 calc_chksum += pp->a_lastcode[c];
493 up->unit, pp->a_lastcode);
502 up->quarzstatus = pp->a_lastcode[NEOCLOCK4X_OFFSET_QUARZSTATUS];
503 if(0==(pp->sloppyclockflag & CLK_FLAG2))
505 if('I' != up->quarzstatus)
509 up->unit, pp->a_lastcode);
510 pp->leap = LEAP_NOTINSYNC;
515 if('I' != up->quarzstatus)
519 up->unit, pp->a_lastcode);
527 up->timesource = pp->a_lastcode[NEOCLOCK4X_OFFSET_TIMESOURCE];
528 if(0==(pp->sloppyclockflag & CLK_FLAG2))
530 if('A' != up->timesource)
533 if(0==(pp->sloppyclockflag & CLK_FLAG1))
536 pp->leap = LEAP_NOTINSYNC;
543 if(pp->sloppyclockflag & CLK_FLAG4)
546 up->unit, pp->a_lastcode);
552 neol_atoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_YEAR], &pp->year, 2);
553 neol_atoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_MONTH], &month, 2);
554 neol_atoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_DAY], &day, 2);
555 neol_atoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_HOUR], &pp->hour, 2);
556 neol_atoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_MINUTE], &pp->minute, 2);
557 neol_atoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_SECOND], &pp->second, 2);
558 neol_atoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_HSEC], &dsec, 2);
560 pp->msec = dsec * 10; /* convert 1/100s from neoclock to real miliseconds */
562 pp->nsec = dsec * 10 * NSEC_TO_MILLI; /* convert 1/100s from neoclock to nanoseconds */
565 memcpy(up->radiosignal, &pp->a_lastcode[NEOCLOCK4X_OFFSET_RADIOSIGNAL], 3);
566 up->radiosignal[3] = 0;
567 memcpy(up->serial, &pp->a_lastcode[NEOCLOCK4X_OFFSET_SERIAL], 6);
568 up->serial[6] = 0;
569 up->dststatus = pp->a_lastcode[NEOCLOCK4X_OFFSET_DSTSTATUS];
570 neol_hexatoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_ANTENNA1], &up->antenna1, 2);
571 neol_hexatoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_ANTENNA2], &up->antenna2, 2);
575 array-bounds problems, etc.
577 if((pp->hour < 0) || (pp->hour > 23) ||
578 (pp->minute < 0) || (pp->minute > 59) ||
579 (pp->second < 0) || (pp->second > 60) /*Allow for leap seconds.*/ ||
582 (pp->year < 0) || (pp->year > 99)) {
586 up->unit, pp->a_lastcode);
591 /* Year-2000 check not needed anymore. Same problem
594 * wrap 2-digit date into 4-digit
596 * if(pp->year < YEAR_PIVOT)
598 * pp->year += 100;
601 pp->year += 2000;
604 calc_utc = neol_mktime(pp->year, month, day, pp->hour, pp->minute, pp->second);
605 calc_utc -= 3600;
607 if('S' == up->dststatus)
608 calc_utc -= 3600;
609 neol_localtime(calc_utc, &pp->year, &month, &day, &pp->hour, &pp->minute, &pp->second);
614 pp->day = ymd2yd(pp->year, month, day);
615 pp->leap = 0;
617 if(pp->sloppyclockflag & CLK_FLAG4)
619 msyslog(LOG_DEBUG, "NeoClock4X(%d): calculated UTC date/time: %04d-%02d-%02d %02d:%02d:%02d.%03ld",
620 up->unit,
621 pp->year, month, day,
622 pp->hour, pp->minute, pp->second,
624 pp->msec
626 pp->nsec/NSEC_TO_MILLI
631 up->utc_year = pp->year;
632 up->utc_month = month;
633 up->utc_day = day;
634 up->utc_hour = pp->hour;
635 up->utc_minute = pp->minute;
636 up->utc_second = pp->second;
638 up->utc_msec = pp->msec;
640 up->utc_msec = pp->nsec/NSEC_TO_MILLI;
646 msyslog(LOG_WARNING, "NeoClock4X(%d): refclock_process failed!", up->unit);
655 record_clock_stats(&peer->srcadr, pp->a_lastcode);
662 struct neoclock4x_unit *up;
665 pp = peer->procptr;
666 up = pp->unitptr;
668 pp->polls++;
669 up->recvnow = 1;
678 struct neoclock4x_unit *up;
687 pp = peer->procptr;
694 up = pp->unitptr;
695 if(NULL == up)
704 if(in->haveflags & CLK_HAVETIME1)
706 pp->fudgetime1 = in->fudgetime1;
709 unit, pp->fudgetime1);
713 if(pp->sloppyclockflag & CLK_FLAG1)
730 out->kv_list = (struct ctl_var *)0;
731 out->type = REFCLK_NEOCLOCK4X;
733 snprintf(tmpbuf, sizeof(tmpbuf)-1,
734 "%04d-%02d-%02d %02d:%02d:%02d.%03d",
735 up->utc_year, up->utc_month, up->utc_day,
736 up->utc_hour, up->utc_minute, up->utc_second,
737 up->utc_msec);
738 tt = add_var(&out->kv_list, sizeof(tmpbuf)-1, RO|DEF);
739 snprintf(tt, sizeof(tmpbuf)-1, "calc_utc=\"%s\"", tmpbuf);
741 tt = add_var(&out->kv_list, 40, RO|DEF);
742 snprintf(tt, 39, "radiosignal=\"%s\"", up->radiosignal);
743 tt = add_var(&out->kv_list, 40, RO|DEF);
744 snprintf(tt, 39, "antenna1=\"%d\"", up->antenna1);
745 tt = add_var(&out->kv_list, 40, RO|DEF);
746 snprintf(tt, 39, "antenna2=\"%d\"", up->antenna2);
747 tt = add_var(&out->kv_list, 40, RO|DEF);
748 if('A' == up->timesource)
750 else if('C' == up->timesource)
754 tt = add_var(&out->kv_list, 40, RO|DEF);
755 if('I' == up->quarzstatus)
757 else if('X' == up->quarzstatus)
761 tt = add_var(&out->kv_list, 40, RO|DEF);
762 if('S' == up->dststatus)
764 else if('W' == up->dststatus)
768 tt = add_var(&out->kv_list, 80, RO|DEF);
769 snprintf(tt, 79, "firmware=\"%s\"", up->firmware);
770 tt = add_var(&out->kv_list, 40, RO|DEF);
771 snprintf(tt, 39, "firmwaretag=\"%c\"", up->firmwaretag);
772 tt = add_var(&out->kv_list, 80, RO|DEF);
774 tt = add_var(&out->kv_list, 80, RO|DEF);
775 snprintf(tt, 79, "serialnumber=\"%s\"", up->serial);
790 hexdigit = isdigit((unsigned char)str[i]) ? toupper((unsigned char)str[i]) - '0' : toupper((unsigned char)str[i]) - 'A' + 10;
808 digit = str[i] - '0';
815 /* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
816 * Assumes input in normal date format, i.e. 1980-12-31 23:59:59
822 * -year/100+year/400 terms, and add 10.]
826 * WARNING: this function will overflow on 2106-02-07 06:28:16 on
827 * machines were long is 32-bit! (However, as time_t is signed, we
828 * will already get problems at other places on 2038-01-19 03:14:08)
838 if (0 >= (int) (mon -= 2)) { /* 1..12 . 11,12,1..10 */
840 year -= 1;
843 (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) +
844 year*365 - 719499
882 x = x - (daysPer400Years * z + 3UL) / 4UL;
884 x = x - 1461UL * y / 4UL + 31UL;
886 d = x - 2447UL * m / 80UL;
888 m = m + 2UL - 12UL * x;
889 y = 100UL * (z - 49UL) + y + x;
916 if(-1 != write(fd, "V", 1))
943 if(-1 == read(fd, &c, 1))
1004 if (len > sizeof(tmpbuf)-5)
1042 if((strlen(firmware) - strlen(ptr)) >= 7)
1075 * - don't assume sprintf returns an int anymore
1076 * - change the way the firmware version is read
1077 * - some customers would like to put a device called
1086 * - changing xprinf to xnprinf to avoid buffer overflows
1087 * - change some logic
1088 * - fixed memory leaks if drivers can't initialize
1092 * - replaced ldiv
1093 * - add code to support FreeBSD
1097 * - fix reporting of clock status
1103 * - open serial port in a way
1109 * - remove some unsued #ifdefs
1110 * - fix nsec calculation, closes #499
1114 * - change license to ntp COPYRIGHT notice. This should allow Debian
1116 * - detect R2 hardware