summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ntpshm.c6
-rw-r--r--srec.52
2 files changed, 7 insertions, 1 deletions
diff --git a/ntpshm.c b/ntpshm.c
index cbfdeaf3..957470f9 100644
--- a/ntpshm.c
+++ b/ntpshm.c
@@ -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;
}
diff --git a/srec.5 b/srec.5
index af235b0c..4c89fc4c 100644
--- a/srec.5
+++ b/srec.5
@@ -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\&.