summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGary E. Miller <gem@rellim.com>2010-04-16 16:40:55 -0700
committerGary E. Miller <gem@rellim.com>2010-04-16 16:40:55 -0700
commit1b79d072cc4eea5b12648aba45dd33cc746174d6 (patch)
tree6118b29905130559ad15427032573cce19da59ac
parent824b564bb06ac70ac9d9b6fad3564a665ff88e2c (diff)
downloadgpsd-1b79d072cc4eea5b12648aba45dd33cc746174d6.tar.gz
Collapse various copies of gps_week into one in gps_contxt_t.
-rw-r--r--driver_italk.c3
-rw-r--r--driver_proto.c1
-rw-r--r--driver_superstar2.c4
-rw-r--r--driver_tsip.c18
-rw-r--r--driver_ubx.c10
-rw-r--r--driver_zodiac.c3
-rw-r--r--gpsd.h-tail4
7 files changed, 23 insertions, 20 deletions
diff --git a/driver_italk.c b/driver_italk.c
index 9cd2e8cf..44aa6a18 100644
--- a/driver_italk.c
+++ b/driver_italk.c
@@ -61,6 +61,7 @@ static gps_mask_t decode_itk_navfix(struct gps_device_t *session,
return mask;
gps_week = (ushort) getlesw(buf, 7 + 82);
+ session->context->gps_week = gps_week;
tow = (uint) getleul(buf, 7 + 84);
t = gpstime_to_unix((int)gps_week,
tow / 1000.0) - session->context->leap_seconds;
@@ -135,6 +136,7 @@ static gps_mask_t decode_itk_prnstatus(struct gps_device_t *session,
mask = ERROR_IS;
} else {
gps_week = (ushort) getleuw(buf, 7 + 4);
+ session->context->gps_week = gps_week;
tow = (uint) getleul(buf, 7 + 6);
t = gpstime_to_unix((int)gps_week,
tow / 1000.0) - session->context->leap_seconds;
@@ -198,6 +200,7 @@ static gps_mask_t decode_itk_utcionomodel(struct gps_device_t *session,
session->context->leap_seconds = leap;
gps_week = (ushort) getleuw(buf, 7 + 36);
+ session->context->gps_week = gps_week;
tow = (uint) getleul(buf, 7 + 38);
t = gpstime_to_unix((int)gps_week,
tow / 1000.0) - session->context->leap_seconds;
diff --git a/driver_proto.c b/driver_proto.c
index 9b4ca583..a140c640 100644
--- a/driver_proto.c
+++ b/driver_proto.c
@@ -154,6 +154,7 @@ _proto__msg_utctime(struct gps_device_t *session, unsigned char *buf, size_t dat
tow = GET_MS_TIMEOFWEEK();
gps_week = GET_WEEKNUMBER();
+ session->context->gps_week = gps_week;
session->context->leap_seconds = GET_GPS_LEAPSECONDS();
t = gpstime_to_unix(gps_week, tow/1000.0) - session->context->leap_seconds;
diff --git a/driver_superstar2.c b/driver_superstar2.c
index 9cc9623b..5e9299f7 100644
--- a/driver_superstar2.c
+++ b/driver_superstar2.c
@@ -196,8 +196,8 @@ superstar2_msg_navsol_ecef(struct gps_device_t *session,
/* extract time data */
tow = getled(buf, 4);
- session->driver.superstar2.gps_week = getleuw(buf, 12);
- tm = gpstime_to_unix((int)session->driver.superstar2.gps_week, tow) -
+ session->context->gps_week = getleuw(buf, 12);
+ tm = gpstime_to_unix((int)session->context->gps_week, tow) -
session->context->leap_seconds;
session->newdata.time = tm;
mask |= TIME_IS;
diff --git a/driver_tsip.c b/driver_tsip.c
index 3422ad4c..d080f651 100644
--- a/driver_tsip.c
+++ b/driver_tsip.c
@@ -194,7 +194,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
s1 = getbesw(buf, 4); /* week */
f2 = getbef(buf, 6); /* leap seconds */
if (f1 >= 0.0 && f2 > 10.0) {
- session->driver.tsip.gps_week = s1;
+ session->context->gps_week = s1;
session->context->leap_seconds = (int)round(f2);
session->context->valid |= LEAP_SECOND_VALID;
@@ -290,9 +290,9 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
session->newdata.altitude = getbef(buf, 8);
f1 = getbef(buf, 12); /* clock bias */
f2 = getbef(buf, 16); /* time-of-fix */
- if (session->driver.tsip.gps_week) {
+ if (session->context->gps_week) {
session->newdata.time =
- gpstime_to_unix((int)session->driver.tsip.gps_week,
+ gpstime_to_unix((int)session->context->gps_week,
f2) - session->context->leap_seconds;
mask |= TIME_IS;
}
@@ -386,7 +386,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
s1 = getbesw(buf, 6); /* tsip.gps_week */
/*@ +charint @*/
if (getub(buf, 0) == 0x01) /* good current fix? */
- session->driver.tsip.gps_week = s1;
+ session->context->gps_week = s1;
/*@ -charint @*/
gpsd_report(LOG_INF, "Fix info %02x %02x %d %f\n", u1, u2, s1, f1);
break;
@@ -551,9 +551,9 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
session->newdata.altitude = getbed(buf, 16);
d1 = getbed(buf, 24); /* clock bias */
f1 = getbef(buf, 32); /* time-of-fix */
- if (session->driver.tsip.gps_week) {
+ if (session->context->gps_week) {
session->newdata.time =
- gpstime_to_unix((int)session->driver.tsip.gps_week,
+ gpstime_to_unix((int)session->context->gps_week,
f1) - session->context->leap_seconds;
mask |= TIME_IS;
}
@@ -648,7 +648,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
session->context->leap_seconds = (int)u4;
session->context->valid |= LEAP_SECOND_VALID;
}
- session->driver.tsip.gps_week = s4;
+ session->context->gps_week = s4;
/*@ ignore @*//*@ splint is confused @ */
session->newdata.time =
gpstime_to_unix((int)s4,
@@ -684,7 +684,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
s4 = getbesw(buf, 25); /* up velocity */
gpsd_report(LOG_INF, "CSP %u %d %u %u %d %u %d %d %d %d\n", ul1,
s1, u1, u2, sl1, ul2, sl3, s2, s3, s4);
- session->driver.tsip.gps_week = s1;
+ session->context->gps_week = s1;
if ((int)u1 > 10) {
session->context->leap_seconds = (int)u1;
session->context->valid |= LEAP_SECOND_VALID;
@@ -751,7 +751,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
s1 = (short)getbeuw(buf, 5); /* week */
s2 = getbesw(buf, 7); /* leap seconds */
- session->driver.tsip.gps_week = s1;
+ session->context->gps_week = s1;
if ((int)u1 > 10) {
session->context->leap_seconds = (int)s2;
session->context->valid |= LEAP_SECOND_VALID;
diff --git a/driver_ubx.c b/driver_ubx.c
index ebbdcc1b..54792136 100644
--- a/driver_ubx.c
+++ b/driver_ubx.c
@@ -72,9 +72,9 @@ ubx_msg_nav_sol(struct gps_device_t *session, unsigned char *buf,
if ((flags & (UBX_SOL_VALID_WEEK | UBX_SOL_VALID_TIME)) != 0) {
tow = (unsigned int)getleul(buf, 0);
gw = (unsigned short)getlesw(buf, 8);
- session->driver.ubx.gps_week = gw;
+ session->context->gps_week = gw;
- t = gpstime_to_unix((int)session->driver.ubx.gps_week,
+ t = gpstime_to_unix((int)session->context->gps_week,
tow / 1000.0) - session->context->leap_seconds;
session->newdata.time = t;
mask |= TIME_IS;
@@ -172,14 +172,14 @@ ubx_msg_nav_timegps(struct gps_device_t *session, unsigned char *buf,
tow = (unsigned int)getleul(buf, 0);
gw = (unsigned int)getlesw(buf, 8);
- if (gw > session->driver.ubx.gps_week)
- session->driver.ubx.gps_week = gw;
+ if (gw > session->context->gps_week)
+ session->context->gps_week = gw;
flags = (unsigned int)getub(buf, 11);
if ((flags & 0x7) != 0)
session->context->leap_seconds = (int)getub(buf, 10);
- t = gpstime_to_unix((int)session->driver.ubx.gps_week,
+ t = gpstime_to_unix((int)session->context->gps_week,
tow / 1000.0) - session->context->leap_seconds;
session->newdata.time = t;
diff --git a/driver_zodiac.c b/driver_zodiac.c
index 9d13f6f4..1aafc90a 100644
--- a/driver_zodiac.c
+++ b/driver_zodiac.c
@@ -152,7 +152,7 @@ static gps_mask_t handle1000(struct gps_device_t *session)
/* solution_type = getzword(11); */
session->gpsdata.satellites_used = (int)getzword(12);
/* polar_navigation = getzword(13); */
- /* gps_week = getzword(14); */
+ session->context->gps_week = getzword(14);
/* gps_seconds = getzlong(15); */
/* gps_nanoseconds = getzlong(17); */
unpacked_date.tm_mday = (int)getzword(19);
@@ -252,6 +252,7 @@ static gps_mask_t handle1002(struct gps_device_t *session)
int gps_seconds = getzlong(11);
/* gps_nanoseconds = getzlong(13); */
/*@-charint@*/
+ session->context->gps_week = gps_week;
session->gpsdata.satellites_used = 0;
memset(session->gpsdata.used, 0, sizeof(session->gpsdata.used));
for (i = 0; i < ZODIAC_CHANNELS; i++) {
diff --git a/gpsd.h-tail b/gpsd.h-tail
index 408a5a8e..7df91bdb 100644
--- a/gpsd.h-tail
+++ b/gpsd.h-tail
@@ -166,6 +166,7 @@ struct gps_context_t {
double rtcmtime; /* timestamp of last RTCM104 report */
/* timekeeping */
int leap_seconds; /* Unix seconds to UTC */
+ unsigned short gps_week; /* GPS week, actually 10 bits */
int century; /* for NMEA-only devices without ZDA */
#ifdef NTPSHM_ENABLE
bool enable_ntpshm;
@@ -373,13 +374,11 @@ struct gps_device_t {
#endif /* SIRF_ENABLE */
#ifdef SUPERSTAR2_ENABLE
struct {
- unsigned short gps_week;
time_t last_iono;
} superstar2;
#endif /* SUPERSTAR2_ENABLE */
#ifdef TSIP_ENABLE
struct {
- int16_t gps_week; /* Current GPS week number */
bool superpkt; /* Super Packet mode requested */
time_t last_41; /* Timestamps for packet requests */
time_t last_48;
@@ -412,7 +411,6 @@ struct gps_device_t {
#endif /* ZODIAC_ENABLE */
#ifdef UBX_ENABLE
struct {
- unsigned int gps_week;
bool have_port_configuration;
unsigned char original_port_settings[20];
unsigned char sbas_in_use;