Lines Matching +full:up +full:- +full:to

2  * refclock_hpgps - clock driver for HP 58503A GPS receiver
30 * Comments and/or questions to: Dave Vitanye
33 * (408) 553-2856
35 * Thanks to the author of the PST driver, which was the starting point for
39 * This receiver uses HP SmartClock (TM) to implement an Enhanced GPS receiver.
40 * The receiver accuracy when locked to GPS in normal operation is better
47 * That is selected by adding "mode 1" to the server line in ntp.conf
52 * Initial driver operation: expects the receiver to be already locked
53 * to GPS, configured and able to output timecode format 2 messages.
55 * The driver uses the poll sequence :PTIME:TCODE? to get a response from
68 * The T is the on-time character, at 980 msec. before the next 1PPS edge.
72 * so the first approximation for fudge time1 is nominally -0.955 seconds.
74 * -0.955000 on an HP 9000 Model 712/80 HP-UX 9.05
75 * -0.953175 on an HP 9000 Model 370 HP-UX 9.10
78 * how to deal with any of the CLK or PPS stuff yet. Stay tuned.
85 * Fudge time1 is used to accomodate the timecode serial interface adjustment.
86 * Fudge flag4 can be set to request a receiver status screen summary, which
96 #define PRECISION (-10) /* precision assumed (about 1 ms) */
104 #define NTCODET2 21 /* number of chars to checksum in format T2 */
107 * Tables to compute the day of year from yyyymmdd timecode.
121 char *lastptr; /* pointer to receiver response data */
137 hpgps_start, /* start up driver */
148 * hpgps_start - open the devices and initialize data for processing
156 register struct hpgpsunit *up;
169 /* mode parameter to server config line shares ttl slot */
170 if (1 == peer->ttl) {
174 fd = refclock_open(&peer->srcadr, device, speed, ldisc);
180 up = emalloc_zero(sizeof(*up));
181 pp = peer->procptr;
182 pp->io.clock_recv = hpgps_receive;
183 pp->io.srcclock = peer;
184 pp->io.datalen = 0;
185 pp->io.fd = fd;
186 if (!io_addclock(&pp->io)) {
188 pp->io.fd = -1;
189 free(up);
192 pp->unitptr = up;
197 peer->precision = PRECISION;
198 pp->clockdesc = DESCRIPTION;
199 memcpy((char *)&pp->refid, REFID, 4);
200 up->tzhour = 0;
201 up->tzminute = 0;
203 *up->statscrn = '\0';
204 up->lastptr = up->statscrn;
205 up->pollcnt = 2;
211 up->linecnt = 1;
220 * hpgps_shutdown - shut down the clock
228 register struct hpgpsunit *up;
231 pp = peer->procptr;
232 up = pp->unitptr;
233 if (-1 != pp->io.fd)
234 io_closeclock(&pp->io);
235 if (NULL != up)
236 free(up);
241 * hpgps_receive - receive data from the serial interface
248 register struct hpgpsunit *up;
254 char timequal; /* time figure of merit: 0-9 */
255 char freqqual; /* frequency figure of merit: 0-3 */
256 char leapchar; /* leapsecond: + or 0 or - */
269 peer = rbufp->recv_peer;
270 pp = peer->procptr;
271 up = pp->unitptr;
272 *pp->a_lastcode = '\0';
273 pp->lencode = refclock_gtlin(rbufp, pp->a_lastcode, BMAX, &trtmp);
278 pp->lencode, pp->a_lastcode);
284 if (pp->lencode == 0)
291 * screen buffer. When we have the last line, write the buffer to
296 * to the clockstats file, and go on to process the prompt (if any),
301 if (up->linecnt-- > 0) {
302 if ((int)(pp->lencode + 2) <= (SMAX - (up->lastptr - up->statscrn))) {
303 *up->lastptr++ = '\n';
304 memcpy(up->lastptr, pp->a_lastcode, pp->lencode);
305 up->lastptr += pp->lencode;
307 if (up->linecnt == 0)
308 record_clock_stats(&peer->srcadr, up->statscrn);
313 record_clock_stats(&peer->srcadr, pp->a_lastcode);
314 pp->lastrec = trtmp;
316 up->lastptr = up->statscrn;
317 *up->lastptr = '\0';
318 up->pollcnt = 2;
321 * We get down to business: get a prompt if one is there, issue
330 * scpi > -H,-M<cr><lf>
337 strlcpy(prompt, pp->a_lastcode, sizeof(prompt));
338 tcp = strrchr(pp->a_lastcode,'>');
340 tcp = pp->a_lastcode;
343 prompt[tcp - pp->a_lastcode] = '\0';
376 case '-':
377 m = sscanf(tcp,"%d,%d", &up->tzhour, &up->tzminute);
386 if ((up->tzhour < -12) || (up->tzhour > 13) ||
387 (up->tzminute < -59) || (up->tzminute > 59)){
391 up->tzhour, up->tzminute);
416 &pp->year, &month, &day, &pp->hour, &pp->minute, &pp->second,
447 while (n-- > 0) tcodechksm += *tcp++;
468 if ( ! isleap_4(pp->year) ) { /* Y2KFixes */
470 if (day > day1tab[month - 1]) {
474 for (i = 0; i < month - 1; i++) day += day1tab[i];
478 if (day > day2tab[month - 1]) {
482 for (i = 0; i < month - 1; i++) day += day2tab[i];
489 * For example, Pacific Standard Time is -8 hours , 0 minutes.
492 pp->minute -= up->tzminute;
493 pp->hour -= up->tzhour;
495 if (pp->minute < 0) {
496 pp->minute += 60;
497 pp->hour--;
499 if (pp->minute > 59) {
500 pp->minute -= 60;
501 pp->hour++;
503 if (pp->hour < 0) {
504 pp->hour += 24;
505 day--;
507 pp->year--;
508 if ( isleap_4(pp->year) ) /* Y2KFixes */
515 if (pp->hour > 23) {
516 pp->hour -= 24;
519 pp->year++;
524 pp->day = day;
528 * NEED TO FIGURE OUT how to deal with the request for service,
532 pp->leap = LEAP_NOTINSYNC;
535 pp->leap = LEAP_NOWARNING;
543 * Better would be to use :GPSTime? to find the month,
544 * but that seems too likely to introduce other bugs.
548 pp->leap = LEAP_ADDSECOND;
551 case '-':
553 pp->leap = LEAP_DELSECOND;
570 * the reference time and receive time in order to avoid being
572 * time, which may cause a paranoid protocol module to chuck out
579 pp->lastref = pp->lastrec;
585 if (pp->sloppyclockflag & CLK_FLAG4){
586 up->linecnt = 22;
594 * hpgps_poll - called by the transmit procedure
602 register struct hpgpsunit *up;
606 * Time to poll the clock. The HP 58503A responds to a
611 pp = peer->procptr;
612 up = pp->unitptr;
613 if (up->pollcnt == 0)
616 up->pollcnt--;
621 pp->polls++;