diff options
| author | Keith Packard <keithp@keithp.com> | 2009-07-17 21:24:45 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2009-07-17 21:24:45 -0700 | 
| commit | ddfa2308c0be4c002f982ae9da6032ee7854117d (patch) | |
| tree | 7a9e58212a6092e4719a4e815142882c74cab089 | |
| parent | 34f148500df427c148188c0ada20bf914a7c74ba (diff) | |
Support the not-connected GPS state
| -rw-r--r-- | aoview/aoview.h | 3 | ||||
| -rw-r--r-- | aoview/aoview_monitor.c | 14 | ||||
| -rw-r--r-- | aoview/aoview_state.c | 10 | 
3 files changed, 19 insertions, 8 deletions
| diff --git a/aoview/aoview.h b/aoview/aoview.h index b4d13159..800349ec 100644 --- a/aoview/aoview.h +++ b/aoview/aoview.h @@ -69,7 +69,8 @@ struct aodata {  	int	flight_pres;  	int	ground_pres;  	int	nsat; -	int	locked; +	int	gps_locked; +	int	gps_connected;  	struct {  		int hour;  		int minute; diff --git a/aoview/aoview_monitor.c b/aoview/aoview_monitor.c index 43381800..8d120091 100644 --- a/aoview/aoview_monitor.c +++ b/aoview/aoview_monitor.c @@ -106,14 +106,22 @@ aoview_monitor_parse(const char *input_line)  	aoview_parse_int(&data.flight_pres, words[30]);  	aoview_parse_int(&data.ground_pres, words[32]);  	aoview_parse_int(&data.nsat, words[34]); -	if (strcmp (words[36], "unlocked") != 0 && nword >= 40) { -		data.locked = 1; +	if (strcmp (words[36], "unlocked") == 0) { +		data.gps_connected = 1; +		data.gps_locked = 0; +		data.gps_time.hour = data.gps_time.minute = data.gps_time.second = 0; +		data.lat = data.lon = 0; +		data.alt = 0; +	} else if (nword >= 40) { +		data.gps_locked = 1; +		data.gps_connected = 1;  		sscanf(words[36], "%d:%d:%d", &data.gps_time.hour, &data.gps_time.minute, &data.gps_time.second);  		aoview_parse_pos(&data.lat, words[37]);  		aoview_parse_pos(&data.lon, words[38]);  		sscanf(words[39], "%dm", &data.alt);  	} else { -		data.locked = 0; +		data.gps_connected = 0; +		data.gps_locked = 0;  		data.gps_time.hour = data.gps_time.minute = data.gps_time.second = 0;  		data.lat = data.lon = 0;  		data.alt = 0; diff --git a/aoview/aoview_state.c b/aoview/aoview_state.c index cf1594cd..a0a608e0 100644 --- a/aoview/aoview_state.c +++ b/aoview/aoview_state.c @@ -130,7 +130,7 @@ aoview_state_derive(struct aodata *data, struct aostate *state)  	state->main_sense = data->main / 32767.0 * 15.0;  	state->battery = data->batt / 32767.0 * 5.0;  	if (!strcmp(data->state, "pad")) { -		if (data->locked && data->nsat >= 4) { +		if (data->gps_locked && data->nsat >= 4) {  			state->npad++;  			state->pad_lat_total += data->lat;  			state->pad_lon_total += data->lon; @@ -159,7 +159,7 @@ aoview_state_derive(struct aodata *data, struct aostate *state)  	if (state->height > state->max_height)  		state->max_height = state->height; -	if (data->locked) { +	if (data->gps_locked) {  		state->lat = data->lat;  		state->lon = data->lon;  		aoview_great_circle(state->pad_lat, state->pad_lon, data->lat, data->lon, @@ -296,7 +296,7 @@ aoview_state_notify(struct aodata *data)  	aoview_table_add_row(0, "Main", "%5.2fV", state->main_sense);  	aoview_table_add_row(0, "Pad altitude", "%dm", state->ground_altitude);  	aoview_table_add_row(1, "Satellites", "%d", state->data.nsat); -	if (state->data.locked) { +	if (state->data.gps_locked) {  		aoview_state_add_deg(1, "Latitude", state->data.lat, 'N', 'S');  		aoview_state_add_deg(1, "Longitude", state->data.lon, 'E', 'W');  		aoview_table_add_row(1, "GPS height", "%d", state->gps_height); @@ -313,8 +313,10 @@ aoview_state_notify(struct aodata *data)  				     state->data.hdop, state->data.h_error, state->data.v_error);  		aoview_table_add_row(1, "Distance from pad", "%5.0fm", state->distance);  		aoview_table_add_row(1, "Direction from pad", "%4.0f°", state->bearing); -	} else { +	} else if (state->data.gps_connected) {  		aoview_table_add_row(1, "GPS", "unlocked"); +	} else { +		aoview_table_add_row(1, "GPS", "not available");  	}  	if (state->npad) {  		aoview_state_add_deg(1, "Pad latitude", state->pad_lat, 'N', 'S'); | 
