diff options
-rw-r--r-- | ntpshm.c | 6 | ||||
-rw-r--r-- | srec.5 | 2 |
2 files changed, 7 insertions, 1 deletions
@@ -118,6 +118,7 @@ int ntpshm_put(struct gps_device_t *session, double fixtime) struct shmTime *shmTime = NULL; struct timeval tv; double seconds,microseconds; + double offset; if (session->shmTime < 0 || (shmTime = session->context->shmTime[session->shmTime]) == NULL) @@ -126,14 +127,19 @@ int ntpshm_put(struct gps_device_t *session, double fixtime) (void)gettimeofday(&tv,NULL); microseconds = 1000000.0 * modf(fixtime,&seconds); + offset = fabs(fixtime - (tv.tv_sec + (tv.tv_usec / 1000000.0))); + shmTime->count++; shmTime->clockTimeStampSec = (time_t)seconds; shmTime->clockTimeStampUSec = (int)microseconds; shmTime->receiveTimeStampSec = (time_t)tv.tv_sec; shmTime->receiveTimeStampUSec = tv.tv_usec; + shmTime->precision = offset != 0 ? (int)(ceil(log(offset) / M_LN2)) : -20; shmTime->count++; shmTime->valid = 1; + gpsd_report(5, "ntpshm_put: precision %d\n",shmTime->precision); + return 1; } @@ -224,7 +224,7 @@ There isn't any evidence that Motorola ever made use of the header information w The Unix manual page on S\-records is the only place that a 78\-byte limit on total record length or 64\-byte limit on data length is documented\&. These values shouldn't be trusted for the general case\&. .TP \(bu -The count field can have values in the range of 0x3 (2 bytes of address + 1 byte checksum = 3, a not very useful record) to 0xff; this is the count of remaining character pairs, including checksum\&. +The count field can have values in the range of 0x3 (2 bytes of address + 1 byte checksum = 3, a not very useful record) to 0xff; this is the count of remaining character \fIpairs\fR, including checksum\&. .TP \(bu If you write code to convert S\-Records, you should always assume that a record can be as long as 514 (decimal) characters in length (255 * 2 = 510, plus 4 characters for the type and count fields), plus any terminating character(s)\&. That is, in establishing an input buffer in C, you would declare it to be an array of 515 chars, thus leaving room for the terminating null character\&. |