diff options
-rw-r--r-- | evermore.c | 2 | ||||
-rw-r--r-- | gps.h | 1 | ||||
-rw-r--r-- | gpsd.c | 22 | ||||
-rw-r--r-- | gpsd.h-tail | 2 | ||||
-rw-r--r-- | libgpsd_core.c | 83 | ||||
-rw-r--r-- | navcom.c | 6 | ||||
-rw-r--r-- | netlib.c | 2 | ||||
-rw-r--r-- | serial.c | 10 | ||||
-rw-r--r-- | ubx.c | 4 |
9 files changed, 70 insertions, 62 deletions
@@ -176,7 +176,7 @@ static bool evermore_write(struct gps_device_t *session, unsigned char *msg, siz gpsd_report(LOG_IO, "writing EverMore control type 0x%02x: %s\n", msg[0], gpsd_hexdump(stuffed, len)); #ifdef ALLOW_RECONFIGURE - return gpsd_write(session, stuffed, len); + return (gpsd_write(session, stuffed, len) == len); #else return 0; #endif /* ALLOW_RECONFIGURE */ @@ -221,7 +221,6 @@ struct gps_data_t { */ struct gps_fix_t fix; /* accumulated PVT data */ - struct gps_fix_t oldfix; /* previous fix for error modelling */ double separation; /* Geoidal separation, MSL - WGS84 (Meters) */ @@ -914,16 +914,16 @@ static int handle_gpsd_request(struct subscriber_t* sub, char *buf, int buflen) sub->fixbuffer.altitude); else (void)strlcat(phrase, " ?", BUFSIZ); - if (isnan(sub->device->gpsdata.fix.eph)==0) + if (isnan(sub->fixbuffer.eph)==0) (void)snprintf(phrase+strlen(phrase), sizeof(phrase)-strlen(phrase), - " %.2f", sub->device->gpsdata.fix.eph); + " %.2f", sub->fixbuffer.eph); else (void)strlcat(phrase, " ?", BUFSIZ); - if (isnan(sub->device->gpsdata.fix.epv)==0) + if (isnan(sub->fixbuffer.epv)==0) (void)snprintf(phrase+strlen(phrase), sizeof(phrase)-strlen(phrase), - " %.2f", sub->device->gpsdata.fix.epv); + " %.2f", sub->fixbuffer.epv); else (void)strlcat(phrase, " ?", BUFSIZ); if (isnan(sub->fixbuffer.track)==0) @@ -941,23 +941,23 @@ static int handle_gpsd_request(struct subscriber_t* sub, char *buf, int buflen) sub->fixbuffer.climb); else (void)strlcat(phrase, " ?", BUFSIZ); - if (isnan(sub->device->gpsdata.fix.epd)==0) + if (isnan(sub->fixbuffer.epd)==0) (void)snprintf(phrase+strlen(phrase), sizeof(phrase)-strlen(phrase), " %.4f", - sub->device->gpsdata.fix.epd); + sub->fixbuffer.epd); else (void)strlcat(phrase, " ?", BUFSIZ); - if (isnan(sub->device->gpsdata.fix.eps)==0) + if (isnan(sub->fixbuffer.eps)==0) (void)snprintf(phrase+strlen(phrase), sizeof(phrase)-strlen(phrase), - " %.2f", sub->device->gpsdata.fix.eps); + " %.2f", sub->fixbuffer.eps); else (void)strlcat(phrase, " ?", BUFSIZ); - if (isnan(sub->device->gpsdata.fix.epc)==0) + if (isnan(sub->fixbuffer.epc)==0) (void)snprintf(phrase+strlen(phrase), sizeof(phrase)-strlen(phrase), - " %.2f", sub->device->gpsdata.fix.epc); + " %.2f", sub->fixbuffer.epc); else (void)strlcat(phrase, " ?", BUFSIZ); if (sub->fixbuffer.mode > 0) @@ -1676,6 +1676,8 @@ int main(int argc, char *argv[]) gps_merge_fix(&sub->fixbuffer, changed, &sub->device->gpsdata.fix); + gpsd_error_model(sub->device, + &sub->fixbuffer, &sub->oldfix); } } } diff --git a/gpsd.h-tail b/gpsd.h-tail index 22a8f531..83317c42 100644 --- a/gpsd.h-tail +++ b/gpsd.h-tail @@ -363,7 +363,7 @@ extern void ntrip_report(struct gps_device_t *); extern void gpsd_tty_init(struct gps_device_t *); extern int gpsd_open(struct gps_device_t *); extern bool gpsd_set_raw(struct gps_device_t *); -extern bool gpsd_write(struct gps_device_t *, void const *, size_t); +extern ssize_t gpsd_write(struct gps_device_t *, void const *, size_t); extern bool gpsd_next_hunt_setting(struct gps_device_t *); extern int gpsd_switch_driver(struct gps_device_t *, char *); extern void gpsd_set_speed(struct gps_device_t *, speed_t, unsigned char, unsigned int); diff --git a/libgpsd_core.c b/libgpsd_core.c index b776bb49..89d41265 100644 --- a/libgpsd_core.c +++ b/libgpsd_core.c @@ -76,7 +76,6 @@ void gpsd_init(struct gps_device_t *session, struct gps_context_t *context, char /*@ +mayaliasunique @*/ /*@ +mustfreeonly @*/ gps_clear_fix(&session->gpsdata.fix); - gps_clear_fix(&session->gpsdata.oldfix); session->gpsdata.set &=~ (FIX_SET | DOP_SET); session->gpsdata.hdop = NAN; session->gpsdata.vdop = NAN; @@ -513,8 +512,9 @@ static void gpsd_binary_dump(struct gps_device_t *session, #endif /* BINARY_ENABLE */ -void gpsd_error_model_fixup(struct gps_device_t *session) -/* compute missing errors and derived quantities */ +void gpsd_error_model(struct gps_device_t *session, + struct gps_fix_t *fix, struct gps_fix_t *oldfix) +/* compute errors and derived quantities */ { /* * Now we compute derived quantities. This is where the tricky error- @@ -534,37 +534,42 @@ void gpsd_error_model_fixup(struct gps_device_t *session) * the GPS clock, so we put the bound of the error * in as a constant pending getting it from each driver. */ - if (isnan(session->gpsdata.fix.ept)) - session->gpsdata.fix.ept = 0.005; - + if (isnan(fix->ept)!=0) + fix->ept = 0.005; /* Other error computations depend on having a valid fix */ - if (session->gpsdata.fix.mode >= MODE_2D) { - if (isnan(session->gpsdata.fix.eph) && finite(session->gpsdata.hdop)) - session->gpsdata.fix.eph = session->gpsdata.hdop * uere; - if ((session->gpsdata.fix.mode >= MODE_3D) - && isnan(session->gpsdata.fix.epv) && finite(session->gpsdata.vdop)) - session->gpsdata.fix.epv = session->gpsdata.vdop * uere; - if (isnan(session->gpsdata.epe) && finite(session->gpsdata.vdop)) + if (fix->mode >= MODE_2D) { + if (isnan(fix->eph)!=0 && finite(session->gpsdata.hdop)!=0) + fix->eph = session->gpsdata.hdop * uere; + else + fix->eph = NAN; + if ((fix->mode >= MODE_3D) + && isnan(fix->epv)!=0 && finite(session->gpsdata.vdop)!=0) + fix->epv = session->gpsdata.vdop * uere; + else + fix->epv = NAN; + if (isnan(session->gpsdata.epe)!=0 && finite(session->gpsdata.vdop)!=0) session->gpsdata.epe = session->gpsdata.pdop * uere; + else + session->gpsdata.epe = NAN; /* * If we have a current fix and an old fix, and the packet handler * didn't set the speed error and climb error members itself, * try to compute them now. */ - if (isnan(session->gpsdata.fix.eps) && session->gpsdata.fix.time > session->gpsdata.oldfix.time) { - if (session->gpsdata.oldfix.mode > MODE_NO_FIX && session->gpsdata.fix.mode > MODE_NO_FIX) { - double t = session->gpsdata.fix.time-session->gpsdata.oldfix.time; - double e = session->gpsdata.oldfix.eph + session->gpsdata.fix.eph; - session->gpsdata.fix.eps = e/t; + if (isnan(fix->eps)!=0 && fix->time > oldfix->time) { + if (oldfix->mode > MODE_NO_FIX && fix->mode > MODE_NO_FIX) { + double t = fix->time-oldfix->time; + double e = oldfix->eph + fix->eph; + fix->eps = e/t; } } - if ((session->gpsdata.fix.mode >= MODE_3D) - && isnan(session->gpsdata.fix.epc) && session->gpsdata.fix.time > session->gpsdata.oldfix.time) { - if (session->gpsdata.oldfix.mode >= MODE_3D && session->gpsdata.fix.mode >= MODE_3D) { - double t = session->gpsdata.fix.time-session->gpsdata.oldfix.time; - double e = session->gpsdata.oldfix.epv + session->gpsdata.fix.epv; + if ((fix->mode >= MODE_3D) + && isnan(fix->epc)!=0 && fix->time > oldfix->time) { + if (oldfix->mode > MODE_3D && fix->mode > MODE_3D) { + double t = fix->time-oldfix->time; + double e = oldfix->epv + fix->epv; /* if vertical uncertainties are zero this will be too */ - session->gpsdata.fix.epc = e/t; + fix->epc = e/t; } /* * We compute a track error estinate solely from the @@ -582,26 +587,24 @@ void gpsd_error_model_fixup(struct gps_device_t *session) * garbage, throw back NaN if the distance from the previous * fix is less than the error estimate. */ - if (isnan(session->gpsdata.fix.epd)) { - if (session->gpsdata.oldfix.mode >= MODE_2D) { - double adj = earth_distance( - session->gpsdata.oldfix.latitude, session->gpsdata.oldfix.longitude, - session->gpsdata.fix.latitude, session->gpsdata.fix.longitude); - if (isnan(adj)==0 && adj > session->gpsdata.fix.eph) { - double opp = session->gpsdata.fix.eph; - double hyp = sqrt(adj*adj + opp*opp); - session->gpsdata.fix.epd = RAD_2_DEG * 2 * asin(opp / hyp); - } - } + fix->epd = NAN; + if (oldfix->mode >= MODE_2D) { + double adj = earth_distance( + oldfix->latitude, oldfix->longitude, + fix->latitude, fix->longitude); + if (isnan(adj)==0 && adj > fix->eph) { + double opp = fix->eph; + double hyp = sqrt(adj*adj + opp*opp); + fix->epd = RAD_2_DEG * 2 * asin(opp / hyp); + } } } } - session->gpsdata.set |= ERR_SET | SPEEDERR_SET | TRACKERR_SET | CLIMBERR_SET ; /* save old fix for later error computations */ /*@ -mayaliasunique @*/ - if (session->gpsdata.fix.mode >= MODE_2D) - (void)memcpy(&(session->gpsdata.oldfix), &(session->gpsdata.fix), sizeof(struct gps_fix_t)); + if (fix->mode >= MODE_2D) + (void)memcpy(oldfix, fix, sizeof(struct gps_fix_t)); /*@ +mayaliasunique @*/ } @@ -718,10 +721,8 @@ gps_mask_t gpsd_poll(struct gps_device_t *session) /* Get data from current packet into the fix structure */ received = 0; if (session->packet.type != COMMENT_PACKET) - if (session->device_type != NULL && session->device_type->parse_packet!=NULL) { + if (session->device_type != NULL && session->device_type->parse_packet!=NULL) received = session->device_type->parse_packet(session); - gpsd_error_model_fixup(session); - } /* * Compute fix-quality data from the satellite positions. @@ -94,7 +94,7 @@ static u_int8_t checksum(unsigned char *buf, size_t len) static bool navcom_send_cmd(struct gps_device_t *session, unsigned char *cmd, size_t len) { gpsd_report(LOG_RAW, "Navcom: command dump: %s\n", gpsd_hexdump(cmd, len)); - return gpsd_write(session, cmd, len); + return (gpsd_write(session, cmd, len) == (ssize_t)len); } /* Data Request */ @@ -194,6 +194,7 @@ static void navcom_probe_subtype(struct gps_device_t *session, unsigned int seq) { /* Request the following messages: */ if (seq==0) { + /*@ +charint @*/ navcom_cmd_0x1c(session, 0x01, 5); /* Blink LEDs on receiver */ navcom_cmd_0x20(session, 0xae, 0x1770); /* Identification Block - send every 10 min*/ navcom_cmd_0x20(session, 0xb1, 0x4000); /* PVT Block */ @@ -204,6 +205,7 @@ static void navcom_probe_subtype(struct gps_device_t *session, unsigned int seq) navcom_cmd_0x20(session, 0x86, 0x4000); /* Channel Status */ navcom_cmd_0x20(session, 0x83, 0x4000); /* Ionosphere and UTC Data */ navcom_cmd_0x20(session, 0xef, 0x0bb8); /* Clock Drift - send every 5 min */ + /*@ -charint @*/ } } @@ -223,6 +225,7 @@ static bool navcom_speed(struct gps_device_t *session, unsigned int speed) /* We still don't know which port we're connected to */ return false; } + /*@ +charint @*/ switch (speed) { /* NOTE - The spec says that certain baud combinations on ports A and B are not allowed, those are @@ -256,6 +259,7 @@ static bool navcom_speed(struct gps_device_t *session, unsigned int speed) /* Unsupported speed */ return false; } + /*@ -charint @*/ /* Proceed to construct our message */ port_selection = physical_port | baud; @@ -65,7 +65,9 @@ int netlib_connectsock(const char *host, const char *service, const char *protoc #ifdef IPTOS_LOWDELAY opt = IPTOS_LOWDELAY; + /*@ -unrecog @*/ (void)setsockopt(s, IPPROTO_IP, IP_TOS, &opt, sizeof opt); + /*@ +unrecog @*/ #endif #ifdef TCP_NODELAY if (type == SOCK_STREAM) @@ -201,16 +201,16 @@ void gpsd_set_speed(struct gps_device_t *session, int gpsd_open(struct gps_device_t *session) { struct stat sb; - mode_t mode = O_RDWR; + mode_t mode = (mode_t)O_RDWR; if (device_readonly || ((stat(session->gpsdata.gps_device, &sb) != -1) && ((sb.st_mode & S_IFCHR) != S_IFCHR))){ - mode = O_RDONLY; + mode = (mode_t)O_RDONLY; gpsd_report(LOG_INF, "opening read-only GPS data source at '%s'\n", session->gpsdata.gps_device); } else { gpsd_report(LOG_INF, "opening GPS data source at '%s'\n", session->gpsdata.gps_device); } - if ((session->gpsdata.gps_fd = open(session->gpsdata.gps_device, mode|O_NONBLOCK|O_NOCTTY)) < 0) { + if ((session->gpsdata.gps_fd = open(session->gpsdata.gps_device, (int)(mode|O_NONBLOCK|O_NOCTTY))) < 0) { gpsd_report(LOG_ERROR, "device open failed: %s - retrying read-only\n", strerror(errno)); if ((session->gpsdata.gps_fd = open(session->gpsdata.gps_device, O_RDONLY|O_NONBLOCK|O_NOCTTY)) < 0) { gpsd_report(LOG_ERROR, "read-only device open failed: %s\n", strerror(errno)); @@ -260,7 +260,7 @@ int gpsd_open(struct gps_device_t *session) return session->gpsdata.gps_fd; } -bool gpsd_write(struct gps_device_t *session, void const *buf, size_t len) +ssize_t gpsd_write(struct gps_device_t *session, void const *buf, size_t len) { ssize_t status; bool ok; @@ -271,7 +271,7 @@ bool gpsd_write(struct gps_device_t *session, void const *buf, size_t len) (void)tcdrain(session->gpsdata.gps_fd); /* no test here now, always print as hex */ gpsd_report(LOG_IO, "=> GPS: %s%s\n", gpsd_hexdump(buf, len), ok?"":" FAILED"); - return ok; + return status; } /* @@ -45,9 +45,9 @@ ubx_msg_nav_sol(struct gps_device_t *session, unsigned char *buf, size_t data_le flags = getub(buf, 11); mask = ONLINE_SET; - if (flags & (UBX_SOL_VALID_WEEK |UBX_SOL_VALID_TIME)){ + if ((flags & (UBX_SOL_VALID_WEEK |UBX_SOL_VALID_TIME)) != 0){ tow = getul(buf, 0); - gw = getsw(buf, 8); + gw = (unsigned short)getsw(buf, 8); gps_week = gw; t = gpstime_to_unix(gps_week, tow/1000.0) - session->context->leap_seconds; |