if (_gps->io.conn > RCVR_OFF)
gps_conn_set_state(_gps, RCVR_OFF);
gps_disconnect(_gps);
- track_add(NULL, FALSE);
+ track_add(NULL);
_speed_excess=FALSE;
}
if (_enable_gps==FALSE)
/* Move mark to new location. */
map_refresh_mark();
_gps->data.time=time(NULL);
-track_add(&_gps->data, FALSE);
+track_add(&_gps->data);
return TRUE;
}
if (token && *token == 'A') {
/* Data is valid. */
if (gps->io.conn != RCVR_FIXED) {
- newly_fixed = TRUE;
+ gps->data.newly_fixed = TRUE;
gps_conn_set_state(gps, RCVR_FIXED);
+ } else {
+ gps->data.newly_fixed = FALSE;
}
} else {
/* Data is invalid - not enough satellites?. */
}
gps_data_integerize(&gps->data);
-
- if ((gps->io.conn==RCVR_FIXED) && (gps->update_location!=NULL)) {
- gps->update_location(gps, newly_fixed);
- }
gps->data.lheading=gps->data.heading;
}
{
g_assert(gps);
-g_debug("NMEA: %s", gps->io.nmea);
+g_debug("NMEA2 %d %s", gps->io.nmea_cnt, gps->io.nmea);
if (!gps->io.nmea)
return FALSE;
if (!strncmp(gps->io.nmea, NMEA_GSV, NMEA_PRLEN)) {
gps_nmea_parse_gsv(gps, gps->io.nmea + NMEA_PRLEN+1);
-} else if (!strncmp(gps->io.nmea, NMEA_RMC, NMEA_PRLEN))
+ if (gps->update_satellite)
+ g_idle_add_full(G_PRIORITY_DEFAULT, (GSourceFunc)gps->update_satellite, gps, NULL);
+
+} else if (!strncmp(gps->io.nmea, NMEA_RMC, NMEA_PRLEN)) {
gps_nmea_parse_rmc(gps, gps->io.nmea + NMEA_PRLEN+1);
-else if (!strncmp(gps->io.nmea, NMEA_GGA, NMEA_PRLEN))
+ if ((gps->io.conn==RCVR_FIXED) && (gps->update_location!=NULL))
+ gps->update_location(gps);
+
+} else if (!strncmp(gps->io.nmea, NMEA_GGA, NMEA_PRLEN)) {
gps_nmea_parse_gga(gps, gps->io.nmea + NMEA_PRLEN+1);
-else if (!strncmp(gps->io.nmea, NMEA_GSA, NMEA_PRLEN))
+ if (gps->update_info)
+ g_idle_add_full(G_PRIORITY_DEFAULT, (GSourceFunc)gps->update_info, gps, NULL);
+
+} else if (!strncmp(gps->io.nmea, NMEA_GSA, NMEA_PRLEN)) {
gps_nmea_parse_gsa(gps, gps->io.nmea + NMEA_PRLEN+1);
-else g_printerr("Unknown NMEA: [%s]\n", gps->io.nmea);
-g_free(gps->io.nmea);
-gps->io.nmea=NULL;
+ if (gps->update_satellite)
+ g_idle_add_full(G_PRIORITY_DEFAULT, (GSourceFunc)gps->update_satellite, gps, NULL);
+ if (gps->update_info)
+ g_idle_add_full(G_PRIORITY_DEFAULT, (GSourceFunc)gps->update_info, gps, NULL);
+
+} else g_printerr("Unknown NMEA: [%s]\n", gps->io.nmea);
return FALSE;
}
gps->io.type=type;
gps->io.conn=RCVR_OFF;
gps->io.nmea=NULL;
+gps->io.nmea_cnt=0;
gps->data.lat=60.20;
gps->data.lon=22.20;
gps->connection_error=NULL;
gps->data.time=time(NULL);
gps_data_integerize(&gps->data);
if (gps->update_location!=NULL) {
- gps->update_location(gps, FALSE);
+ gps->update_location(gps);
}
gps->data.lheading=gps->data.heading;
if (*sptr)
*sptr = '\0'; /* take checksum out of the buffer. */
- gps->io.nmea=g_strdup(gps->io.buffer);
- g_assert(gps->io.nmea);
- g_idle_add_full(G_PRIORITY_HIGH_IDLE, (GSourceFunc)gps_nmea_parse, gps, NULL);
+ gps->io.nmea_cnt++;
+ gps->io.nmea=gps->io.buffer;
- if (gps->update_info)
- g_idle_add_full(G_PRIORITY_DEFAULT, (GSourceFunc)gps->update_info, gps, NULL);
+ g_assert(gps->io.nmea);
+ g_debug("NMEA1 %d: (%s)", gps->io.nmea_cnt, gps->io.nmea);
- if (gps->update_satellite)
- g_idle_add_full(G_PRIORITY_DEFAULT, (GSourceFunc)gps->update_satellite, gps, NULL);
+ gps_nmea_parse(gps);
} else {
/* There was a checksum, and it was bad. */
g_printerr("%s: Bad checksum in NMEA sentence:\n%s\n", __PRETTY_FUNCTION__, gps->io.buffer);
gchar *curr;
gchar *last;
/* Latest NMEA line, ready for parsing */
+ guint nmea_cnt;
gchar *nmea;
};
gboolean(* connection_progress)(Gps *gps, gdouble fix);
/* New location */
- void(* update_location)(Gps *gps, gboolean newly_fixed);
+ gboolean(* update_location)(Gps *gps);
gboolean(* update_satellite)(Gps *gps);
gboolean(* update_info)(Gps *gps);
};
guint unity;
time_t time;
GpsFix fix;
+ gboolean newly_fixed;
guint fixquality;
gfloat speed;
gfloat maxspeed;
gconf_client_clear_cache(gconf_client);
gps_conn_set_state(_gps, RCVR_OFF);
gps_disconnect(_gps);
- track_add(NULL, FALSE);
+ track_add(NULL);
/* Pretend autoroute is in progress to avoid download. */
if (_autoroute_data.enabled)
_autoroute_data.in_progress = TRUE;
_gps->data.speed=20.f;
gps_data_integerize(&_gps->data);
_gps->data.time=time(NULL);
-track_add(&_gps->data, FALSE);
+track_add(&_gps->data);
map_refresh_mark();
}
* in the track).
*/
void
-track_add(GpsData *gps, gboolean newly_fixed)
+track_add(GpsData *gps)
{
gboolean show_directions = TRUE;
gint announce_thres_unsquared;
if (abs((gint)gps->unitx-_track.tail->unitx) > _draw_width || abs((gint)gps->unity-_track.tail->unity) > _draw_width) {
/* If gps is available, update the nearest-waypoint data. */
- if (gps && _route.head != _route.tail && (newly_fixed ? (route_find_nearest_point(), TRUE) : route_update_nears(TRUE))) {
+ if (gps && _route.head != _route.tail && (gps->newly_fixed ? (route_find_nearest_point(), TRUE) : route_update_nears(TRUE))) {
/* Nearest waypoint has changed - re-render paths. */
map_render_paths();
MACRO_QUEUE_DRAW_AREA();
void track_init(void);
void track_deinit(void);
-void track_add(GpsData *gps, gboolean newly_fixed);
+void track_add(GpsData *gps);
gboolean track_insert_break(void);
gboolean track_insert_mark(void);
gboolean track_save(void);
gboolean
gps_satellite_update(Gps *gps)
{
+g_assert(gps);
if (_satdetails_on)
gps_display_details(&gps->data);
}
gboolean
-gps_location_update(Gps *gps, gboolean newly_fixed)
+gps_location_update(Gps *gps)
{
g_assert(gps);
if (filter_check(&filter, &gps->data, &map_loc)==TRUE) {
- track_add(&_gps->data, newly_fixed);
+ track_add(&_gps->data);
map_refresh_mark();
}
-return TRUE;
+return FALSE;
}
/**
/* XXX: Not the right place but.. */
gboolean gps_info_update(Gps *gps);
-gboolean gps_location_update(Gps *gps, gboolean newly_fixed);
+gboolean gps_location_update(Gps *gps);
gboolean gps_retry_connection(Gps *gps, const gchar *error);
#endif