Lines Matching +full:message +full:- +full:handling +full:- +full:unit
2 ** refclock_datum - clock driver for the Datum Programmable Time Server
43 ** time code after it first receives the "//k/mn" message. It does not
50 ** byte 0: | - - - - | H D |
54 ** byte 2: | - - | T H | U H |
56 ** byte 3: | - | T M | U M |
58 ** byte 4: | - | T S | U S |
62 ** byte 6: | m S | - - - - |
67 ** "-" means don't care
95 ** correct time by less than +- 30 minutes. The default is for GMT to not
96 ** defined. If you really want to force GMT without the funny +- 30 minute
107 #define PRECISION (-10) /* precision assumed 1/1024 ms */
122 ** that you can use any id for your unit and I will search for it in a
132 u_int unit; /* id for unit */ member
155 static char TIME_REQUEST[6]; /* request message sent to datum for time */
189 ** request message to the Datum Programmable Time System. Then, ntpd
211 /* datum_pts_start - start up the datum PTS. This means open the */
212 /* RS232 device and set up the data structure for my unit. */
217 int unit, in datum_pts_start() argument
231 printf("Starting Datum PTS unit %d\n", unit); in datum_pts_start()
245 ** Create the memory for the new unit in datum_pts_start()
248 datum_pts->unit = unit; /* set my unit id */ in datum_pts_start()
249 datum_pts->yearstart = 0; /* initialize the yearstart to 0 */ in datum_pts_start()
250 datum_pts->sigma2 = 0.0; /* initialize the sigma2 to 0 */ in datum_pts_start()
252 datum_pts->PTS_fd = fd; in datum_pts_start()
254 if (-1 == fcntl(datum_pts->PTS_fd, F_SETFL, 0)) /* clear the descriptor flags */ in datum_pts_start()
256 unit); in datum_pts_start()
261 datum_pts->PTS_fd); in datum_pts_start()
281 rc = tcsetattr(datum_pts->PTS_fd, TCSANOW, &arg); in datum_pts_start()
284 close(datum_pts->PTS_fd); in datum_pts_start()
293 datum_pts->peer = peer; in datum_pts_start()
294 pp = peer->procptr; in datum_pts_start()
295 pp->io.clock_recv = datum_pts_receive; in datum_pts_start()
296 pp->io.srcclock = peer; in datum_pts_start()
297 pp->io.datalen = 0; in datum_pts_start()
298 pp->io.fd = datum_pts->PTS_fd; in datum_pts_start()
300 if (!io_addclock(&pp->io)) { in datum_pts_start()
301 pp->io.fd = -1; in datum_pts_start()
308 close(datum_pts->PTS_fd); in datum_pts_start()
313 peer->procptr->unitptr = datum_pts; in datum_pts_start()
326 /* datum_pts_shutdown - this routine shuts doen the device and */
327 /* removes the memory for the unit. */
332 int unit, in datum_pts_shutdown() argument
347 ** We found the unit so close the file descriptor and free up the memory used in datum_pts_shutdown()
350 pp = peer->procptr; in datum_pts_shutdown()
351 datum_pts = pp->unitptr; in datum_pts_shutdown()
353 io_closeclock(&pp->io); in datum_pts_shutdown()
360 /* datum_pts_poll - this routine sends out the time request to the */
367 int unit, in datum_pts_poll() argument
374 datum_pts = peer->procptr->unitptr; in datum_pts_poll()
382 ** Find the right unit and send out a time request once it is found. in datum_pts_poll()
384 error_code = write(datum_pts->PTS_fd, TIME_REQUEST, 6); in datum_pts_poll()
387 datum_pts->nbytes = 0; in datum_pts_poll()
392 /* datum_pts_control - not used */
397 int unit, in datum_pts_control() argument
413 /* datum_pts_init - initializes things for all possible Datum */
438 ** Initialize the time request command string. This is the only message in datum_pts_init()
455 /* datum_pts_buginfo - not used */
460 int unit, in datum_pts_buginfo() argument
475 /* datum_pts_receive - receive the time buffer that was read in */
476 /* by the ntpd io handling routines. When 7 bytes have been */
505 ** Get the time code (maybe partial) message out of the rbufp buffer. in datum_pts_receive()
508 p = rbufp->recv_peer; in datum_pts_receive()
509 datum_pts = p->procptr->unitptr; in datum_pts_receive()
510 dpt = (char *)&rbufp->recv_space; in datum_pts_receive()
511 dpend = rbufp->recv_length; in datum_pts_receive()
525 ** bytes of our return message are finally received by the io handlers in in datum_pts_receive()
530 nb = datum_pts->nbytes; in datum_pts_receive()
532 datum_pts->lastrec = rbufp->recv_time; in datum_pts_receive()
541 for (i=0; (i < dpend) && (nb < sizeof(datum_pts->retbuf)); i++, nb++) { in datum_pts_receive()
542 datum_pts->retbuf[nb] = dpt[i]; in datum_pts_receive()
544 datum_pts->nbytes = nb; in datum_pts_receive()
557 datum_pts->day = 100*(datum_pts->retbuf[0] & 0x0f) + in datum_pts_receive()
558 10*((datum_pts->retbuf[1] & 0xf0)>>4) + in datum_pts_receive()
559 (datum_pts->retbuf[1] & 0x0f); in datum_pts_receive()
561 datum_pts->hour = 10*((datum_pts->retbuf[2] & 0x30)>>4) + in datum_pts_receive()
562 (datum_pts->retbuf[2] & 0x0f); in datum_pts_receive()
564 datum_pts->minute = 10*((datum_pts->retbuf[3] & 0x70)>>4) + in datum_pts_receive()
565 (datum_pts->retbuf[3] & 0x0f); in datum_pts_receive()
567 datum_pts->second = 10*((datum_pts->retbuf[4] & 0x70)>>4) + in datum_pts_receive()
568 (datum_pts->retbuf[4] & 0x0f); in datum_pts_receive()
570 datum_pts->msec = 100*((datum_pts->retbuf[5] & 0xf0) >> 4) + in datum_pts_receive()
571 10*(datum_pts->retbuf[5] & 0x0f) + in datum_pts_receive()
572 ((datum_pts->retbuf[6] & 0xf0)>>4); in datum_pts_receive()
574 datum_pts->usec = 1000*datum_pts->msec; in datum_pts_receive()
579 datum_pts->day, in datum_pts_receive()
580 datum_pts->hour, in datum_pts_receive()
581 datum_pts->minute, in datum_pts_receive()
582 datum_pts->second, in datum_pts_receive()
583 datum_pts->msec); in datum_pts_receive()
610 ** pick the one that gives the smallest error (+- one half hour). The time in datum_pts_receive()
621 if (clocktime( datum_pts->day, in datum_pts_receive()
622 datum_pts->hour, in datum_pts_receive()
623 datum_pts->minute, in datum_pts_receive()
624 datum_pts->second, in datum_pts_receive()
625 (tzoff + datum_pts->tzoff) % 24, in datum_pts_receive()
626 datum_pts->lastrec.l_ui, in datum_pts_receive()
627 &datum_pts->yearstart, in datum_pts_receive()
628 &datum_pts->lastref.l_ui) ) { in datum_pts_receive()
630 datum_pts->lastref.l_uf = 0; in datum_pts_receive()
631 error = datum_pts->lastref.l_ui - datum_pts->lastrec.l_ui; in datum_pts_receive()
637 if ((error < 1799) && (error > -1799)) { in datum_pts_receive()
638 tzoff = (tzoff + datum_pts->tzoff) % 24; in datum_pts_receive()
639 datum_pts->tzoff = tzoff; in datum_pts_receive()
662 if (!clocktime( datum_pts->day, in datum_pts_receive()
663 datum_pts->hour, in datum_pts_receive()
664 datum_pts->minute, in datum_pts_receive()
665 datum_pts->second, in datum_pts_receive()
667 datum_pts->lastrec.l_ui, in datum_pts_receive()
668 &datum_pts->yearstart, in datum_pts_receive()
669 &datum_pts->lastref.l_ui) ) { in datum_pts_receive()
677 datum_pts->lastrec.l_ui, in datum_pts_receive()
678 datum_pts->yearstart, in datum_pts_receive()
679 datum_pts->lastref.l_ui); in datum_pts_receive()
699 ** We have datum_pts->lastref.l_ui set (which is the integer part of the in datum_pts_receive()
703 TVUTOTSF(datum_pts->usec, datum_pts->lastref.l_uf); in datum_pts_receive()
710 tstmp = datum_pts->lastref; /* tstmp is the datum ntp time */ in datum_pts_receive()
711 L_SUB(&tstmp, &datum_pts->lastrec); /* tstmp is now the correction */ in datum_pts_receive()
712 datum_pts->coderecv++; /* increment a counter */ in datum_pts_receive()
725 ** for the Datum PTS to send the message back. I am (erroneously) assuming in datum_pts_receive()
732 datum_pts->lastref = datum_pts->lastrec; in datum_pts_receive()
733 refclock_receive(datum_pts->peer); in datum_pts_receive()
749 if (ftimerr < 0.0) abserr = -ftimerr; in datum_pts_receive()
751 if (datum_pts->sigma2 == 0.0) { in datum_pts_receive()
753 datum_pts->sigma2 = abserr*abserr; in datum_pts_receive()
755 datum_pts->sigma2 = DATUM_MAX_ERROR2; in datum_pts_receive()
759 datum_pts->sigma2 = 0.95*datum_pts->sigma2 + 0.05*abserr*abserr; in datum_pts_receive()
761 datum_pts->sigma2 = 0.95*datum_pts->sigma2 + 0.05*DATUM_MAX_ERROR2; in datum_pts_receive()
773 datum_pts->day, in datum_pts_receive()
774 datum_pts->hour, in datum_pts_receive()
775 datum_pts->minute, in datum_pts_receive()
776 datum_pts->second, in datum_pts_receive()
777 datum_pts->msec, in datum_pts_receive()