From 09f1d5cf1046962c85eeddf97f21ca03eadd95a0 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 9 Sep 2006 07:58:01 +0000 Subject: The big dead-storage elimination: we get rid of the newdata member. All regression tests pass. --- drivers.c | 6 ++-- evermore.c | 26 ++++++++--------- garmin.c | 44 ++++++++++++++--------------- geoid.c | 14 +++++----- gps.h | 1 - gpsd.c | 2 +- libgpsd_core.c | 70 +++++++++++++++++++++++----------------------- nmea_parse.c | 88 +++++++++++++++++++++++++++++----------------------------- packet.c | 22 +++++++-------- sirf.c | 76 +++++++++++++++++++++++++------------------------- tsip.c | 88 +++++++++++++++++++++++++++++----------------------------- zodiac.c | 36 ++++++++++++------------ 12 files changed, 236 insertions(+), 237 deletions(-) diff --git a/drivers.c b/drivers.c index a2cdfb20..49e903fb 100644 --- a/drivers.c +++ b/drivers.c @@ -79,10 +79,10 @@ gps_mask_t nmea_parse_input(struct gps_device_t *session) #ifdef NTPSHM_ENABLE /* this magic number is derived from observation */ if ((st & TIME_SET) != 0 && - (session->gpsdata.newdata.time!=session->driver.nmea.last_fixtime)) { + (session->gpsdata.fix.time!=session->driver.nmea.last_fixtime)) { /* this magic number is derived from observation */ - (void)ntpshm_put(session, session->gpsdata.newdata.time + 0.675); - session->driver.nmea.last_fixtime = session->gpsdata.newdata.time; + (void)ntpshm_put(session, session->gpsdata.fix.time + 0.675); + session->driver.nmea.last_fixtime = session->gpsdata.fix.time; } #endif /* NTPSHM_ENABLE */ return st; diff --git a/evermore.c b/evermore.c index 931cc468..6d9be0e1 100644 --- a/evermore.c +++ b/evermore.c @@ -198,7 +198,7 @@ gps_mask_t evermore_parse(struct gps_device_t *session, unsigned char *buf, size switch (getub(buf2, 1)) { case 0x02: /* Navigation Data Output */ - session->gpsdata.newdata.time = session->gpsdata.sentence_time + session->gpsdata.fix.time = session->gpsdata.sentence_time = gpstime_to_unix((int)getuw(buf2, 2), getul(buf2, 4)*0.01) - session->context->leap_seconds; ecef_to_wgs84fix(&session->gpsdata, getsl(buf2, 8)*1.0, getsl(buf2, 12)*1.0, getsl(buf2, 16)*1.0, @@ -208,16 +208,16 @@ gps_mask_t evermore_parse(struct gps_device_t *session, unsigned char *buf, size version = getuw(buf2, 27)/100.0; /* that's all the information in this packet */ if (used < 3) - session->gpsdata.newdata.mode = MODE_NO_FIX; + session->gpsdata.fix.mode = MODE_NO_FIX; else if (used == 3) - session->gpsdata.newdata.mode = MODE_2D; + session->gpsdata.fix.mode = MODE_2D; else { - session->gpsdata.newdata.mode = MODE_3D; + session->gpsdata.fix.mode = MODE_3D; mask |= ALTITUDE_SET | CLIMB_SET; } gpsd_report(4, "NDO 0x02: version %3.2f, mode=%d, status=%d, visible=%d, used=%d\n", version, - session->gpsdata.newdata.mode, + session->gpsdata.fix.mode, session->gpsdata.status, visible, used); @@ -225,7 +225,7 @@ gps_mask_t evermore_parse(struct gps_device_t *session, unsigned char *buf, size return mask; case 0x04: /* DOP Data Output */ - session->gpsdata.newdata.time = session->gpsdata.sentence_time + session->gpsdata.fix.time = session->gpsdata.sentence_time = gpstime_to_unix((int)getuw(buf2, 2), getul(buf2, 4)*0.01) - session->context->leap_seconds; session->gpsdata.gdop = (double)getub(buf2, 8)*0.1; session->gpsdata.pdop = (double)getub(buf2, 9)*0.1; @@ -236,29 +236,29 @@ gps_mask_t evermore_parse(struct gps_device_t *session, unsigned char *buf, size case 0: /* no position fix */ case 1: /* manual calls this "1D navigation" */ session->gpsdata.status = STATUS_NO_FIX; - session->gpsdata.newdata.mode = MODE_NO_FIX; + session->gpsdata.fix.mode = MODE_NO_FIX; break; case 2: /* 2D navigation */ session->gpsdata.status = STATUS_FIX; - session->gpsdata.newdata.mode = MODE_2D; + session->gpsdata.fix.mode = MODE_2D; break; case 3: /* 3D navigation */ session->gpsdata.status = STATUS_FIX; - session->gpsdata.newdata.mode = MODE_3D; + session->gpsdata.fix.mode = MODE_3D; break; case 4: /* 3D navigation with DGPS */ session->gpsdata.status = STATUS_DGPS_FIX; - session->gpsdata.newdata.mode = MODE_3D; + session->gpsdata.fix.mode = MODE_3D; break; } /* that's all the information in this packet */ gpsd_report(4, "DDO 0x04: mode=%d, status=%d\n", - session->gpsdata.newdata.mode, + session->gpsdata.fix.mode, session->gpsdata.status); return TIME_SET | DOP_SET | MODE_SET | STATUS_SET; case 0x06: /* Channel Status Output */ - session->gpsdata.newdata.time = session->gpsdata.sentence_time + session->gpsdata.fix.time = session->gpsdata.sentence_time = gpstime_to_unix((int)getuw(buf2, 2), getul(buf2, 4)*0.01) - session->context->leap_seconds; session->gpsdata.satellites = (int)getub(buf2, 8); session->gpsdata.satellites_used = 0; @@ -304,7 +304,7 @@ gps_mask_t evermore_parse(struct gps_device_t *session, unsigned char *buf, size case 0x08: /* Measurement Data Output */ // clock offset is a manufacturer diagnostic // (int)getuw(buf2, 8); clock offset, 29000..29850 ?? - session->gpsdata.newdata.time = session->gpsdata.sentence_time + session->gpsdata.fix.time = session->gpsdata.sentence_time = gpstime_to_unix((int)getuw(buf2, 2), getul(buf2, 4)*0.01) - session->context->leap_seconds; visible = getub(buf2, 10); /* FIXME: read full statellite status for each channel */ diff --git a/garmin.c b/garmin.c index 17178d2d..b0f82de2 100644 --- a/garmin.c +++ b/garmin.c @@ -312,16 +312,16 @@ static gps_mask_t PrintPacket(struct gps_device_t *session, Packet_t *pkt) session->context->valid = LEAP_SECOND_VALID; // gps_tow is always like x.999 or x.998 so just round it time_l += (time_t) round(pvt->gps_tow); - session->gpsdata.newdata.time + session->gpsdata.fix.time = session->gpsdata.sentence_time = (double)time_l; gpsd_report(5, "time_l: %ld\n", (long int)time_l); - session->gpsdata.newdata.latitude = radtodeg(pvt->lat); - session->gpsdata.newdata.longitude = radtodeg(pvt->lon); + session->gpsdata.fix.latitude = radtodeg(pvt->lat); + session->gpsdata.fix.longitude = radtodeg(pvt->lon); // altitude over WGS84 converted to MSL - session->gpsdata.newdata.altitude = pvt->alt + pvt->msl_hght; + session->gpsdata.fix.altitude = pvt->alt + pvt->msl_hght; // geoid separation from WGS 84 // gpsd sign is opposite of garmin sign @@ -329,21 +329,21 @@ static gps_mask_t PrintPacket(struct gps_device_t *session, Packet_t *pkt) // Estimated position error in meters. session->gpsdata.epe = pvt->epe * (GPSD_CONFIDENCE/2); - session->gpsdata.newdata.eph = pvt->eph * (GPSD_CONFIDENCE/2); - session->gpsdata.newdata.epv = pvt->epv * (GPSD_CONFIDENCE/2); + session->gpsdata.fix.eph = pvt->eph * (GPSD_CONFIDENCE/2); + session->gpsdata.fix.epv = pvt->epv * (GPSD_CONFIDENCE/2); // convert lat/lon to knots - session->gpsdata.newdata.speed + session->gpsdata.fix.speed = hypot(pvt->lon_vel, pvt->lat_vel) * 1.9438445; // keep climb in meters/sec - session->gpsdata.newdata.climb = pvt->alt_vel; + session->gpsdata.fix.climb = pvt->alt_vel; track = atan2(pvt->lon_vel, pvt->lat_vel); if (track < 0) { track += 2 * PI; } - session->gpsdata.newdata.track = radtodeg(track); + session->gpsdata.fix.track = radtodeg(track); switch ( pvt->fix) { case 0: @@ -351,43 +351,43 @@ static gps_mask_t PrintPacket(struct gps_device_t *session, Packet_t *pkt) default: // no fix session->gpsdata.status = STATUS_NO_FIX; - session->gpsdata.newdata.mode = MODE_NO_FIX; + session->gpsdata.fix.mode = MODE_NO_FIX; break; case 2: // 2D fix session->gpsdata.status = STATUS_FIX; - session->gpsdata.newdata.mode = MODE_2D; + session->gpsdata.fix.mode = MODE_2D; break; case 3: // 3D fix session->gpsdata.status = STATUS_FIX; - session->gpsdata.newdata.mode = MODE_3D; + session->gpsdata.fix.mode = MODE_3D; break; case 4: // 2D Differential fix session->gpsdata.status = STATUS_DGPS_FIX; - session->gpsdata.newdata.mode = MODE_2D; + session->gpsdata.fix.mode = MODE_2D; break; case 5: // 3D differential fix session->gpsdata.status = STATUS_DGPS_FIX; - session->gpsdata.newdata.mode = MODE_3D; + session->gpsdata.fix.mode = MODE_3D; break; } #ifdef NTPSHM_ENABLE - if (session->gpsdata.newdata.mode > MODE_NO_FIX) - (void) ntpshm_put(session, session->gpsdata.newdata.time); + if (session->gpsdata.fix.mode > MODE_NO_FIX) + (void) ntpshm_put(session, session->gpsdata.fix.time); #endif /* NTPSHM_ENABLE */ gpsd_report(4, "Appl, mode %d, status %d\n" - , session->gpsdata.newdata.mode + , session->gpsdata.fix.mode , session->gpsdata.status); - gpsd_report(3, "UTC Time: %lf\n", session->gpsdata.newdata.time); + gpsd_report(3, "UTC Time: %lf\n", session->gpsdata.fix.time); gpsd_report(3, "Geoid Separation (MSL - WGS84): from garmin %lf, calculated %lf\n" , -pvt->msl_hght - , wgs84_separation(session->gpsdata.newdata.latitude - , session->gpsdata.newdata.longitude)); + , wgs84_separation(session->gpsdata.fix.latitude + , session->gpsdata.fix.longitude)); gpsd_report(3, "Alt: %.3f, Epe: %.3f, Eph: %.3f, Epv: %.3f, Fix: %d, Gps_tow: %f, Lat: %.3f, Lon: %.3f, LonVel: %.3f, LatVel: %.3f, AltVel: %.3f, MslHgt: %.3f, Leap: %d, GarminDays: %ld\n" , pvt->alt , pvt->epe @@ -395,8 +395,8 @@ static gps_mask_t PrintPacket(struct gps_device_t *session, Packet_t *pkt) , pvt->epv , pvt->fix , pvt->gps_tow - , session->gpsdata.newdata.latitude - , session->gpsdata.newdata.longitude + , session->gpsdata.fix.latitude + , session->gpsdata.fix.longitude , pvt->lon_vel , pvt->lat_vel , pvt->alt_vel diff --git a/geoid.c b/geoid.c index c04bea95..8e575361 100644 --- a/geoid.c +++ b/geoid.c @@ -92,20 +92,20 @@ void ecef_to_wgs84fix(struct gps_data_t *gpsdata, phi = atan2(z + e_2*b*pow(sin(theta),3),p - e2*a*pow(cos(theta),3)); n = a / sqrt(1.0 - e2*pow(sin(phi),2)); h = p / cos(phi) - n; - gpsdata->newdata.latitude = phi * RAD_2_DEG; - gpsdata->newdata.longitude = lambda * RAD_2_DEG; - gpsdata->separation = wgs84_separation(gpsdata->newdata.latitude, gpsdata->newdata.longitude); - gpsdata->newdata.altitude = h - gpsdata->separation; + gpsdata->fix.latitude = phi * RAD_2_DEG; + gpsdata->fix.longitude = lambda * RAD_2_DEG; + gpsdata->separation = wgs84_separation(gpsdata->fix.latitude, gpsdata->fix.longitude); + gpsdata->fix.altitude = h - gpsdata->separation; /* velocity computation */ vnorth = -vx*sin(phi)*cos(lambda)-vy*sin(phi)*sin(lambda)+vz*cos(phi); veast = -vx*sin(lambda)+vy*cos(lambda); - gpsdata->newdata.climb = vx*cos(phi)*cos(lambda)+vy*cos(phi)*sin(lambda)+vz*sin(phi); - gpsdata->newdata.speed = sqrt(pow(vnorth,2) + pow(veast,2)); + gpsdata->fix.climb = vx*cos(phi)*cos(lambda)+vy*cos(phi)*sin(lambda)+vz*sin(phi); + gpsdata->fix.speed = sqrt(pow(vnorth,2) + pow(veast,2)); heading = atan2(veast,vnorth); /*@ +evalorder @*/ if (heading < 0) heading += 2 * PI; - gpsdata->newdata.track = heading * RAD_2_DEG; + gpsdata->fix.track = heading * RAD_2_DEG; } #ifdef TESTMAIN diff --git a/gps.h b/gps.h index 18564e62..210471e5 100644 --- a/gps.h +++ b/gps.h @@ -210,7 +210,6 @@ struct gps_data_t { */ struct gps_fix_t fix; /* accumulated PVT data */ - struct gps_fix_t newdata; /* PVT data from last packet */ double separation; /* Geoidal separation, MSL - WGS84 (Meters) */ diff --git a/gpsd.c b/gpsd.c index 67940ae0..c444eea1 100644 --- a/gpsd.c +++ b/gpsd.c @@ -1565,7 +1565,7 @@ int main(int argc, char *argv[]) gps_clear_fix(&sub->fixbuffer); gps_merge_fix(&sub->fixbuffer, changed, - &sub->device->gpsdata.newdata); + &sub->device->gpsdata.fix); gpsd_error_model(sub->device, &sub->fixbuffer, &sub->oldfix); } diff --git a/libgpsd_core.c b/libgpsd_core.c index 4b0aad67..211b1391 100644 --- a/libgpsd_core.c +++ b/libgpsd_core.c @@ -61,7 +61,7 @@ void gpsd_init(struct gps_device_t *session, struct gps_context_t *context, char /*@ +temptrans @*/ /*@ +mayaliasunique @*/ /*@ +mustfreeonly @*/ - gps_clear_fix(&session->gpsdata.newdata); + gps_clear_fix(&session->gpsdata.fix); session->gpsdata.set &=~ (FIX_SET | DOP_SET); session->gpsdata.hdop = NAN; session->gpsdata.vdop = NAN; @@ -129,7 +129,7 @@ static void *gpsd_ppsmonitor(void *arg) } /*@ +boolint @*/ - if (session->gpsdata.newdata.mode > MODE_NO_FIX) { + if (session->gpsdata.fix.mode > MODE_NO_FIX) { /* * The PPS pulse is normally a short pulse with a frequency of * 1 Hz, and the UTC second is defined by the front edge. But we @@ -174,9 +174,9 @@ int gpsd_activate(struct gps_device_t *session) session->retry_counter = 0; gpsd_report(1, "gpsd_activate: opened GPS (%d)\n", session->gpsdata.gps_fd); // session->gpsdata.online = 0; - session->gpsdata.newdata.mode = MODE_NOT_SEEN; + session->gpsdata.fix.mode = MODE_NOT_SEEN; session->gpsdata.status = STATUS_NO_FIX; - session->gpsdata.newdata.track = NAN; + session->gpsdata.fix.track = NAN; session->gpsdata.separation = NAN; #ifdef BINARY_ENABLE session->mag_var = NAN; @@ -223,30 +223,30 @@ void gpsd_position_fix_dump(struct gps_device_t *session, struct tm tm; time_t intfixtime; - intfixtime = (time_t)session->gpsdata.newdata.time; + intfixtime = (time_t)session->gpsdata.fix.time; (void)gmtime_r(&intfixtime, &tm); - if (session->gpsdata.newdata.mode > 1) { + if (session->gpsdata.fix.mode > 1) { (void)snprintf(bufp, len, "$GPGGA,%02d%02d%02d,%09.4f,%c,%010.4f,%c,%d,%02d,", tm.tm_hour, tm.tm_min, tm.tm_sec, - degtodm(fabs(session->gpsdata.newdata.latitude)), - ((session->gpsdata.newdata.latitude > 0) ? 'N' : 'S'), - degtodm(fabs(session->gpsdata.newdata.longitude)), - ((session->gpsdata.newdata.longitude > 0) ? 'E' : 'W'), - session->gpsdata.newdata.mode, + degtodm(fabs(session->gpsdata.fix.latitude)), + ((session->gpsdata.fix.latitude > 0) ? 'N' : 'S'), + degtodm(fabs(session->gpsdata.fix.longitude)), + ((session->gpsdata.fix.longitude > 0) ? 'E' : 'W'), + session->gpsdata.fix.mode, session->gpsdata.satellites_used); if (isnan(session->gpsdata.hdop)) (void)strlcat(bufp, ",", len); else (void)snprintf(bufp+strlen(bufp), len-strlen(bufp), "%.2f,",session->gpsdata.hdop); - if (isnan(session->gpsdata.newdata.altitude)) + if (isnan(session->gpsdata.fix.altitude)) (void)strlcat(bufp, ",", len); else (void)snprintf(bufp+strlen(bufp), len-strlen(bufp), - "%.1f,M,", session->gpsdata.newdata.altitude); + "%.1f,M,", session->gpsdata.fix.altitude); if (isnan(session->gpsdata.separation)) (void)strlcat(bufp, ",", len); else @@ -271,7 +271,7 @@ static void gpsd_transit_fix_dump(struct gps_device_t *session, struct tm tm; time_t intfixtime; - intfixtime = (time_t)session->gpsdata.newdata.time; + intfixtime = (time_t)session->gpsdata.fix.time; (void)gmtime_r(&intfixtime, &tm); /*@ -usedef @*/ (void)snprintf(bufp, len, @@ -280,12 +280,12 @@ static void gpsd_transit_fix_dump(struct gps_device_t *session, tm.tm_min, tm.tm_sec, session->gpsdata.status ? 'A' : 'V', - degtodm(fabs(session->gpsdata.newdata.latitude)), - ((session->gpsdata.newdata.latitude > 0) ? 'N' : 'S'), - degtodm(fabs(session->gpsdata.newdata.longitude)), - ((session->gpsdata.newdata.longitude > 0) ? 'E' : 'W'), - session->gpsdata.newdata.speed * MPS_TO_KNOTS, - session->gpsdata.newdata.track, + degtodm(fabs(session->gpsdata.fix.latitude)), + ((session->gpsdata.fix.latitude > 0) ? 'N' : 'S'), + degtodm(fabs(session->gpsdata.fix.longitude)), + ((session->gpsdata.fix.longitude > 0) ? 'E' : 'W'), + session->gpsdata.fix.speed * MPS_TO_KNOTS, + session->gpsdata.fix.track, tm.tm_mday, tm.tm_mon + 1, tm.tm_year % 100); @@ -354,7 +354,7 @@ static void gpsd_binary_quality_dump(struct gps_device_t *session, char *bufp2 = bufp; (void)snprintf(bufp, len-strlen(bufp), - "$GPGSA,%c,%d,", 'A', session->gpsdata.newdata.mode); + "$GPGSA,%c,%d,", 'A', session->gpsdata.fix.mode); j = 0; for (i = 0; i < session->device_type->channels; i++) { if (session->gpsdata.used[i]) { @@ -370,7 +370,7 @@ static void gpsd_binary_quality_dump(struct gps_device_t *session, } bufp += strlen(bufp); #define ZEROIZE(x) (isnan(x)!=0 ? 0.0 : x) - if (session->gpsdata.newdata.mode == MODE_NO_FIX) + if (session->gpsdata.fix.mode == MODE_NO_FIX) (void)strlcat(bufp, ",,,", len); else (void)snprintf(bufp, len-strlen(bufp), @@ -380,14 +380,14 @@ static void gpsd_binary_quality_dump(struct gps_device_t *session, ZEROIZE(session->gpsdata.vdop)); nmea_add_checksum(bufp2); bufp += strlen(bufp); - if (finite(session->gpsdata.newdata.eph) - || finite(session->gpsdata.newdata.epv) + if (finite(session->gpsdata.fix.eph) + || finite(session->gpsdata.fix.epv) || finite(session->gpsdata.epe)) { /* output PGRME only if realistic */ (void)snprintf(bufp, len-strlen(bufp), "$PGRME,%.2f,%.2f,%.2f", - ZEROIZE(session->gpsdata.newdata.eph), - ZEROIZE(session->gpsdata.newdata.epv), + ZEROIZE(session->gpsdata.fix.eph), + ZEROIZE(session->gpsdata.fix.epv), ZEROIZE(session->gpsdata.epe)); nmea_add_checksum(bufp); } @@ -486,19 +486,19 @@ void gpsd_error_model(struct gps_device_t *session, gps_mask_t gpsd_poll(struct gps_device_t *session) /* update the stuff in the scoreboard structure */ { - ssize_t newdata; + ssize_t newlen; - gps_clear_fix(&session->gpsdata.newdata); + gps_clear_fix(&session->gpsdata.fix); if (session->inbuflen==0) session->gpsdata.d_xmit_time = timestamp(); /* can we get a full packet from the device? */ if (session->device_type) { - newdata = session->device_type->get_packet(session); + newlen = session->device_type->get_packet(session); session->gpsdata.d_xmit_time = timestamp(); } else { - newdata = packet_get(session); + newlen = packet_get(session); session->gpsdata.d_xmit_time = timestamp(); gpsd_report(3, "packet sniff finds type %d\n", @@ -546,11 +546,11 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) } /* update the scoreboard structure from the GPS */ - gpsd_report(7, "GPS sent %d new characters\n", newdata); - if (newdata == -1) { /* read error */ + gpsd_report(7, "GPS sent %d new characters\n", newlen); + if (newlen == -1) { /* read error */ session->gpsdata.online = 0; return 0; - } else if (newdata == 0) { /* no new data */ + } else if (newlen == 0) { /* no new data */ if (session->device_type != NULL && timestamp()>session->gpsdata.online+session->device_type->cycle+1){ gpsd_report(3, "GPS is offline (%lf sec since data)\n", timestamp() - session->gpsdata.online); @@ -574,7 +574,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) session->gpsdata.sentence_length = session->outbuflen; session->gpsdata.d_recv_time = timestamp(); - /* Get data from current packet into the newdata structure */ + /* Get data from current packet into the fix structure */ if (session->device_type != NULL && session->device_type->parse_packet!=NULL) received = session->device_type->parse_packet(session); else @@ -584,7 +584,7 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) * Compute fix-quality data from the satellite positions. * This may be overridden by DOPs reported from the packet we just got. */ - if (session->gpsdata.newdata.mode > MODE_NO_FIX + if (session->gpsdata.fix.mode > MODE_NO_FIX && (session->gpsdata.set & SATELLITE_SET) != 0 && session->gpsdata.satellites > 0) { dopmask = dop(&session->gpsdata); diff --git a/nmea_parse.c b/nmea_parse.c index 60d10fc0..032360e0 100644 --- a/nmea_parse.c +++ b/nmea_parse.c @@ -32,8 +32,8 @@ static void do_lat_lon(char *field[], struct gps_data_t *out) p = field[1]; if (*p == 'S') lat = -lat; - if (out->newdata.latitude != lat) - out->newdata.latitude = lat; + if (out->fix.latitude != lat) + out->fix.latitude = lat; updated++; } if (*(p = field[2]) != '\0') { @@ -45,8 +45,8 @@ static void do_lat_lon(char *field[], struct gps_data_t *out) p = field[3]; if (*p == 'W') lon = -lon; - if (out->newdata.longitude != lon) - out->newdata.longitude = lon; + if (out->fix.longitude != lon) + out->fix.longitude = lon; updated++; } } @@ -126,8 +126,8 @@ static gps_mask_t processGPRMC(int count, char *field[], struct gps_device_t *se session->gpsdata.status = STATUS_NO_FIX; mask |= STATUS_SET; } - if (session->gpsdata.newdata.mode >= MODE_2D) { - session->gpsdata.newdata.mode = MODE_NO_FIX; + if (session->gpsdata.fix.mode >= MODE_2D) { + session->gpsdata.fix.mode = MODE_NO_FIX; mask |= MODE_SET; } /* set something nz, so it won't look like an unknown sentence */ @@ -137,28 +137,28 @@ static gps_mask_t processGPRMC(int count, char *field[], struct gps_device_t *se merge_ddmmyy(field[9], session); merge_hhmmss(field[1], session); mask |= TIME_SET; - session->gpsdata.newdata.time = (double)mkgmtime(&session->driver.nmea.date)+session->driver.nmea.subseconds; - if (session->gpsdata.sentence_time != session->gpsdata.newdata.time) + session->gpsdata.fix.time = (double)mkgmtime(&session->driver.nmea.date)+session->driver.nmea.subseconds; + if (session->gpsdata.sentence_time != session->gpsdata.fix.time) mask |= CYCLE_START_SET; - session->gpsdata.sentence_time = session->gpsdata.newdata.time; + session->gpsdata.sentence_time = session->gpsdata.fix.time; } do_lat_lon(&field[3], &session->gpsdata); mask |= LATLON_SET; - session->gpsdata.newdata.speed = atof(field[7]) * KNOTS_TO_MPS; - session->gpsdata.newdata.track = atof(field[8]); + session->gpsdata.fix.speed = atof(field[7]) * KNOTS_TO_MPS; + session->gpsdata.fix.track = atof(field[8]); mask |= (TRACK_SET | SPEED_SET); /* * This copes with GPSes like the Magellan EC-10X that *only* emit * GPRMC. In this case we set mode and status here so the client * code that relies on them won't mistakenly believe it has never - * received a newdata. + * received a fix. */ if (session->gpsdata.status == STATUS_NO_FIX) { session->gpsdata.status = STATUS_FIX; /* could be DGPS_FIX, we can't tell */ mask |= STATUS_SET; } - if (session->gpsdata.newdata.mode < MODE_2D) { - session->gpsdata.newdata.mode = MODE_2D; + if (session->gpsdata.fix.mode < MODE_2D) { + session->gpsdata.fix.mode = MODE_2D; mask |= MODE_SET; } } @@ -204,10 +204,10 @@ static gps_mask_t processGPGLL(int count, char *field[], struct gps_device_t *se gpsd_report(1, "can't use GGA/GGL time until after ZDA or RMC has supplied a year.\n"); else { mask = TIME_SET; - session->gpsdata.newdata.time = (double)mkgmtime(&session->driver.nmea.date)+session->driver.nmea.subseconds; - if (session->gpsdata.sentence_time != session->gpsdata.newdata.time) + session->gpsdata.fix.time = (double)mkgmtime(&session->driver.nmea.date)+session->driver.nmea.subseconds; + if (session->gpsdata.sentence_time != session->gpsdata.fix.time) mask |= CYCLE_START_SET; - session->gpsdata.sentence_time = session->gpsdata.newdata.time; + session->gpsdata.sentence_time = session->gpsdata.fix.time; } do_lat_lon(&field[1], &session->gpsdata); mask |= LATLON_SET; @@ -250,17 +250,17 @@ static gps_mask_t processGPGGA(int c UNUSED, char *field[], struct gps_device_t mask = STATUS_SET; if (session->gpsdata.status > STATUS_NO_FIX) { char *altitude; - double oldfixtime = session->gpsdata.newdata.time; + double oldfixtime = session->gpsdata.fix.time; merge_hhmmss(field[1], session); if (session->driver.nmea.date.tm_year == 0) gpsd_report(1, "can't use GGA/GGL time until after ZDA or RMC has supplied a year.\n"); else { mask |= TIME_SET; - session->gpsdata.newdata.time = (double)mkgmtime(&session->driver.nmea.date)+session->driver.nmea.subseconds; - if (session->gpsdata.sentence_time != session->gpsdata.newdata.time) + session->gpsdata.fix.time = (double)mkgmtime(&session->driver.nmea.date)+session->driver.nmea.subseconds; + if (session->gpsdata.sentence_time != session->gpsdata.fix.time) mask |= CYCLE_START_SET; - session->gpsdata.sentence_time = session->gpsdata.newdata.time; + session->gpsdata.sentence_time = session->gpsdata.fix.time; } do_lat_lon(&field[2], &session->gpsdata); mask |= LATLON_SET; @@ -272,14 +272,14 @@ static gps_mask_t processGPGGA(int c UNUSED, char *field[], struct gps_device_t * If we see this, force mode to 2D at most. */ if (altitude[0] == '\0') { - if (session->gpsdata.newdata.mode == MODE_3D) { - session->gpsdata.newdata.mode = session->gpsdata.status ? MODE_2D : MODE_NO_FIX; + if (session->gpsdata.fix.mode == MODE_3D) { + session->gpsdata.fix.mode = session->gpsdata.status ? MODE_2D : MODE_NO_FIX; mask |= MODE_SET; } } else { - double oldaltitude = session->gpsdata.newdata.altitude; + double oldaltitude = session->gpsdata.fix.altitude; - session->gpsdata.newdata.altitude = atof(altitude); + session->gpsdata.fix.altitude = atof(altitude); mask |= ALTITUDE_SET; @@ -289,17 +289,17 @@ static gps_mask_t processGPGGA(int c UNUSED, char *field[], struct gps_device_t * SiRF and Garmin chips, which might have some smoothing * going on. */ - if (isnan(oldaltitude)!=0 || session->gpsdata.newdata.time==oldfixtime) - session->gpsdata.newdata.climb = 0; + if (isnan(oldaltitude)!=0 || session->gpsdata.fix.time==oldfixtime) + session->gpsdata.fix.climb = 0; else { - session->gpsdata.newdata.climb = (session->gpsdata.newdata.altitude-oldaltitude)/(session->gpsdata.newdata.time-oldfixtime); + session->gpsdata.fix.climb = (session->gpsdata.fix.altitude-oldaltitude)/(session->gpsdata.fix.time-oldfixtime); } mask |= CLIMB_SET; } if (strlen(field[11]) > 0) { session->gpsdata.separation = atof(field[11]); } else { - session->gpsdata.separation = wgs84_separation(session->gpsdata.newdata.latitude,session->gpsdata.newdata.longitude); + session->gpsdata.separation = wgs84_separation(session->gpsdata.fix.latitude,session->gpsdata.fix.longitude); } } return mask; @@ -333,17 +333,17 @@ static gps_mask_t processGPGSA(int count, char *field[], struct gps_device_t *se if (count < 17) return ONLINE_SET; - session->gpsdata.newdata.mode = atoi(field[2]); + session->gpsdata.fix.mode = atoi(field[2]); /* * The first arm of this conditional ignores dead-reckoning * fixes from an Antaris chipset. which returns E in field 2 * for a dead-reckoning estimate. Fix by Andreas Stricker. */ - if (session->gpsdata.newdata.mode == 0 && field[2][0] == 'E') + if (session->gpsdata.fix.mode == 0 && field[2][0] == 'E') mask = 0; else mask = MODE_SET; - gpsd_report(3, "GPGSA sets mode %d\n", session->gpsdata.newdata.mode); + gpsd_report(3, "GPGSA sets mode %d\n", session->gpsdata.fix.mode); session->gpsdata.pdop = atof(field[count-3]); session->gpsdata.hdop = atof(field[count-2]); session->gpsdata.vdop = atof(field[count-1]); @@ -449,8 +449,8 @@ static gps_mask_t processPGRME(int c UNUSED, char *field[], struct gps_device_t * Garmin won't say, but the general belief is that these are 50% CEP. * We follow the advice at . */ - session->gpsdata.newdata.eph = atof(field[1]) * (GPSD_CONFIDENCE/CEP50_SIGMA); - session->gpsdata.newdata.epv = atof(field[3]) * (GPSD_CONFIDENCE/CEP50_SIGMA); + session->gpsdata.fix.eph = atof(field[1]) * (GPSD_CONFIDENCE/CEP50_SIGMA); + session->gpsdata.fix.epv = atof(field[3]) * (GPSD_CONFIDENCE/CEP50_SIGMA); session->gpsdata.epe = atof(field[5]) * (GPSD_CONFIDENCE/CEP50_SIGMA); return HERR_SET | VERR_SET | PERR_SET; } @@ -473,10 +473,10 @@ static gps_mask_t processGPZDA(int c UNUSED, char *field[], struct gps_device_t session->driver.nmea.date.tm_year = atoi(field[4]) - 1900; session->driver.nmea.date.tm_mon = atoi(field[3])-1; session->driver.nmea.date.tm_mday = atoi(field[2]); - session->gpsdata.newdata.time = (double)mkgmtime(&session->driver.nmea.date)+session->driver.nmea.subseconds; - if (session->gpsdata.sentence_time != session->gpsdata.newdata.time) + session->gpsdata.fix.time = (double)mkgmtime(&session->driver.nmea.date)+session->driver.nmea.subseconds; + if (session->gpsdata.sentence_time != session->gpsdata.fix.time) mask |= CYCLE_START_SET; - session->gpsdata.sentence_time = session->gpsdata. newdata.time; + session->gpsdata.sentence_time = session->gpsdata. fix.time; return mask; } @@ -518,20 +518,20 @@ static gps_mask_t processTNTHTM(int c UNUSED, char *field[], struct gps_device_t * Roll maps to speed. * Dip maps to altitude. */ - session->gpsdata.newdata.time = timestamp(); - session->gpsdata.newdata.track = atof(field[1]); + session->gpsdata.fix.time = timestamp(); + session->gpsdata.fix.track = atof(field[1]); session->gpsdata.headingStatus = *field[2]; - session->gpsdata.newdata.climb = atof(field[3]); + session->gpsdata.fix.climb = atof(field[3]); session->gpsdata.pitchStatus = *field[4]; - session->gpsdata.newdata.speed = atof(field[5]); + session->gpsdata.fix.speed = atof(field[5]); session->gpsdata.rollStatus = *field[6]; - session->gpsdata.newdata.altitude = atof(field[7]); + session->gpsdata.fix.altitude = atof(field[7]); session->gpsdata.horzField = atof(field[8]); - session->gpsdata.newdata.mode = MODE_2D; + session->gpsdata.fix.mode = MODE_2D; mask |= (TRACK_SET | MODE_SET | TRACK_SET | SPEED_SET | CLIMB_SET | ALTITUDE_SET); session->gpsdata.status = STATUS_FIX; /* could be DGPS_FIX */ - gpsd_report(5, "Heading %lf %c.\n", session->gpsdata.newdata.track, session->gpsdata.headingStatus); + gpsd_report(5, "Heading %lf %c.\n", session->gpsdata.fix.track, session->gpsdata.headingStatus); return mask; } #endif /* TNT_ENABLE */ diff --git a/packet.c b/packet.c index 2d64a9c2..6a8f229f 100644 --- a/packet.c +++ b/packet.c @@ -613,19 +613,19 @@ static void character_discard(struct gps_device_t *session) #define getword(i) (short)(session->inbuffer[2*(i)] | (session->inbuffer[2*(i)+1] << 8)) -ssize_t packet_parse(struct gps_device_t *session, size_t newdata) +ssize_t packet_parse(struct gps_device_t *session, size_t fix) /* grab a packet; returns either BAD_PACKET or the length */ { #ifdef STATE_DEBUG gpsd_report(6, "Read %d chars to buffer offset %d (total %d): %s\n", - newdata, + fix, session->inbuflen, - session->inbuflen+newdata, - gpsd_hexdump(session->inbufptr, newdata)); + session->inbuflen+fix, + gpsd_hexdump(session->inbufptr, fix)); #endif /* STATE_DEBUG */ session->outbuflen = 0; - session->inbuflen += newdata; + session->inbuflen += fix; while (session->inbufptr < session->inbuffer + session->inbuflen) { /*@ -modobserver @*/ unsigned char c = *session->inbufptr++; @@ -782,19 +782,19 @@ ssize_t packet_parse(struct gps_device_t *session, size_t newdata) } } /* while */ - return (ssize_t)newdata; + return (ssize_t)fix; } #undef getword ssize_t packet_get(struct gps_device_t *session) /* grab a packet; returns either BAD_PACKET or the length */ { - ssize_t newdata; + ssize_t fix; /*@ -modobserver @*/ - newdata = read(session->gpsdata.gps_fd, session->inbuffer+session->inbuflen, + fix = read(session->gpsdata.gps_fd, session->inbuffer+session->inbuflen, sizeof(session->inbuffer)-(session->inbuflen)); /*@ +modobserver @*/ - if (newdata == -1) { + if (fix == -1) { if ((errno == EAGAIN) || (errno == EINTR)) { return 0; } else { @@ -802,9 +802,9 @@ ssize_t packet_get(struct gps_device_t *session) } } - if (newdata == 0) + if (fix == 0) return 0; - return packet_parse(session, (size_t)newdata); + return packet_parse(session, (size_t)fix); } void packet_reset(struct gps_device_t *session) diff --git a/sirf.c b/sirf.c index 71dc2d47..275909c3 100644 --- a/sirf.c +++ b/sirf.c @@ -174,31 +174,31 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l /* fix status is byte 19 */ navtype = (unsigned short)getub(buf, 19); session->gpsdata.status = STATUS_NO_FIX; - session->gpsdata.newdata.mode = MODE_NO_FIX; + session->gpsdata.fix.mode = MODE_NO_FIX; if ((navtype & 0x80) != 0) session->gpsdata.status = STATUS_DGPS_FIX; else if ((navtype & 0x07) > 0 && (navtype & 0x07) < 7) session->gpsdata.status = STATUS_FIX; if ((navtype & 0x07) == 4 || (navtype & 0x07) == 6) - session->gpsdata.newdata.mode = MODE_3D; + session->gpsdata.fix.mode = MODE_3D; else if (session->gpsdata.status != 0) - session->gpsdata.newdata.mode = MODE_2D; - if (session->gpsdata.newdata.mode == MODE_3D) + session->gpsdata.fix.mode = MODE_2D; + if (session->gpsdata.fix.mode == MODE_3D) mask |= ALTITUDE_SET | CLIMB_SET; gpsd_report(4, "MND 0x02: Navtype = 0x%0x, Status = %d, mode = %d\n", - navtype,session->gpsdata.status,session->gpsdata.newdata.mode); + navtype,session->gpsdata.status,session->gpsdata.fix.mode); /* byte 20 is HDOP, see below */ /* byte 21 is "mode 2", not clear how to interpret that */ - session->gpsdata.newdata.time = session->gpsdata.sentence_time + session->gpsdata.fix.time = session->gpsdata.sentence_time = 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->gpsdata.fix.mode > MODE_NO_FIX) { if ((session->driver.sirf.time_seen & TIME_SEEN_GPS_2) == 0) gpsd_report(4, "valid time in message 0x02, seen=0x%02x\n", session->driver.sirf.time_seen); session->driver.sirf.time_seen |= TIME_SEEN_GPS_2; if (IS_HIGHEST_BIT(session->driver.sirf.time_seen,TIME_SEEN_GPS_2)) - (void)ntpshm_put(session, session->gpsdata.newdata.time + 0.8); + (void)ntpshm_put(session, session->gpsdata.fix.time + 0.8); } #endif /* NTPSHM_ENABLE */ /* fix quality data */ @@ -431,18 +431,18 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l */ navtype = (unsigned short)getuw(buf, 3); session->gpsdata.status = STATUS_NO_FIX; - session->gpsdata.newdata.mode = MODE_NO_FIX; + session->gpsdata.fix.mode = MODE_NO_FIX; if (navtype & 0x80) session->gpsdata.status = STATUS_DGPS_FIX; else if ((navtype & 0x07) > 0 && (navtype & 0x07) < 7) session->gpsdata.status = STATUS_FIX; - session->gpsdata.newdata.mode = MODE_NO_FIX; + session->gpsdata.fix.mode = MODE_NO_FIX; if ((navtype & 0x07) == 4 || (navtype & 0x07) == 6) - session->gpsdata.newdata.mode = MODE_3D; + session->gpsdata.fix.mode = MODE_3D; else if (session->gpsdata.status) - session->gpsdata.newdata.mode = MODE_2D; + session->gpsdata.fix.mode = MODE_2D; gpsd_report(4, "GNI 0x29: Navtype = 0x%0x, Status = %d, mode = %d\n", - navtype, session->gpsdata.status, session->gpsdata.newdata.mode); + navtype, session->gpsdata.status, session->gpsdata.fix.mode); /* * UTC is left all zeros in 231 and older firmware versions, * and misdocumented in the Protocol Reference (version 1.4). @@ -463,31 +463,31 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l unpacked_date.tm_sec = 0; subseconds = getuw(buf, 17)*1e-3; /*@ -compdef */ - session->gpsdata.newdata.time = session->gpsdata.sentence_time + session->gpsdata.fix.time = session->gpsdata.sentence_time = (double)mktime(&unpacked_date)+subseconds; /*@ +compdef */ - gpsd_report(5, "MID 41 UTC: %lf\n", session->gpsdata.newdata.time); + gpsd_report(5, "MID 41 UTC: %lf\n", session->gpsdata.fix.time); #ifdef NTPSHM_ENABLE - if (session->gpsdata.newdata.mode > MODE_NO_FIX && unpacked_date.tm_year != 0) { + if (session->gpsdata.fix.mode > MODE_NO_FIX && unpacked_date.tm_year != 0) { if ((session->driver.sirf.time_seen & TIME_SEEN_UTC_1) == 0) gpsd_report(4, "valid time in message 0x29, seen=0x%02x\n", session->driver.sirf.time_seen); session->driver.sirf.time_seen |= TIME_SEEN_UTC_1; if (IS_HIGHEST_BIT(session->driver.sirf.time_seen,TIME_SEEN_UTC_1)) - (void)ntpshm_put(session, session->gpsdata.newdata.time + 0.8); + (void)ntpshm_put(session, session->gpsdata.fix.time + 0.8); } #endif /* NTPSHM_ENABLE */ /* skip 4 bytes of satellite map */ - session->gpsdata.newdata.latitude = getsl(buf, 23)*1e-7; - session->gpsdata.newdata.longitude = getsl(buf, 27)*1e-7; + session->gpsdata.fix.latitude = getsl(buf, 23)*1e-7; + session->gpsdata.fix.longitude = getsl(buf, 27)*1e-7; /* skip 4 bytes of altitude from ellipsoid */ mask = TIME_SET | LATLON_SET | STATUS_SET | MODE_SET; - session->gpsdata.newdata.altitude = getsl(buf, 31)*1e-2; + session->gpsdata.fix.altitude = getsl(buf, 31)*1e-2; /* skip 1 byte of map datum */ - session->gpsdata.newdata.speed = getsw(buf, 36)*1e-2; - session->gpsdata.newdata.track = getsw(buf, 38)*1e-2; + session->gpsdata.fix.speed = getsw(buf, 36)*1e-2; + session->gpsdata.fix.track = getsw(buf, 38)*1e-2; /* skip 2 bytes of magnetic variation */ - session->gpsdata.newdata.climb = getsw(buf, 42)*1e-2; + session->gpsdata.fix.climb = getsw(buf, 42)*1e-2; /* HDOP should be available at byte 89, but in 231 it's zero. */ mask |= SPEED_SET | TRACK_SET | CLIMB_SET | CYCLE_START_SET; session->gpsdata.sentence_length = 91; @@ -531,7 +531,7 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l unpacked_date.tm_mon = (int)getub(buf, 5) - 1; unpacked_date.tm_year = (int)getuw(buf, 6) - 1900; /*@ -compdef */ - session->gpsdata.newdata.time = session->gpsdata.sentence_time + session->gpsdata.fix.time = session->gpsdata.sentence_time = (double)mktime(&unpacked_date); /*@ +compdef */ session->context->leap_seconds = (int)getuw(buf, 8); @@ -542,7 +542,7 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l session->driver.sirf.time_seen); session->driver.sirf.time_seen |= TIME_SEEN_UTC_2; if (IS_HIGHEST_BIT(session->driver.sirf.time_seen,TIME_SEEN_UTC_2)) - (void)ntpshm_put(session, session->gpsdata.newdata.time + 0.3); + (void)ntpshm_put(session, session->gpsdata.fix.time + 0.3); #endif /* NTPSHM_ENABLE */ mask |= TIME_SET; } @@ -552,27 +552,27 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l /* this packet is only sent by uBlox firmware from version 1.32 */ mask = LATLON_SET | ALTITUDE_SET | SPEED_SET | TRACK_SET | CLIMB_SET | STATUS_SET | MODE_SET | HDOP_SET | VDOP_SET | PDOP_SET; - session->gpsdata.newdata.latitude = getsl(buf, 1) * RAD_2_DEG * 1e-8; - session->gpsdata.newdata.longitude = getsl(buf, 5) * RAD_2_DEG * 1e-8; - session->gpsdata.separation = wgs84_separation(session->gpsdata.newdata.latitude, session->gpsdata.newdata.longitude); - session->gpsdata.newdata.altitude = getsl(buf, 9) * 1e-3 - session->gpsdata.separation; - session->gpsdata.newdata.speed = getsl(buf, 13) * 1e-3; - session->gpsdata.newdata.climb = getsl(buf, 17) * 1e-3; - session->gpsdata.newdata.track = getsl(buf, 21) * RAD_2_DEG * 1e-8; + session->gpsdata.fix.latitude = getsl(buf, 1) * RAD_2_DEG * 1e-8; + session->gpsdata.fix.longitude = getsl(buf, 5) * RAD_2_DEG * 1e-8; + session->gpsdata.separation = wgs84_separation(session->gpsdata.fix.latitude, session->gpsdata.fix.longitude); + session->gpsdata.fix.altitude = getsl(buf, 9) * 1e-3 - session->gpsdata.separation; + session->gpsdata.fix.speed = getsl(buf, 13) * 1e-3; + session->gpsdata.fix.climb = getsl(buf, 17) * 1e-3; + session->gpsdata.fix.track = getsl(buf, 21) * RAD_2_DEG * 1e-8; navtype = (unsigned short)getub(buf, 25); session->gpsdata.status = STATUS_NO_FIX; - session->gpsdata.newdata.mode = MODE_NO_FIX; + session->gpsdata.fix.mode = MODE_NO_FIX; if (navtype & 0x80) session->gpsdata.status = STATUS_DGPS_FIX; else if ((navtype & 0x07) > 0 && (navtype & 0x07) < 7) session->gpsdata.status = STATUS_FIX; if ((navtype & 0x07) == 4 || (navtype & 0x07) == 6) - session->gpsdata.newdata.mode = MODE_3D; + session->gpsdata.fix.mode = MODE_3D; else if (session->gpsdata.status) - session->gpsdata.newdata.mode = MODE_2D; + session->gpsdata.fix.mode = MODE_2D; gpsd_report(4, "EMND 0x62: Navtype = 0x%0x, Status = %d, mode = %d\n", - navtype, session->gpsdata.status, session->gpsdata.newdata.mode); + navtype, session->gpsdata.status, session->gpsdata.fix.mode); if (navtype & 0x40) { /* UTC corrected timestamp? */ struct tm unpacked_date; @@ -586,7 +586,7 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l unpacked_date.tm_sec = 0; subseconds = ((unsigned short)getuw(buf, 32))*1e-3; /*@ -compdef */ - session->gpsdata.newdata.time = session->gpsdata.sentence_time + session->gpsdata.fix.time = session->gpsdata.sentence_time = (double)mkgmtime(&unpacked_date)+subseconds; /*@ +compdef */ #ifdef NTPSHM_ENABLE @@ -595,7 +595,7 @@ gps_mask_t sirf_parse(struct gps_device_t *session, unsigned char *buf, size_t l session->driver.sirf.time_seen); session->driver.sirf.time_seen |= TIME_SEEN_UTC_2; if (IS_HIGHEST_BIT(session->driver.sirf.time_seen,TIME_SEEN_UTC_2)) - (void)ntpshm_put(session, session->gpsdata.newdata.time + 0.8); + (void)ntpshm_put(session, session->gpsdata.fix.time + 0.8); #endif /* NTPSHM_ENABLE */ session->context->valid |= LEAP_SECOND_VALID; } diff --git a/tsip.c b/tsip.c index c17429ff..689ddbb3 100644 --- a/tsip.c +++ b/tsip.c @@ -262,17 +262,17 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session) case 0x4a: /* Single-Precision Position LLA */ if (len != 20) break; - session->gpsdata.newdata.latitude = getf(buf,0) * RAD_2_DEG; - session->gpsdata.newdata.longitude = getf(buf,4) * RAD_2_DEG; - session->gpsdata.newdata.altitude = getf(buf,8); + session->gpsdata.fix.latitude = getf(buf,0) * RAD_2_DEG; + session->gpsdata.fix.longitude = getf(buf,4) * RAD_2_DEG; + session->gpsdata.fix.altitude = getf(buf,8); f1 = getf(buf,12); /* clock bias */ f2 = getf(buf,16); /* time-of-fix */ if (session->driver.tsip.gps_week) { - session->gpsdata.newdata.time = session->gpsdata.sentence_time = + session->gpsdata.fix.time = session->gpsdata.sentence_time = gpstime_to_unix((int)session->driver.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); + gpsd_report(4, "GPS LLA %f %f %f\n",session->gpsdata.fix.latitude,session->gpsdata.fix.longitude,session->gpsdata.fix.altitude); mask |= LATLON_SET | ALTITUDE_SET | CYCLE_START_SET; break; case 0x4b: /* Machine/Code ID and Additional Status */ @@ -326,12 +326,12 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session) f3 = getf(buf,8); /* Up velocity */ f4 = getf(buf,12); /* clock bias rate */ f5 = getf(buf,16); /* time-of-fix */ - session->gpsdata.newdata.climb = f3; + session->gpsdata.fix.climb = f3; /*@ -evalorder @*/ - session->gpsdata.newdata.speed = sqrt(pow(f2,2) + pow(f1,2)); + session->gpsdata.fix.speed = sqrt(pow(f2,2) + pow(f1,2)); /*@ +evalorder @*/ - if ((session->gpsdata.newdata.track = atan2(f1,f2) * RAD_2_DEG) < 0) - session->gpsdata.newdata.track += 360.0; + if ((session->gpsdata.fix.track = atan2(f1,f2) * RAD_2_DEG) < 0) + session->gpsdata.fix.track += 360.0; gpsd_report(4, "GPS Velocity ENU %f %f %f %f %f\n",f1,f2,f3,f4,f5); mask |= SPEED_SET | TRACK_SET | CLIMB_SET; break; @@ -401,15 +401,15 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session) { case 3: //session->gpsdata.status = STATUS_FIX; - session->gpsdata.newdata.mode = MODE_2D; + session->gpsdata.fix.mode = MODE_2D; break; case 4: //session->gpsdata.status = STATUS_FIX; - session->gpsdata.newdata.mode = MODE_3D; + session->gpsdata.fix.mode = MODE_3D; break; default: //session->gpsdata.status = STATUS_NO_FIX; - session->gpsdata.newdata.mode = MODE_NO_FIX; + session->gpsdata.fix.mode = MODE_NO_FIX; break; } session->gpsdata.satellites_used = count; @@ -430,7 +430,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session) /*@ -charint @*/ gpsd_report(4, "Sat info: %d %f %f %f %f %f %d:%s\n", - session->gpsdata.newdata.mode, session->gpsdata.pdop, + session->gpsdata.fix.mode, session->gpsdata.pdop, session->gpsdata.hdop, session->gpsdata.vdop, session->gpsdata.tdop, session->gpsdata.gdop, session->gpsdata.satellites_used,buf2); @@ -475,17 +475,17 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session) case 0x84: /* Double-Precision LLA Position Fix and Bias Information */ if (len != 36) break; - session->gpsdata.newdata.latitude = getd(buf,0) * RAD_2_DEG; - session->gpsdata.newdata.longitude = getd(buf,8) * RAD_2_DEG; - session->gpsdata.newdata.altitude = getd(buf,16); + session->gpsdata.fix.latitude = getd(buf,0) * RAD_2_DEG; + session->gpsdata.fix.longitude = getd(buf,8) * RAD_2_DEG; + session->gpsdata.fix.altitude = getd(buf,16); d1 = getd(buf,24); /* clock bias */ f1 = getf(buf,32); /* time-of-fix */ if (session->driver.tsip.gps_week) { - session->gpsdata.newdata.time = session->gpsdata.sentence_time = + session->gpsdata.fix.time = session->gpsdata.sentence_time = gpstime_to_unix((int)session->driver.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); + gpsd_report(4, "GPS DP LLA %f %f %f\n",session->gpsdata.fix.latitude,session->gpsdata.fix.longitude,session->gpsdata.fix.altitude); mask |= LATLON_SET | ALTITUDE_SET | CYCLE_START_SET; break; case 0x8f: /* Super Packet. Well... */ @@ -532,27 +532,27 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session) d5 = 0.005; d1 = s1 * d5; /* east velocity m/s */ d2 = s2 * d5; /* north velocity m/s */ - session->gpsdata.newdata.climb = s3 * d5; /* up velocity m/s */ + session->gpsdata.fix.climb = s3 * d5; /* up velocity m/s */ /*@ -evalorder @*/ - session->gpsdata.newdata.speed = sqrt(pow(d2,2) + pow(d1,2)); + session->gpsdata.fix.speed = sqrt(pow(d2,2) + pow(d1,2)); /*@ +evalorder @*/ - if ((session->gpsdata.newdata.track = atan2(d1,d2) * RAD_2_DEG) < 0) - session->gpsdata.newdata.track += 360.0; - session->gpsdata.newdata.latitude = sl1 * SEMI_2_DEG; - if ((session->gpsdata.newdata.longitude = ul2 * SEMI_2_DEG) > 180.0) - session->gpsdata.newdata.longitude -= 360.0; - session->gpsdata.separation = wgs84_separation(session->gpsdata.newdata.latitude, session->gpsdata.newdata.longitude); - session->gpsdata.newdata.altitude = sl2 * 1e-3 - session->gpsdata.separation;; + if ((session->gpsdata.fix.track = atan2(d1,d2) * RAD_2_DEG) < 0) + session->gpsdata.fix.track += 360.0; + session->gpsdata.fix.latitude = sl1 * SEMI_2_DEG; + if ((session->gpsdata.fix.longitude = ul2 * SEMI_2_DEG) > 180.0) + session->gpsdata.fix.longitude -= 360.0; + session->gpsdata.separation = wgs84_separation(session->gpsdata.fix.latitude, session->gpsdata.fix.longitude); + session->gpsdata.fix.altitude = sl2 * 1e-3 - session->gpsdata.separation;; session->gpsdata.status = STATUS_NO_FIX; - session->gpsdata.newdata.mode = MODE_NO_FIX; + session->gpsdata.fix.mode = MODE_NO_FIX; if ((u2 & 0x01) == (u_int8_t)0) { /* Fix Available */ session->gpsdata.status = STATUS_FIX; if ((u2 & 0x02) != (u_int8_t)0) /* DGPS Corrected */ session->gpsdata.status = STATUS_DGPS_FIX; if ((u2 & 0x04) != (u_int8_t)0) /* Fix Dimension */ - session->gpsdata.newdata.mode = MODE_2D; + session->gpsdata.fix.mode = MODE_2D; else - session->gpsdata.newdata.mode = MODE_3D; + session->gpsdata.fix.mode = MODE_3D; } session->gpsdata.satellites_used = (int)u3; if ((int)u4 > 10) { @@ -560,7 +560,7 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session) session->context->valid |= LEAP_SECOND_VALID; } session->driver.tsip.gps_week = s4; - session->gpsdata.newdata.time = session->gpsdata.sentence_time = + session->gpsdata.fix.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; break; @@ -583,36 +583,36 @@ static gps_mask_t tsip_analyze(struct gps_device_t *session) session->context->leap_seconds = (int)u1; session->context->valid |= LEAP_SECOND_VALID; } - session->gpsdata.newdata.time = session->gpsdata.sentence_time = + session->gpsdata.fix.time = session->gpsdata.sentence_time = gpstime_to_unix((int)s1, ul1 * 1e-3) - session->context->leap_seconds; session->gpsdata.status = STATUS_NO_FIX; - session->gpsdata.newdata.mode = MODE_NO_FIX; + session->gpsdata.fix.mode = MODE_NO_FIX; if ((u2 & 0x01) == (u_int8_t)0) { /* Fix Available */ session->gpsdata.status = STATUS_FIX; if ((u2 & 0x02) != (u_int8_t)0) /* DGPS Corrected */ session->gpsdata.status = STATUS_DGPS_FIX; if ((u2 & 0x04) != (u_int8_t)0) /* Fix Dimension */ - session->gpsdata.newdata.mode = MODE_2D; + session->gpsdata.fix.mode = MODE_2D; else - session->gpsdata.newdata.mode = MODE_3D; + session->gpsdata.fix.mode = MODE_3D; } - session->gpsdata.newdata.latitude = sl1 * SEMI_2_DEG; - if ((session->gpsdata.newdata.longitude = ul2 * SEMI_2_DEG) > 180.0) - session->gpsdata.newdata.longitude -= 360.0; - session->gpsdata.separation = wgs84_separation(session->gpsdata.newdata.latitude, session->gpsdata.newdata.longitude); - session->gpsdata.newdata.altitude = sl3 * 1e-3 - session->gpsdata.separation;; + session->gpsdata.fix.latitude = sl1 * SEMI_2_DEG; + if ((session->gpsdata.fix.longitude = ul2 * SEMI_2_DEG) > 180.0) + session->gpsdata.fix.longitude -= 360.0; + session->gpsdata.separation = wgs84_separation(session->gpsdata.fix.latitude, session->gpsdata.fix.longitude); + session->gpsdata.fix.altitude = sl3 * 1e-3 - session->gpsdata.separation;; if ((u2 & 0x20) != (u_int8_t)0) /* check velocity scaling */ d5 = 0.02; else d5 = 0.005; d1 = s2 * d5; /* east velocity m/s */ d2 = s3 * d5; /* north velocity m/s */ - session->gpsdata.newdata.climb = s4 * d5; /* up velocity m/s */ + session->gpsdata.fix.climb = s4 * d5; /* up velocity m/s */ /*@ -evalorder @*/ - session->gpsdata.newdata.speed = sqrt(pow(d2,2) + pow(d1,2)) * MPS_TO_KNOTS; + session->gpsdata.fix.speed = sqrt(pow(d2,2) + pow(d1,2)) * MPS_TO_KNOTS; /*@ +evalorder @*/ - if ((session->gpsdata.newdata.track = atan2(d1,d2) * RAD_2_DEG) < 0) - session->gpsdata.newdata.track += 360.0; + if ((session->gpsdata.fix.track = atan2(d1,d2) * RAD_2_DEG) < 0) + session->gpsdata.fix.track += 360.0; mask |= TIME_SET | LATLON_SET | ALTITUDE_SET | SPEED_SET | TRACK_SET | CLIMB_SET | STATUS_SET | MODE_SET | CYCLE_START_SET; break; default: diff --git a/zodiac.c b/zodiac.c index 8a6a118a..3461aadf 100644 --- a/zodiac.c +++ b/zodiac.c @@ -144,9 +144,9 @@ static gps_mask_t handle1000(struct gps_device_t *session) /*@ -boolops -predboolothers @*/ session->gpsdata.status = (getword(10) & 0x1c) ? 0 : 1; if (session->gpsdata.status != 0) - session->gpsdata.newdata.mode = (getword(10) & 1) ? MODE_2D : MODE_3D; + session->gpsdata.fix.mode = (getword(10) & 1) ? MODE_2D : MODE_3D; else - session->gpsdata.newdata.mode = MODE_NO_FIX; + session->gpsdata.fix.mode = MODE_NO_FIX; /*@ +boolops -predboolothers @*/ /* solution_type = getword(11); */ @@ -163,42 +163,42 @@ static gps_mask_t handle1000(struct gps_device_t *session) unpacked_date.tm_sec = (int)getword(24); subseconds = (int)getlong(25) / 1e9; /*@ -compdef */ - session->gpsdata.newdata.time = session->gpsdata.sentence_time = + session->gpsdata.fix.time = session->gpsdata.sentence_time = (double)mkgmtime(&unpacked_date) + subseconds; /*@ +compdef */ #ifdef NTPSHM_ENABLE - if (session->gpsdata.newdata.mode > MODE_NO_FIX) - (void)ntpshm_put(session, session->gpsdata.newdata.time + 1.1); + if (session->gpsdata.fix.mode > MODE_NO_FIX) + (void)ntpshm_put(session, session->gpsdata.fix.time + 1.1); #endif /*@ -type @*/ - session->gpsdata.newdata.latitude = ((long)getlong(27)) * RAD_2_DEG * 1e-8; - session->gpsdata.newdata.longitude = ((long)getlong(29)) * RAD_2_DEG * 1e-8; + session->gpsdata.fix.latitude = ((long)getlong(27)) * RAD_2_DEG * 1e-8; + session->gpsdata.fix.longitude = ((long)getlong(29)) * RAD_2_DEG * 1e-8; /* * The Rockwell Jupiter TU30-D140 reports altitude as uncorrected height * above WGS84 geoid. The Zodiac binary protocol manual does not * specify whether word 31 is geodetic or WGS 84. */ - session->gpsdata.newdata.altitude = ((long)getlong(31)) * 1e-2; + session->gpsdata.fix.altitude = ((long)getlong(31)) * 1e-2; /*@ +type @*/ session->gpsdata.separation = ((short)getword(33)) * 1e-2; - session->gpsdata.newdata.altitude -= session->gpsdata.separation; - session->gpsdata.newdata.speed = (int)getlong(34) * 1e-2; - session->gpsdata.newdata.track = (int)getword(36) * RAD_2_DEG * 1e-3; + session->gpsdata.fix.altitude -= session->gpsdata.separation; + session->gpsdata.fix.speed = (int)getlong(34) * 1e-2; + session->gpsdata.fix.track = (int)getword(36) * RAD_2_DEG * 1e-3; session->mag_var = ((short)getword(37)) * RAD_2_DEG * 1e-4; - session->gpsdata.newdata.climb = ((short)getword(38)) * 1e-2; + session->gpsdata.fix.climb = ((short)getword(38)) * 1e-2; /* map_datum = getword(39); */ /* manual says these are 1-sigma */ - session->gpsdata.newdata.eph = (int)getlong(40) * 1e-2 * GPSD_CONFIDENCE; - session->gpsdata.newdata.epv = (int)getlong(42) * 1e-2 * GPSD_CONFIDENCE; - session->gpsdata.newdata.ept = (int)getlong(44) * 1e-2 * GPSD_CONFIDENCE; - session->gpsdata.newdata.eps = (int)getword(46) * 1e-2 * GPSD_CONFIDENCE; + session->gpsdata.fix.eph = (int)getlong(40) * 1e-2 * GPSD_CONFIDENCE; + session->gpsdata.fix.epv = (int)getlong(42) * 1e-2 * GPSD_CONFIDENCE; + session->gpsdata.fix.ept = (int)getlong(44) * 1e-2 * GPSD_CONFIDENCE; + session->gpsdata.fix.eps = (int)getword(46) * 1e-2 * GPSD_CONFIDENCE; /* clock_bias = (int)getlong(47) * 1e-2; */ /* clock_bias_sd = (int)getlong(49) * 1e-2; */ /* clock_drift = (int)getlong(51) * 1e-2; */ /* clock_drift_sd = (int)getlong(53) * 1e-2; */ #if 0 - gpsd_report(1, "date: %lf\n", session->gpsdata.newdata.time); + gpsd_report(1, "date: %lf\n", session->gpsdata.fix.time); gpsd_report(1, " solution invalid:\n"); gpsd_report(1, " altitude: %d\n", (getword(10) & 1) ? 1 : 0); gpsd_report(1, " no diff gps: %d\n", (getword(10) & 2) ? 1 : 0); @@ -320,7 +320,7 @@ static void handle1005(struct gps_device_t *session UNUSED) gpsd_report(1, "iode mismatch:%d\n", (getword(13+i) & 4096) ? 1 : 0); } #endif - if (session->gpsdata.newdata.mode == MODE_NO_FIX) + if (session->gpsdata.fix.mode == MODE_NO_FIX) session->gpsdata.status = STATUS_NO_FIX; else if (numcorrections == 0) session->gpsdata.status = STATUS_FIX; -- cgit v1.2.1