Lines Matching +full:up +full:-
37 * refclock_palisade - clock driver for the Trimble Palisade GPS
46 * Sven-Thorsten Dietrich
49 * Sunnyvale, CA 94088-3642
57 * E-mail: fernandoph@iar.unlp.edu.ar
101 palisade_start, /* start up driver */
113 #define CLK_TYPE(x) ((int)(((x)->ttl) & 0x7F))
133 * sendcmd - Build data packet for sending
141 *buffer->data = DLE;
142 *(buffer->data + 1) = (unsigned char)c;
143 buffer->size = 2;
147 * sendsupercmd - Build super data packet for sending
156 *buffer->data = DLE;
157 *(buffer->data + 1) = (unsigned char)c1;
158 *(buffer->data + 2) = (unsigned char)c2;
159 buffer->size = 3;
163 * sendbyte -
172 *(buffer->data+buffer->size++) = DLE;
173 *(buffer->data+buffer->size++) = (unsigned char)b;
177 * sendint -
190 * sendetx - Send packet or super packet to the device
200 *(buffer->data+buffer->size++) = DLE;
201 *(buffer->data+buffer->size++) = ETX;
202 result = write(fd, buffer->data, (unsigned long)buffer->size);
204 if (result != -1)
207 return (-1);
211 * init_thunderbolt - Prepares Thunderbolt receiver to be used with
229 /* activate packets 0x8F-AB and 0x8F-AC */
238 * init_acutime - Prepares Acutime Receiver to be used with NTP
245 /* Disable all outputs, Enable Event-Polling on PortA so
263 * init_resolution - Prepares Resolution receiver to be used with NTP
285 /* activate packets 0x8F-AB and 0x8F-AC */
294 * palisade_start - open the devices and initialize data for processing
302 struct palisade_unit *up;
315 fd = refclock_open(&peer->srcadr, gpsdev, speed, LDISC_RAW);
342 up = emalloc_zero(sizeof(*up));
344 up->type = CLK_TYPE(peer);
345 switch (up->type) {
385 if (tcsetattr(fd, TCSANOW, &tio) == -1) {
391 free(up);
395 pp = peer->procptr;
396 pp->io.clock_recv = palisade_io;
397 pp->io.srcclock = peer;
398 pp->io.datalen = 0;
399 pp->io.fd = fd;
400 if (!io_addclock(&pp->io)) {
405 pp->io.fd = -1;
406 free(up);
413 pp->unitptr = up;
414 pp->clockdesc = DESCRIPTION;
416 peer->precision = PRECISION;
417 peer->sstclktype = CTL_SST_TS_UHF;
418 peer->minpoll = TRMB_MINPOLL;
419 peer->maxpoll = TRMB_MAXPOLL;
420 memcpy((char *)&pp->refid, REFID, 4);
422 up->leap_status = 0;
423 up->unit = (short) unit;
424 up->rpt_status = TSIP_PARSED_EMPTY;
425 up->rpt_cnt = 0;
427 if (up->type == CLK_THUNDERBOLT)
429 if (up->type == CLK_ACUTIME)
431 if (up->type == CLK_RESOLUTION)
439 * palisade_shutdown - shut down the clock
447 struct palisade_unit *up;
449 pp = peer->procptr;
450 up = pp->unitptr;
451 if (-1 != pp->io.fd)
452 io_closeclock(&pp->io);
453 if (NULL != up)
454 free(up);
478 * after 1997-12-14 and therefore folds back in 2017, 2037,...)
480 * Returns -1 on error, day-of-month + (month * 32) othertwise.
507 /* for the paranoid: do reverse calculation and cross-check */
512 return - 1;
514 /* calculate cycle shift to base day and calculate re-folded
525 pp->day = jd.yearday;
526 pp->year = jd.year;
532 * TSIP_decode - decode the TSIP data packets
549 struct palisade_unit *up;
552 pp = peer->procptr;
553 up = pp->unitptr;
561 if ((up->type != CLK_THUNDERBOLT) &&
562 (up->type != CLK_ACUTIME ) &&
563 (up->type != CLK_RESOLUTION ) &&
564 (up->type != CLK_ACE ) &&
565 (up->type != CLK_COPERNICUS ) )
567 if ((up->rpt_buf[0] == (char) 0x41) ||
568 (up->rpt_buf[0] == (char) 0x46) ||
569 (up->rpt_buf[0] == (char) 0x54) ||
570 (up->rpt_buf[0] == (char) 0x4B) ||
571 (up->rpt_buf[0] == (char) 0x6D)) {
573 /* standard time packet - GPS time and GPS week number */
585 if ((u_char) up->rpt_buf[0] == (u_char) 0x8f) {
590 if (!((pp->sloppyclockflag & CLK_FLAG2) || event))
598 if (up->polled <= 0)
601 if (up->rpt_cnt != LENCODE_8F0B) /* check length */
613 up->unit, lat,lon,alt);
615 up->unit);
635 secfrac = secs - secint; /* 0.0 <= secfrac < 1.0 */
637 pp->nsec = (long) (secfrac * 1000000000);
640 pp->hour = secint / 3600;
642 pp->minute = secint / 60;
644 pp->second = secint % 60;
653 up->unit, mb(0) & 0xff, event, pp->hour, pp->minute,
654 pp->second, pp->nsec, (mmday >> 5), (mmday & 31), pp->year, GPS_UTC_Offset);
657 * 8F-AD's are being received
660 if (up->leap_status) {
661 up->leap_status = 0;
669 /* Palisade-NTP Packet */
671 if (up->rpt_cnt != LENCODE_NTP) /* check length */
674 up->leap_status = mb(19);
676 if (up->polled <= 0)
689 up->polled = -1;
697 up->month = (mmday >> 5); /* Save for LEAP check */
699 if ( (up->leap_status & PALISADE_LEAP_PENDING) &&
701 (6 == up->month || 12 == up->month) ) {
702 if (up->leap_status & PALISADE_UTC_TIME)
703 pp->leap = LEAP_ADDSECOND;
705 pp->leap = LEAP_DELSECOND;
707 else if (up->leap_status)
708 pp->leap = LEAP_NOWARNING;
713 pp->leap = LEAP_NOTINSYNC;
719 up->polled = -1;
723 pp->nsec = (long) (getdbl((u_char *) &mb(3))
726 pp->hour = mb(11);
727 pp->minute = mb(12);
728 pp->second = mb(13);
733 up->unit, mb(0) & 0xff, event, pp->hour, pp->minute,
734 pp->second, pp->nsec, (mmday >> 5), (mmday & 31), pp->year,
741 if (up->polled <= 0)
744 if (up->rpt_cnt != LENCODE_8FAC)/* check length */
755 up->unit, lat,lon,alt);
756 printf("TSIP_decode: unit %d\n", up->unit);
761 (6 == up->month || 12 == up->month) )
762 pp->leap = LEAP_ADDSECOND; /* we ASSUME addsecond */
764 pp->leap = LEAP_NOWARNING;
769 up->unit, mb(0) & 0xff, pp->leap);
791 printf(" POWER-UP\n");
808 if (up->rpt_cnt != LENCODE_8FAB) /* check length */
811 if (up->polled <= 0)
828 pp->leap = LEAP_NOTINSYNC;
830 up->polled = -1;
834 pp->nsec = 0;
866 printf("pp->day: %d\n", pp->day);
871 pp->hour = mb(12);
872 pp->minute = mb(11);
873 pp->second = mb(10);
879 up->unit, mb(0) & 0xff, event, pp->hour, pp->minute, pp->second,
880 pp->nsec, (mmday >> 5), (mmday & 31), pp->year);
891 else if (up->rpt_buf[0] == (u_char)0x42) {
895 else if (up->rpt_buf[0] == (u_char)0x43) {
899 else if ((up->rpt_buf[0] == PACKET_41) & (up->type == CLK_THUNDERBOLT)){
903 else if ((up->rpt_buf[0] == PACKET_41A) & (up->type == CLK_ACUTIME)) {
907 printf("GPS UTC-GPS Offset: %ld\n", (long)getlong((u_char *) &mb(6)));
913 else if ((up->rpt_buf[0] == PACKET_41) &&
914 ((up->type == CLK_ACE) || (up->type == CLK_COPERNICUS))) {
916 if ((debug > 1) && (up->type == CLK_ACE))
918 if ((debug > 1) && (up->type == CLK_COPERNICUS))
921 if (up->rpt_cnt != LENCODE_41) { /* check length */
923 up->polled = -1;
926 up->unit, up->rpt_buf[0] & 0xff, up->rpt_cnt);
930 if (up->polled <= 0)
940 up->polled = -1;
947 l_fp ugo; /* UTC-GPS offset, negative number */
948 ugo.Ul_i.Xl_i = (int32_t)-GPS_UTC_Offset;
952 pp->year = cd.year;
953 pp->day = cd.yearday;
954 pp->hour = cd.hour;
955 pp->minute = cd.minute;
956 pp->second = cd.second;
957 pp->nsec = 0;
958 pp->leap = LEAP_NOWARNING;
963 printf("GPS UTC-GPS Offset: %d\n", GPS_UTC_Offset);
965 up->unit, mb(0) & 0xff, event, pp->hour, pp->minute, pp->second,
966 pp->nsec, cd.month, cd.monthday, pp->year);
974 else if ((up->rpt_buf[0] == PACKET_46) & (up->type == CLK_ACUTIME)) {
1009 up->polled = -1;
1030 else if ((up->rpt_buf[0] == PACKET_46) && (up->type == CLK_COPERNICUS)) {
1064 up->polled = -1;
1078 else if (((up->rpt_buf[0] == (char) 0x4A) ||
1079 (up->rpt_buf[0] == (char) 0x4B) ||
1080 (up->rpt_buf[0] == (char) 0x56) ||
1081 (up->rpt_buf[0] == (char) 0x5F) ||
1082 (up->rpt_buf[0] == (char) 0x6D) ||
1083 (up->rpt_buf[0] == (char) 0x82) ||
1084 (up->rpt_buf[0] == (char) 0x84)) &&
1085 ((up->type == CLK_ACE) || (up->type == CLK_COPERNICUS))) {
1087 if ((debug > 1) && (up->type == CLK_ACE))
1088 printf("TSIP_decode: Packet 0x%2x seen in ACE III mode\n", (up->rpt_buf[0] & 0XFF));
1089 if ((debug > 1) && (up->type == CLK_COPERNICUS))
1090 printf("TSIP_decode: Packet 0x%2x seen in Copernicus II mode\n", (up->rpt_buf[0] & 0XFF));
1095 else if (up->rpt_buf[0] == 0x54)
1098 else if (up->rpt_buf[0] == PACKET_6D) {
1119 up->polled = -1;
1121 printf("TSIP_decode: unit %d: bad packet %02x-%02x event %d len %d\n",
1122 up->unit, up->rpt_buf[0] & 0xff, mb(0) & 0xff,
1123 event, up->rpt_cnt);
1129 * palisade__receive - receive data from the serial interface
1137 struct palisade_unit *up;
1143 pp = peer->procptr;
1144 up = pp->unitptr;
1148 if (up->polled <= 0)
1151 up->polled = 0; /* Poll reply received */
1152 pp->lencode = 0; /* clear time code */
1157 up->unit, pp->year, pp->day, pp->hour, pp->minute,
1158 pp->second, pp->nsec);
1167 snprintf(pp->a_lastcode, sizeof(pp->a_lastcode),
1169 pp->year, pp->day,
1170 pp->hour,pp->minute, pp->second, pp->nsec);
1171 pp->lencode = 24;
1178 up->unit);
1183 record_clock_stats(&peer->srcadr, pp->a_lastcode);
1188 up->unit, prettydate(&pp->lastrec));
1190 pp->lastref = pp->lastrec;
1196 * palisade_poll - called by the transmit procedure
1205 struct palisade_unit *up;
1208 pp = peer->procptr;
1209 up = pp->unitptr;
1211 pp->polls++;
1212 if (up->polled > 0) /* last reply never arrived or error */
1215 up->polled = 2; /* synchronous packet + 1 event */
1220 (pp->sloppyclockflag & CLK_FLAG2) ?
1224 if (pp->sloppyclockflag & CLK_FLAG2)
1227 if(up->type == CLK_PRAECIS) {
1228 if (write(peer->procptr->io.fd,"SPSTAT\r\n",8) < 0) {
1250 pp = peer->procptr;
1252 if (p + rbufp->recv_length >= sizeof buf) {
1253 struct palisade_unit *up;
1254 up = pp->unitptr;
1272 up->unit);
1282 memcpy(buf+p, rbufp->recv_buffer, rbufp->recv_length);
1283 p += rbufp->recv_length;
1286 && buf[p-2] == '\r'
1287 && buf[p-1] == '\n') {
1288 buf[p-2] = '\0';
1289 record_clock_stats(&peer->srcadr, buf);
1309 struct palisade_unit *up;
1315 peer = rbufp->recv_peer;
1316 pp = peer->procptr;
1317 up = pp->unitptr;
1319 if(up->type == CLK_PRAECIS) {
1326 c = (char *) &rbufp->recv_space;
1327 d = c + rbufp->recv_length;
1332 switch (up->rpt_status) {
1340 up->rpt_status = TSIP_PARSED_EMPTY;
1344 up->rpt_status = TSIP_PARSED_DATA;
1346 up->rpt_buf[0] = *c;
1353 up->rpt_status = TSIP_PARSED_DLE_2;
1355 mb(up->rpt_cnt++) = *c;
1360 up->rpt_status = TSIP_PARSED_DATA;
1361 mb(up->rpt_cnt++) =
1365 up->rpt_status = TSIP_PARSED_FULL;
1368 up->rpt_status = TSIP_PARSED_DLE_1;
1369 up->rpt_buf[0] = *c;
1377 up->rpt_status = TSIP_PARSED_EMPTY;
1379 up->rpt_status = TSIP_PARSED_DLE_1;
1385 if (up->rpt_status == TSIP_PARSED_DLE_1) {
1386 up->rpt_cnt = 0;
1387 if (pp->sloppyclockflag & CLK_FLAG2)
1389 get_systime(&pp->lastrec);
1391 else if (up->rpt_status == TSIP_PARSED_EMPTY)
1392 up->rpt_cnt = 0;
1394 else if (up->rpt_cnt > BMAX)
1395 up->rpt_status =TSIP_PARSED_EMPTY;
1397 if (up->rpt_status == TSIP_PARSED_FULL)
1416 struct palisade_unit *up;
1419 up = pp->unitptr;
1421 if (up->type == CLK_ACE) {
1426 sendetx (&tx, pp->io.fd);
1431 if (ioctl(pp->io.fd, TIOCMGET, &x) < 0) {
1433 up->unit));
1435 up->unit);
1436 return -1;
1442 if (up->type == CLK_ACUTIME)
1443 if (write (pp->io.fd, "", 1) != 1)
1446 up->unit);
1448 if (ioctl(pp->io.fd, TIOCMSET, &x) < 0) {
1451 printf("Palisade HW_poll: unit %d: SET \n", up->unit);
1455 up->unit);
1456 return -1;
1461 } /* (up->type != CLK_ACE) */
1464 get_systime(&pp->lastrec);
1466 if (up->type != CLK_ACE) {
1467 if (ioctl(pp->io.fd, TIOCMSET, &x) == -1) {
1470 printf("Palisade HW_poll: unit %d: UNSET \n", up->unit);
1474 up->unit);
1475 return -1;
1483 * copy/swap a big-endian palisade double into a host double
1507 /* least-significant 32 bits of double from swapped bp[4] to bp[7] */
1509 /* most-significant 32 bits from swapped bp[0] to bp[3] */
1517 * copy/swap a big-endian palisade short into a host short
1531 * copy/swap a big-endian palisade 32-bit int into a host 32-bit int
1545 * copy/swap a big-endian 32-bit single-precision floating point into a host 32-bit int
1560 exponent = (int8_t)exp_field - 127;
1563 res = (int32)(mantissa << (exponent - 23));
1565 res = (int32)(mantissa >> (23 - exponent));
1566 return sign ? -res : res;