summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--garmin.c34
-rw-r--r--gpsd.h78
-rw-r--r--libgpsd_core.c8
-rw-r--r--sirf.c58
-rw-r--r--tsip.c44
-rw-r--r--zodiac.c18
6 files changed, 126 insertions, 114 deletions
diff --git a/garmin.c b/garmin.c
index 26cf666d..912a72b9 100644
--- a/garmin.c
+++ b/garmin.c
@@ -514,9 +514,9 @@ static int GetPacket (struct gps_device_t *session )
int cnt = 0;
// int x = 0; // for debug dump
- memset( session->GarminBuffer, 0, sizeof(Packet_t));
+ memset( session->garmin.Buffer, 0, sizeof(Packet_t));
memset( &delay, 0, sizeof(delay));
- session->GarminBufferLen = 0;
+ session->garmin.BufferLen = 0;
gpsd_report(4, "GetPacket()\n");
@@ -527,10 +527,10 @@ static int GetPacket (struct gps_device_t *session )
// not optimal, but given the speed and packet nature of
// the USB not too bad for a start
ssize_t theBytesReturned = 0;
- unsigned char *buf = session->GarminBuffer;
+ unsigned char *buf = session->garmin.Buffer;
theBytesReturned = read(session->gpsdata.gps_fd
- , buf + session->GarminBufferLen
+ , buf + session->garmin.BufferLen
, ASYNC_DATA_SIZE);
if ( 0 > theBytesReturned ) {
// read error...
@@ -541,15 +541,15 @@ static int GetPacket (struct gps_device_t *session )
}
gpsd_report(5, "got %d bytes\n", theBytesReturned);
- session->GarminBufferLen += theBytesReturned;
+ session->garmin.BufferLen += theBytesReturned;
if ( 64 > theBytesReturned ) {
// zero length, or short, read is a flag for got the whole packet
break;
}
- if ( 256 <= session->GarminBufferLen ) {
+ if ( 256 <= session->garmin.BufferLen ) {
// really bad read error...
- session->GarminBufferLen = 0;
+ session->garmin.BufferLen = 0;
gpsd_report(3, "GetPacket() packet too long!\n");
break;
}
@@ -562,15 +562,15 @@ static int GetPacket (struct gps_device_t *session )
/*@ end @*/
}
// dump the individual bytes, debug only
- // for ( x = 0; x < session->GarminBufferLen; x++ ) {
- // gpsd_report(6, "p[%d] = %x\n", x, session->GarminBuffer[x]);
+ // for ( x = 0; x < session->garmin.BufferLen; x++ ) {
+ // gpsd_report(6, "p[%d] = %x\n", x, session->garmin.Buffer[x]);
// }
if ( 10 <= cnt ) {
gpsd_report(3, "GetPacket() packet too long or too slow!\n");
return -1;
}
- gpsd_report(5, "GotPacket() sz=%d \n", session->GarminBufferLen);
+ gpsd_report(5, "GotPacket() sz=%d \n", session->garmin.BufferLen);
return 0;
}
@@ -614,16 +614,16 @@ static bool garmin_probe(struct gps_device_t *session)
}
/* reset the buffer and buffer length */
- memset( session->GarminBuffer, 0, sizeof(session->GarminBuffer) );
- session->GarminBufferLen = 0;
+ memset( session->garmin.Buffer, 0, sizeof(session->garmin.Buffer) );
+ session->garmin.BufferLen = 0;
- if (sizeof(session->GarminBuffer) < sizeof(Packet_t)) {
- gpsd_report(0, "garmin_probe: Compile error, GarminBuffer too small.\n",
+ if (sizeof(session->garmin.Buffer) < sizeof(Packet_t)) {
+ gpsd_report(0, "garmin_probe: Compile error, garmin.Buffer too small.\n",
strerror(errno));
return false;
}
- buffer = session->GarminBuffer;
+ buffer = session->garmin.Buffer;
thePacket = (Packet_t*)buffer;
// set Mode 0
@@ -798,7 +798,7 @@ static bool garmin_probe(struct gps_device_t *session)
*/
static void garmin_init(struct gps_device_t *session)
{
- unsigned char *buffer = session->GarminBuffer;
+ unsigned char *buffer = session->garmin.Buffer;
Packet_t *thePacket = (Packet_t*)buffer;
bool ret;
@@ -832,7 +832,7 @@ static ssize_t garmin_get_packet(struct gps_device_t *session)
static gps_mask_t garmin_parse_input(struct gps_device_t *session)
{
- return PrintPacket(session, (Packet_t*)session->GarminBuffer);
+ return PrintPacket(session, (Packet_t*)session->garmin.Buffer);
}
/* this is everything we export */
diff --git a/gpsd.h b/gpsd.h
index 23f47b8e..0ce045a2 100644
--- a/gpsd.h
+++ b/gpsd.h
@@ -104,6 +104,7 @@ struct gps_device_t {
/* session object, encapsulates all global state */
struct gps_data_t gpsdata;
/*@relnull@*/struct gps_type_t *device_type;
+ struct gps_context_t *context;
double rtcmtime; /* timestamp of last RTCM104 correction to GPS */
struct termios ttyset, ttyset_old;
/* packet-getter internals */
@@ -122,55 +123,64 @@ struct gps_device_t {
unsigned char outbuffer[MAX_PACKET_LENGTH+1];
size_t outbuflen;
unsigned long counter;
+ double poll_times[FD_SETSIZE]; /* last daemon poll time */
+#ifdef NTPSHM_ENABLE
+ int shmTime;
+# ifdef PPS_ENABLE
+ int shmTimeP;
+# endif /* PPS_ENABLE */
+#endif /* NTPSHM_ENABLE */
#ifdef BINARY_ENABLE
struct gps_fix_t lastfix; /* use to compute uncertainties */
- unsigned int driverstate; /* for private use */
+ double mag_var; /* Magnetic variation in degrees */
+ union {
+#ifdef SIRFII_ENABLE
+ struct {
+ unsigned int driverstate; /* for private use */
#define SIRF_LT_231 0x01 /* SiRF at firmware rev < 231 */
#define SIRF_EQ_231 0x02 /* SiRF at firmware rev == 231 */
#define SIRF_GE_232 0x04 /* SiRF at firmware rev >= 232 */
#define UBLOX 0x08 /* uBlox firmware with packet 0x62 */
- double mag_var; /* Magnetic variation in degrees */
-#ifdef SIRFII_ENABLE
- unsigned long satcounter;
+ unsigned long satcounter;
+#ifdef NTPSHM_ENABLE
+ unsigned int time_seen;
+#define TIME_SEEN_GPS_1 0x01 /* Seen GPS time variant 1? */
+#define TIME_SEEN_GPS_2 0x02 /* Seen GPS time variant 2? */
+#define TIME_SEEN_UTC_1 0x04 /* Seen UTC time variant 1? */
+#define TIME_SEEN_UTC_2 0x08 /* Seen UTC time variant 2? */
+#endif /* NTPSHM_ENABLE */
+ } sirf;
#endif /* SIRFII_ENABLE */
#ifdef TSIP_ENABLE
- 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_5c;
- time_t last_6d;
+ 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_5c;
+ time_t last_6d;
+ } tsip;
#endif /* TSIP_ENABLE */
#ifdef GARMIN_ENABLE /* private housekeeping stuff for the Garmin driver */
- unsigned char GarminBuffer[4096+12]; /* Garmin packet buffer */
- size_t GarminBufferLen; /* current GarminBuffer Length */
+ struct {
+ unsigned char Buffer[4096+12]; /* Garmin packet buffer */
+ size_t BufferLen; /* current GarminBuffer Length */
+ } garmin;
#endif /* GARMIN_ENABLE */
#ifdef ZODIAC_ENABLE /* private housekeeping stuff for the Zodiac driver */
- unsigned short sn; /* packet sequence number */
- /*
- * Zodiac chipset channel status from PRWIZCH. Keep it so raw-mode
- * translation of Zodiac binary protocol can send it up to the client.
- */
+ struct {
+ unsigned short sn; /* packet sequence number */
+ /*
+ * Zodiac chipset channel status from PRWIZCH. Keep it so
+ * raw-mode translation of Zodiac binary protocol can send
+ * it up to the client.
+ */
#define ZODIAC_CHANNELS 12
- unsigned int Zs[ZODIAC_CHANNELS]; /* satellite PRNs */
- unsigned int Zv[ZODIAC_CHANNELS]; /* signal values (0-7) */
+ unsigned int Zs[ZODIAC_CHANNELS]; /* satellite PRNs */
+ unsigned int Zv[ZODIAC_CHANNELS]; /* signal values (0-7) */
+ } zodiac;
#endif /* ZODIAC_ENABLE */
+ };
#endif /* BINARY_ENABLE */
-#ifdef NTPSHM_ENABLE
- unsigned int time_seen;
-#define TIME_SEEN_GPS_1 0x01 /* Seen GPS time variant 1? */
-#define TIME_SEEN_GPS_2 0x02 /* Seen GPS time variant 2? */
-#define TIME_SEEN_UTC_1 0x04 /* Seen UTC time variant 1? */
-#define TIME_SEEN_UTC_2 0x08 /* Seen UTC time variant 2? */
-#endif /* NTPSHM_ENABLE */
- double poll_times[FD_SETSIZE]; /* last daemon poll time */
-
- struct gps_context_t *context;
-#ifdef NTPSHM_ENABLE
- int shmTime;
-# ifdef PPS_ENABLE
- int shmTimeP;
-# endif /* PPS_ENABLE */
-#endif /* NTPSHM_ENABLE */
};
#define IS_HIGHEST_BIT(v,m) (v & ~((m<<1)-1))==0
diff --git a/libgpsd_core.c b/libgpsd_core.c
index 049b5874..f77dc4dc 100644
--- a/libgpsd_core.c
+++ b/libgpsd_core.c
@@ -150,7 +150,7 @@ int gpsd_activate(struct gps_device_t *session)
else {
session->gpsdata.online = timestamp();
#ifdef SIRFII_ENABLE
- session->satcounter = 0;
+ session->sirf.satcounter = 0;
#endif /* SIRFII_ENABLE */
session->counter = 0;
gpsd_report(1, "gpsd_activate: opened GPS (%d)\n", session->gpsdata.gps_fd);
@@ -295,13 +295,15 @@ static void gpsd_binary_satellite_dump(struct gps_device_t *session,
}
#ifdef ZODIAC_ENABLE
- if (session->Zs[0] != 0) {
+ if (session->packet_type == ZODIAC_PACKET && session->zodiac.Zs[0] != 0) {
bufp += strlen(bufp);
bufp2 = bufp;
strcpy(bufp, "$PRWIZCH");
for (i = 0; i < ZODIAC_CHANNELS; i++) {
len -= snprintf(bufp+strlen(bufp), len,
- ",%02u,%X", session->Zs[i], session->Zv[i] & 0x0f);
+ ",%02u,%X",
+ session->zodiac.Zs[i],
+ session->zodiac.Zv[i] & 0x0f);
}
nmea_add_checksum(bufp2);
}
diff --git a/sirf.c b/sirf.c
index 1cc27185..9cbf771c 100644
--- a/sirf.c
+++ b/sirf.c
@@ -167,7 +167,7 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l
memset(session->gpsdata.used,0,sizeof(session->gpsdata.used));
for (i = 0; i < SIRF_CHANNELS; i++)
session->gpsdata.used[i] = (int)getub(buf, 29+i);
- if ((session->driverstate & (SIRF_GE_232 | UBLOX))==0) {
+ if ((session->sirf.driverstate & (SIRF_GE_232 | UBLOX))==0) {
/* position/velocity is bytes 1-18 */
ecef_to_wgs84fix(&session->gpsdata,
getsl(buf, 1)*1.0, getsl(buf, 5)*1.0, getsl(buf, 9)*1.0,
@@ -195,11 +195,11 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l
= gpstime_to_unix(getsw(buf, 22), getul(buf, 24)*1e-2) - session->context->leap_seconds;
#ifdef NTPSHM_ENABLE
if (session->gpsdata.newdata.mode > MODE_NO_FIX) {
- if ((session->time_seen & TIME_SEEN_GPS_2) == 0)
+ if ((session->sirf.time_seen & TIME_SEEN_GPS_2) == 0)
gpsd_report(4, "valid time in message 0x02, seen=0x%02x\n",
- session->time_seen);
- session->time_seen |= TIME_SEEN_GPS_2;
- if (IS_HIGHEST_BIT(session->time_seen,TIME_SEEN_GPS_2))
+ session->sirf.time_seen);
+ session->sirf.time_seen |= TIME_SEEN_GPS_2;
+ if (IS_HIGHEST_BIT(session->sirf.time_seen,TIME_SEEN_GPS_2))
(void)ntpshm_put(session, session->gpsdata.newdata.time + 0.8);
}
#endif /* NTPSHM_ENABLE */
@@ -241,11 +241,11 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l
session->gpsdata.satellites = st;
#ifdef NTPSHM_ENABLE
if (st > 3) {
- if ((session->time_seen & TIME_SEEN_GPS_1)==0)
+ if ((session->sirf.time_seen & TIME_SEEN_GPS_1)==0)
gpsd_report(4, "valid time in message 0x04, seen=0x%02x\n",
- session->time_seen);
- session->time_seen |= TIME_SEEN_GPS_1;
- if (IS_HIGHEST_BIT(session->time_seen,TIME_SEEN_GPS_1))
+ session->sirf.time_seen);
+ session->sirf.time_seen |= TIME_SEEN_GPS_1;
+ if (IS_HIGHEST_BIT(session->sirf.time_seen,TIME_SEEN_GPS_1))
(void)ntpshm_put(session,session->gpsdata.sentence_time+0.8);
}
#endif /* NTPSHM_ENABLE */
@@ -254,7 +254,7 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l
* rate-control command for 04, at least at firmware rev. 231,
* so we have to do our own rate-limiting here...
*/
- if ((session->satcounter++ % 5) != 0)
+ if ((session->sirf.satcounter++ % 5) != 0)
break;
gpsd_report(4, "MTD 0x04: %d satellites\n", st);
return TIME_SET | SATELLITE_SET;
@@ -266,11 +266,11 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l
gpsd_report(4, "FV 0x06: Firmware version: %s\n", buf+1);
fv = atof((char *)(buf+1));
if (fv < 231) {
- session->driverstate |= SIRF_LT_231;
+ session->sirf.driverstate |= SIRF_LT_231;
if (fv > 200)
sirfbin_mode(session, 0);
} else if (fv < 232)
- session->driverstate |= SIRF_EQ_231;
+ session->sirf.driverstate |= SIRF_EQ_231;
else {
/*@ +charint @*/
unsigned char enablemid52[] = {
@@ -280,13 +280,13 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l
/*@ -charint @*/
gpsd_report(4, "Enabling PPS message...\n");
(void)sirf_write(session->gpsdata.gps_fd, enablemid52);
- session->driverstate |= SIRF_GE_232;
+ session->sirf.driverstate |= SIRF_GE_232;
session->context->valid |= LEAP_SECOND_VALID;
}
if (strstr((char *)(buf+1), "ES"))
gpsd_report(4, "Firmware has XTrac capability\n");
- gpsd_report(4, "Driver state flags are: %0x\n", session->driverstate);
- session->time_seen = 0;
+ gpsd_report(4, "Driver state flags are: %0x\n", session->sirf.driverstate);
+ session->sirf.time_seen = 0;
if ((session->context->valid & LEAP_SECOND_VALID)==0) {
gpsd_report(4, "Enabling subframe transmission...\n");
(void)sirf_write(session->gpsdata.gps_fd, enablesubframe);
@@ -455,7 +455,7 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l
case 0x29: /* Geodetic Navigation Information */
mask = 0;
- if (session->driverstate & SIRF_GE_232) {
+ if (session->sirf.driverstate & SIRF_GE_232) {
/*
* Many versions of the SiRF protocol manual don't document
* this sentence at all. Those that do may incorrectly
@@ -512,11 +512,11 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l
gpsd_report(5, "MID 41 UTC: %lf\n", session->gpsdata.newdata.time);
#ifdef NTPSHM_ENABLE
if (session->gpsdata.newdata.mode > MODE_NO_FIX && session->gpsdata.nmea_date.tm_year != 0) {
- if ((session->time_seen & TIME_SEEN_UTC_1) == 0)
+ if ((session->sirf.time_seen & TIME_SEEN_UTC_1) == 0)
gpsd_report(4, "valid time in message 0x29, seen=0x%02x\n",
- session->time_seen);
- session->time_seen |= TIME_SEEN_UTC_1;
- if (IS_HIGHEST_BIT(session->time_seen,TIME_SEEN_UTC_1))
+ session->sirf.time_seen);
+ session->sirf.time_seen |= TIME_SEEN_UTC_1;
+ if (IS_HIGHEST_BIT(session->sirf.time_seen,TIME_SEEN_UTC_1))
(void)ntpshm_put(session, session->gpsdata.newdata.time + 0.8);
}
#endif /* NTPSHM_ENABLE */
@@ -575,11 +575,11 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l
session->context->leap_seconds = (int)getuw(buf, 8);
session->context->valid |= LEAP_SECOND_VALID;
#ifdef NTPSHM_ENABLE
- if ((session->time_seen & TIME_SEEN_UTC_2) == 0)
+ if ((session->sirf.time_seen & TIME_SEEN_UTC_2) == 0)
gpsd_report(4, "valid time in message 0x34, seen=0x%02x\n",
- session->time_seen);
- session->time_seen |= TIME_SEEN_UTC_2;
- if (IS_HIGHEST_BIT(session->time_seen,TIME_SEEN_UTC_2))
+ session->sirf.time_seen);
+ session->sirf.time_seen |= TIME_SEEN_UTC_2;
+ if (IS_HIGHEST_BIT(session->sirf.time_seen,TIME_SEEN_UTC_2))
(void)ntpshm_put(session, session->gpsdata.newdata.time + 0.3);
#endif /* NTPSHM_ENABLE */
mask |= TIME_SET;
@@ -624,11 +624,11 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l
session->gpsdata.newdata.time = session->gpsdata.sentence_time
= (double)mkgmtime(&session->gpsdata.nmea_date)+session->gpsdata.subseconds;
#ifdef NTPSHM_ENABLE
- if ((session->time_seen & TIME_SEEN_UTC_2) == 0)
+ if ((session->sirf.time_seen & TIME_SEEN_UTC_2) == 0)
gpsd_report(4, "valid time in message 0x62, seen=0x%02x\n",
- session->time_seen);
- session->time_seen |= TIME_SEEN_UTC_2;
- if (IS_HIGHEST_BIT(session->time_seen,TIME_SEEN_UTC_2))
+ session->sirf.time_seen);
+ session->sirf.time_seen |= TIME_SEEN_UTC_2;
+ if (IS_HIGHEST_BIT(session->sirf.time_seen,TIME_SEEN_UTC_2))
(void)ntpshm_put(session, session->gpsdata.newdata.time + 0.8);
#endif /* NTPSHM_ENABLE */
session->context->valid |= LEAP_SECOND_VALID;
@@ -639,7 +639,7 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l
session->gpsdata.hdop = (int)getub(buf, 36) / 5.0;
session->gpsdata.vdop = (int)getub(buf, 37) / 5.0;
session->gpsdata.tdop = (int)getub(buf, 38) / 5.0;
- session->driverstate |= UBLOX;
+ session->sirf.driverstate |= UBLOX;
return mask;
case 0xff: /* Debug messages */
diff --git a/tsip.c b/tsip.c
index 40bfdf0d..3a68cb8d 100644
--- a/tsip.c
+++ b/tsip.c
@@ -164,12 +164,12 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
case 0x41: /* GPS Time */
if (len != 10)
break;
- session->last_41 = now; /* keep timestamp for request */
+ session->tsip.last_41 = now; /* keep timestamp for request */
f1 = getf(buf,0); /* gpstime */
s1 = getsw(buf,4); /* week */
f2 = getf(buf,6); /* leap seconds */
if (f1 >= 0.0 && f2 > 10.0) {
- session->gps_week = s1;
+ session->tsip.gps_week = s1;
session->context->leap_seconds = (int)roundf(f2);
session->context->valid |= LEAP_SECOND_VALID;
@@ -247,9 +247,9 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
session->gpsdata.newdata.altitude = getf(buf,8);
f1 = getf(buf,12); /* clock bias */
f2 = getf(buf,16); /* time-of-fix */
- if (session->gps_week) {
+ if (session->tsip.gps_week) {
session->gpsdata.newdata.time = session->gpsdata.sentence_time =
- gpstime_to_unix((int)session->gps_week, f2) - session->context->leap_seconds;
+ gpstime_to_unix((int)session->tsip.gps_week, f2) - session->context->leap_seconds;
mask |= TIME_SET;
}
gpsd_report(4, "GPS LLA %f %f %f\n",session->gpsdata.newdata.latitude,session->gpsdata.newdata.longitude,session->gpsdata.newdata.altitude);
@@ -263,7 +263,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
u3 = getub(buf,2); /* Status 2 */
gpsd_report(4, "Machine ID %02x %02x %02x\n",u1,u2,u3);
#if USE_SUPERPACKET
- if ((u3 & 0x01) != (u_int8_t)0 && !session->superpkt) {
+ if ((u3 & 0x01) != (u_int8_t)0 && !session->tsip.superpkt) {
gpsd_report(2, "Switching to Super Packet mode\n");
/* set new I/O Options for Super Packet output */
@@ -272,7 +272,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
putbyte(buf,2,0x00); /* Time: GPS */
putbyte(buf,3,0x08); /* Aux: dBHz */
(void)tsip_write(session->gpsdata.gps_fd, 0x35, buf, 4);
- session->superpkt = true;
+ session->tsip.superpkt = true;
}
#endif /* USE_SUPERPACKET */
break;
@@ -321,10 +321,10 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
u1 = getub(buf,0); /* Source of information */
u2 = getub(buf,1); /* Mfg. diagnostic */
f1 = getf(buf,2); /* gps_time */
- s1 = getsw(buf,6); /* gps_week */
+ s1 = getsw(buf,6); /* tsip.gps_week */
/*@ +charint @*/
if (getub(buf,0) == 0x01) /* good current fix? */
- session->gps_week = s1;
+ session->tsip.gps_week = s1;
/*@ -charint @*/
gpsd_report(4, "Fix info %02x %02x %d %f\n",u1,u2,s1,f1);
break;
@@ -344,7 +344,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
case 0x5c: /* Satellite Tracking Status */
if (len != 24)
break;
- session->last_5c = now; /* keep timestamp for request */
+ session->tsip.last_5c = now; /* keep timestamp for request */
u1 = getub(buf,0); /* PRN */
u2 = getub(buf,1); /* chan */
u3 = getub(buf,2); /* Acquisition flag */
@@ -376,7 +376,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
count = (int)((u1 >> 4) & 0x0f);
if (len != (17 + count))
break;
- session->last_6d = now; /* keep timestamp for request */
+ session->tsip.last_6d = now; /* keep timestamp for request */
switch (u1 & 7) /* dimension */
{
case 3:
@@ -460,9 +460,9 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
session->gpsdata.newdata.altitude = getd(buf,16);
d1 = getd(buf,24); /* clock bias */
f1 = getf(buf,32); /* time-of-fix */
- if (session->gps_week) {
+ if (session->tsip.gps_week) {
session->gpsdata.newdata.time = session->gpsdata.sentence_time =
- gpstime_to_unix((int)session->gps_week, f1) - session->context->leap_seconds;
+ gpstime_to_unix((int)session->tsip.gps_week, f1) - session->context->leap_seconds;
mask |= TIME_SET;
}
gpsd_report(4, "GPS DP LLA %f %f %f\n",session->gpsdata.newdata.latitude,session->gpsdata.newdata.longitude,session->gpsdata.newdata.altitude);
@@ -502,7 +502,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
u2 = getub(buf,27); /* fix flags */
u3 = getub(buf,28); /* num svs */
u4 = getub(buf,29); /* utc offset */
- s4 = getsw(buf,30); /* gps_week */
+ s4 = getsw(buf,30); /* tsip.gps_week */
/* PRN/IODE data follows */
gpsd_report(4, "LFwEI %d %d %d %u %d %u %u %x %x %u %u %d\n",s1,s2,s3,ul1,sl1,ul2,sl2,u1,u2,u3,u4,s4);
@@ -539,7 +539,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->gps_week = s4;
+ session->tsip.gps_week = s4;
session->gpsdata.newdata.time = session->gpsdata.sentence_time =
gpstime_to_unix((int)s4, ul1 * 1e-3) - session->context->leap_seconds;
mask |= TIME_SET | LATLON_SET | ALTITUDE_SET | SPEED_SET | TRACK_SET | CLIMB_SET | STATUS_SET | MODE_SET | CYCLE_START_SET;
@@ -548,7 +548,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
if (len != 29)
break;
ul1 = getul(buf,1); /* time */
- s1 = getsw(buf,5); /* gps_week */
+ s1 = getsw(buf,5); /* tsip.gps_week */
u1 = getub(buf,7); /* utc offset */
u2 = getub(buf,8); /* fix flags */
sl1 = getsl(buf,9); /* latitude */
@@ -558,7 +558,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
s3 = getsw(buf,23); /* north velocity */
s4 = getsw(buf,25); /* up velocity */
gpsd_report(4, "CSP %u %d %u %u %d %u %d %d %d %d\n",ul1,s1,u1,u2,sl1,ul2,sl3,s2,s3,s4);
- session->gps_week = s1;
+ session->tsip.gps_week = s1;
if ((int)u1 > 10) {
session->context->leap_seconds = (int)u1;
session->context->valid |= LEAP_SECOND_VALID;
@@ -607,23 +607,23 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session)
/* see if it is time to send some request packets for reports that */
/* the receiver won't send at fixed intervals */
- if ((now - session->last_41) > 5) {
+ if ((now - session->tsip.last_41) > 5) {
/* Request Current Time */
(void)tsip_write(session->gpsdata.gps_fd, 0x21, buf, 0);
- session->last_41 = now;
+ session->tsip.last_41 = now;
}
- if ((now - session->last_6d) > 5) {
+ if ((now - session->tsip.last_6d) > 5) {
/* Request GPS Receiver Position Fix Mode */
(void)tsip_write(session->gpsdata.gps_fd, 0x24, buf, 0);
- session->last_6d = now;
+ session->tsip.last_6d = now;
}
- if ((now - session->last_5c) >= 5) {
+ if ((now - session->tsip.last_5c) >= 5) {
/* Request Current Satellite Tracking Status */
putbyte(buf,0,0x00); /* All satellites */
(void)tsip_write(session->gpsdata.gps_fd, 0x3c, buf, 1);
- session->last_5c = now;
+ session->tsip.last_5c = now;
}
return mask;
diff --git a/zodiac.c b/zodiac.c
index 9b1e7a9c..a4c7bfc2 100644
--- a/zodiac.c
+++ b/zodiac.c
@@ -82,12 +82,12 @@ static bool zodiac_speed_switch(struct gps_device_t *session, speed_t speed)
{
unsigned short data[15];
- if (session->sn++ > 32767)
- session->sn = 0;
+ if (session->zodiac.sn++ > 32767)
+ session->zodiac.sn = 0;
memset(data, 0, sizeof(data));
/* data is the part of the message starting at word 6 */
- data[0] = session->sn; /* sequence number */
+ data[0] = session->zodiac.sn; /* sequence number */
data[1] = 1; /* port 1 data valid */
data[2] = 1; /* port 1 character width (8 bits) */
data[3] = 0; /* port 1 stop bits (1 stopbit) */
@@ -106,11 +106,11 @@ static void send_rtcm(struct gps_device_t *session,
unsigned short data[34];
int n = 1 + (int)(rtcmbytes/2 + rtcmbytes%2);
- if (session->sn++ > 32767)
- session->sn = 0;
+ if (session->zodiac.sn++ > 32767)
+ session->zodiac.sn = 0;
memset(data, 0, sizeof(data));
- data[0] = session->sn; /* sequence number */
+ data[0] = session->zodiac.sn; /* sequence number */
memcpy(&data[1], rtcmbuf, rtcmbytes);
data[n] = zodiac_checksum(data, n);
@@ -230,8 +230,8 @@ static gps_mask_t handle1002(struct gps_device_t *session)
/* gps_nanoseconds = getlong(13); */
for (i = 0; i < ZODIAC_CHANNELS; i++) {
/*@ -type @*/
- session->Zv[i] = status = (int)getword(15 + (3 * i));
- session->Zs[i] = prn = (int)getword(16 + (3 * i));
+ session->zodiac.Zv[i] = status = (int)getword(15 + (3 * i));
+ session->zodiac.Zs[i] = prn = (int)getword(16 + (3 * i));
/*@ +type @*/
#if 0
gpsd_report(1, "Sat%02d:\n", i);
@@ -294,7 +294,7 @@ static void handle1005(struct gps_device_t *session UNUSED)
#if 0
int i, numcorrections = getword(12);
- gpsd_report(1, "Packet: %d\n", session->sn);
+ gpsd_report(1, "Packet: %d\n", session->zodiac.sn);
gpsd_report(1, "Station bad: %d\n", (getword(9) & 1) ? 1 : 0);
gpsd_report(1, "User disabled: %d\n", (getword(9) & 2) ? 1 : 0);
gpsd_report(1, "Station ID: %d\n", getword(10));