Lines Matching +full:up +full:-
3 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66.
41 * copied from the Oncore driver (Thanks, Poul-Henning Kamp).
42 * This code runs on SunOS 4.1.3 with ppsclock-1.6a1 and Solaris 7.
90 * gadget box and 1-PPS level converter, such as described in the
91 * Pulse-per-second (PPS) Signal Interfacing page.
111 #define PRECISION (-18) /* precision assumed (about 4 us) */
123 #define NOT_INITIALIZED -9999. /* initial pivot longitude */
191 mx4200_start, /* start up driver */
203 * mx4200_start - open the devices and initialize data for processing
211 register struct mx4200unit *up;
220 fd = refclock_open(&peer->srcadr, gpsdev, SPEED232, LDISC_PPS);
227 up = emalloc_zero(sizeof(*up));
228 pp = peer->procptr;
229 pp->io.clock_recv = mx4200_receive;
230 pp->io.srcclock = peer;
231 pp->io.datalen = 0;
232 pp->io.fd = fd;
233 if (!io_addclock(&pp->io)) {
235 pp->io.fd = -1;
236 free(up);
239 pp->unitptr = up;
244 peer->precision = PRECISION;
245 pp->clockdesc = DESCRIPTION;
246 memcpy((char *)&pp->refid, REFID, 4);
254 * mx4200_shutdown - shut down the clock
262 register struct mx4200unit *up;
265 pp = peer->procptr;
266 up = pp->unitptr;
267 if (-1 != pp->io.fd)
268 io_closeclock(&pp->io);
269 if (NULL != up)
270 free(up);
275 * mx4200_config - Configure the receiver
284 register struct mx4200unit *up;
288 pp = peer->procptr;
289 up = pp->unitptr;
298 up->sloppyclockflag = pp->sloppyclockflag;
299 if (pp->sloppyclockflag & CLK_FLAG2) {
300 up->moving = 1; /* Receiver on mobile platform */
303 up->moving = 0; /* Static Installation */
305 up->pollcnt = 2;
306 up->polled = 0;
307 up->known = 0;
308 up->avg_lat = 0.0;
309 up->avg_lon = 0.0;
310 up->avg_alt = 0.0;
311 up->central_meridian = NOT_INITIALIZED;
312 up->N_fixes = 0.0;
313 up->last_leap = 0; /* LEAP_NOWARNING */
314 up->clamp_time = current_time + (AVGING_TIME * 60 * 60);
315 up->log_time = current_time + SLEEPTIME;
317 if (time_pps_create(pp->io.fd, &up->pps_h) < 0) {
323 if (time_pps_getcap(up->pps_h, &mode) < 0) {
329 if (time_pps_getparams(up->pps_h, &up->pps_p) < 0) {
339 up->pps_p.mode = PPS_CAPTUREASSERT | PPS_TSFMT_TSPEC;
340 up->pps_p.mode &= mode; /* only set what is legal */
342 if (time_pps_setparams(up->pps_h, &up->pps_p) < 0) {
349 if (time_pps_kcbind(up->pps_h, PPS_KC_HARDPPS, PPS_CAPTUREASSERT,
371 /* pass-through control */
422 if (pp->sloppyclockflag & CLK_FLAG2)
423 up->moving = 1; /* Receiver on mobile platform */
425 up->moving = 0; /* Static Installation */
427 up->pollcnt = 2;
428 if (up->moving) {
443 /* Multi-satellite mode */
449 if (up->moving) {
469 /* pass-through control */
475 * mx4200_ref - Reconfigure unit as a reference station at a known position.
482 register struct mx4200unit *up;
488 pp = peer->procptr;
489 up = pp->unitptr;
492 if (up->moving) return;
495 * Set up to output status information in the near future
497 up->log_time = current_time + SLEEPTIME;
512 /* pass-through control */
516 * Put receiver in fully-constrained 2d nav mode
543 /* Multi-satellite mode */
546 * "000" Initialization/Mode Control - Part A
549 if (up->central_meridian != NOT_INITIALIZED) {
550 up->avg_lon += up->central_meridian;
551 if (up->avg_lon < -180.0) up->avg_lon += 360.0;
552 if (up->avg_lon > 180.0) up->avg_lon -= 360.0;
555 if (up->avg_lat >= 0.0) {
556 lat = up->avg_lat;
559 lat = up->avg_lat * (-1.0);
562 if (up->avg_lon >= 0.0) {
563 lon = up->avg_lon;
566 lon = up->avg_lon * (-1.0);
569 alt = up->avg_alt;
570 minute = (lat - (double)(int)lat) * 60.0;
572 minute = (lon - (double)(int)lon) * 60.0;
595 * mx4200_poll - mx4200 watchdog routine
603 register struct mx4200unit *up;
606 pp = peer->procptr;
607 up = pp->unitptr;
618 if (up->pollcnt > 0) {
619 up->pollcnt--;
636 up->polled = 1;
637 pp->polls++;
642 if ((up->log_time > 0) && (current_time > up->log_time)) {
643 up->log_time = 0;
657 * mx4200_receive - receive gps data
664 register struct mx4200unit *up;
674 peer = rbufp->recv_peer;
675 pp = peer->procptr;
676 up = pp->unitptr;
682 if ((pp->sloppyclockflag & CLK_FLAG2) !=
683 (up->sloppyclockflag & CLK_FLAG2)) {
684 up->sloppyclockflag = pp->sloppyclockflag;
690 up->sloppyclockflag = pp->sloppyclockflag;
695 pp->lencode = refclock_gtlin(rbufp, pp->a_lastcode, BMAX, &pp->lastrec);
700 if (pp->lencode == 0)
703 up->pollcnt = 2;
704 pp->a_lastcode[pp->lencode] = '\0';
705 record_clock_stats(&peer->srcadr, pp->a_lastcode);
707 pp->lencode, pp->a_lastcode);
711 * NMEA-0183 Standard for interfacing Marine Electronics
717 * (Start-of-Sentence Identifier)
726 * <cr><lf> Carriage-Return/Line Feed (reserved chars)
727 * (End-of-Sentence Identifier)
731 cp = pp->a_lastcode + pp->lencode - 3;
732 if (cp < pp->a_lastcode || *pp->a_lastcode != '$' || cp[0] != '*' ) {
741 ck = mx4200_cksum(&pp->a_lastcode[1], pp->lencode - 4);
753 if ((cp = strchr(pp->a_lastcode, ',')) == NULL) {
792 if (!up->known) {
802 up->N_fixes, up->avg_lat, up->avg_lon, up->avg_alt);
807 if (current_time > up->clamp_time) {
808 up->known++;
827 "mx4200_receive: multi-record: %s\n", cp);
838 * Precision timestamp is returned in pp->lastrec
862 pp->offset);
871 if (!up->polled)
882 mx4200_debug(peer, "%4d-%03d %02d:%02d:%02d at %s, %.6f\n",
883 pp->year, pp->day, pp->hour, pp->minute, pp->second,
884 prettydate(&pp->lastrec), pp->offset);
885 pp->lastref = pp->lastrec;
892 up->polled = 0;
915 * ----- --------------
921 * time mark will be valid (based on operator-specified
926 * 2 int Year: 1993-
927 * 3 int Month of Year: 1-12
928 * 4 int Day of Month: 1-31
941 * this value will be set to +1 or -1. A value of
952 struct mx4200unit *up;
959 pp = peer->procptr;
960 up = pp->unitptr;
963 sscanf(pp->a_lastcode,
970 return ("wrong rec-type");
980 return ("bad pulse-valid");
987 break; /* UTC -> ok */
1019 "mx4200_parse_t: bad date (%4d-%02d-%02d)\n",
1032 second--;
1035 minute--;
1038 hour--;
1041 day_of_month--;
1054 "mx4200_parse_t: bad julian date %d (%4d-%02d-%02d)\n",
1065 pp->leap = LEAP_NOWARNING;
1068 pp->leap = LEAP_ADDSECOND;
1070 case -1:
1071 pp->leap = LEAP_DELSECOND;
1074 pp->leap = LEAP_NOTINSYNC;
1080 if (leapsec_warn != up->last_leap ) {
1083 up->last_leap, leapsec_warn, pp->leap);
1085 up->last_leap = leapsec_warn;
1091 pp->year = year;
1092 pp->day = day_of_year;
1093 pp->hour = hour;
1094 pp->minute = minute;
1095 pp->second = second;
1100 if (!valid || pp->leap == LEAP_NOTINSYNC) {
1120 for (ck = 0; n-- > 0; cp++)
1168 if (day > day2tab[month - 1]) {
1171 for (i = 0; i < month - 1; i++)
1175 if (day > day1tab[month - 1]) {
1178 for (i = 0; i < month - 1; i++)
1192 * ----- --------------
1197 * *This sentence is intended for post-analysis
1200 * 2 float WGS-84 Lattitude (degrees, minutes)
1202 * 4 float WGS-84 Longitude (degrees, minutes)
1211 * 2 = 2-D position
1212 * 3 = 3-D position
1213 * 4 = 2-D differential position
1214 * 5 = 3-D differential position
1216 * 8 = Position known -- reference station
1217 * 9 = Position known -- Navigator
1234 struct mx4200unit *up;
1239 pp = peer->procptr;
1240 up = pp->unitptr;
1243 if (up->moving) return ("mobile platform - no pos!");
1245 sscanf ( pp->a_lastcode,
1252 return ("wrong rec-type");
1266 lat = ((int)lat) + (((lat - (int)lat)) * 1.6666666666666666);
1273 lat *= -1.0;
1283 lon = ((int)lon) + (((lon - (int)lon)) * 1.6666666666666666);
1290 lon *= -1.0;
1300 if (up->central_meridian == NOT_INITIALIZED) {
1301 up->central_meridian = lon;
1304 up->central_meridian);
1306 lon -= up->central_meridian;
1307 if (lon < -180.0) lon += 360.0;
1308 if (lon > 180.0) lon -= 360.0;
1314 up->avg_lon = (up->N_fixes * up->avg_lon) + lon;
1315 up->avg_lat = (up->N_fixes * up->avg_lat) + lat;
1316 up->avg_alt = (up->N_fixes * up->avg_alt) + alt;
1318 up->N_fixes += 1.0;
1320 up->avg_lon /= up->N_fixes;
1321 up->avg_lat /= up->N_fixes;
1322 up->avg_alt /= up->N_fixes;
1326 up->N_fixes, lat, lon, alt, up->central_meridian);
1343 * ----- --------------
1348 * ACQ = Satellite re-acquisition
1369 * ----- --------------
1375 * 0 = Auto. Constrain altitude (2-D solution) and use
1377 * not constrain altitude (3-D solution) when 4 sats
1379 * 1 = Always constrain altitude (2-D solution).
1380 * 2 = Never constrain altitude (3-D solution).
1381 * 3 = Coast. Constrain altitude (2-D solution) and use
1383 * Do not constrain altitude (3-D solution) when 4 sats
1406 * ----- --------------
1419 * ----- --------------
1436 * 4 Maximum Time Error - the maximum error (in nanoseconds) for
1438 * 5 User Time Bias - external bias in nanoseconds
1455 struct mx4200unit *up;
1458 pp = peer->procptr;
1459 up = pp->unitptr;
1461 sscanf ( pp->a_lastcode, "$PMVXG,%d", &sentence_type);
1468 "mx4200: status: %s", pp->a_lastcode);
1472 "mx4200: mode data: %s", pp->a_lastcode);
1476 "mx4200: firmware configuration: %s", pp->a_lastcode);
1480 "mx4200: time recovery parms: %s", pp->a_lastcode);
1483 return ("wrong rec-type");
1490 * Process a PPS signal, placing a timestamp in pp->lastrec.
1499 struct mx4200unit *up;
1503 pp = peer->procptr;
1504 up = pp->unitptr;
1509 temp_serial = up->pps_i.assert_sequence;
1512 if (time_pps_fetch(up->pps_h, PPS_TSFMT_TSPEC, &(up->pps_i),
1516 (unsigned long)up->pps_i.assert_sequence);
1520 if (temp_serial == up->pps_i.assert_sequence) {
1523 (unsigned long)up->pps_i.assert_sequence);
1530 if (up->lastserial + 1 != up->pps_i.assert_sequence &&
1531 up->lastserial != 0) {
1532 if (up->pps_i.assert_sequence == up->lastserial) {
1536 up->pps_i.assert_sequence - up->lastserial - 1UL);
1540 up->lastserial = up->pps_i.assert_sequence;
1543 * Return the timestamp in pp->lastrec
1546 pp->lastrec.l_ui = up->pps_i.assert_timestamp.tv_sec +
1548 pp->lastrec.l_uf = ((double)(up->pps_i.assert_timestamp.tv_nsec) *
1555 * mx4200_debug - print debug messages
1563 struct mx4200unit *up;
1568 pp = peer->procptr;
1569 up = pp->unitptr;
1597 struct mx4200unit *up;
1605 pp = peer->procptr;
1606 up = pp->unitptr;
1617 n = VSNPRINTF((cp, (size_t)(ep - cp), fmt, ap));
1619 if (n < 0 || (size_t)n >= (size_t)(ep - cp))
1624 n = SNPRINTF((cp, (size_t)(ep - cp), "*%02X\r\n", ck));
1625 if (n < 0 || (size_t)n >= (size_t)(ep - cp))
1628 m = write(pp->io.fd, buf, (unsigned)(cp - buf));