diff options
Diffstat (limited to 'ao-view')
-rw-r--r-- | ao-view/aoview.glade | 25 | ||||
-rw-r--r-- | ao-view/aoview.h | 22 | ||||
-rw-r--r-- | ao-view/aoview_monitor.c | 34 | ||||
-rw-r--r-- | ao-view/aoview_state.c | 24 | ||||
-rw-r--r-- | ao-view/aoview_table.c | 2 |
5 files changed, 97 insertions, 10 deletions
diff --git a/ao-view/aoview.glade b/ao-view/aoview.glade index 3481a779..9a746110 100644 --- a/ao-view/aoview.glade +++ b/ao-view/aoview.glade @@ -3,7 +3,7 @@ <!-- interface-requires gtk+ 2.16 --> <!-- interface-naming-policy project-wide --> <widget class="GtkWindow" id="aoview"> - <property name="width_request">550</property> + <property name="width_request">900</property> <property name="height_request">700</property> <property name="visible">True</property> <property name="title" translatable="yes">AltOS View</property> @@ -412,6 +412,17 @@ <property name="position">1</property> </packing> </child> + <child> + <widget class="GtkTreeView" id="dataview_2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="show_expanders">False</property> + <property name="enable_grid_lines">both</property> + </widget> + <packing> + <property name="position">2</property> + </packing> + </child> </widget> <packing> <property name="position">2</property> @@ -453,7 +464,7 @@ <property name="layout_style">end</property> <child> <widget class="GtkButton" id="cancel_button"> - <property name="label" translatable="yes">gtk-cancel</property> + <property name="label">gtk-cancel</property> <property name="response_id">1</property> <property name="visible">True</property> <property name="can_focus">True</property> @@ -470,7 +481,7 @@ </child> <child> <widget class="GtkButton" id="connect_button"> - <property name="label" translatable="yes">gtk-connect</property> + <property name="label">gtk-connect</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="can_default">True</property> @@ -511,7 +522,7 @@ <property name="layout_style">end</property> <child> <widget class="GtkButton" id="file_configure_cancel"> - <property name="label" translatable="yes">gtk-cancel</property> + <property name="label">gtk-cancel</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> @@ -526,7 +537,7 @@ </child> <child> <widget class="GtkButton" id="file_configure_ok"> - <property name="label" translatable="yes">gtk-ok</property> + <property name="label">gtk-ok</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="can_default">True</property> @@ -693,7 +704,7 @@ You should have received a copy of the GNU General Public License along with AoV <property name="layout_style">end</property> <child> <widget class="GtkButton" id="ao_replay_cancel"> - <property name="label" translatable="yes">gtk-cancel</property> + <property name="label">gtk-cancel</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> @@ -708,7 +719,7 @@ You should have received a copy of the GNU General Public License along with AoV </child> <child> <widget class="GtkButton" id="ao_replay_ok"> - <property name="label" translatable="yes">gtk-ok</property> + <property name="label">gtk-ok</property> <property name="visible">True</property> <property name="can_focus">True</property> <property name="receives_default">True</property> diff --git a/ao-view/aoview.h b/ao-view/aoview.h index e8334e5b..9ca65298 100644 --- a/ao-view/aoview.h +++ b/ao-view/aoview.h @@ -75,6 +75,26 @@ struct aogps { int v_error; /* m */ }; +#define SIRF_SAT_STATE_ACQUIRED (1 << 0) +#define SIRF_SAT_STATE_CARRIER_PHASE_VALID (1 << 1) +#define SIRF_SAT_BIT_SYNC_COMPLETE (1 << 2) +#define SIRF_SAT_SUBFRAME_SYNC_COMPLETE (1 << 3) +#define SIRF_SAT_CARRIER_PULLIN_COMPLETE (1 << 4) +#define SIRF_SAT_CODE_LOCKED (1 << 5) +#define SIRF_SAT_ACQUISITION_FAILED (1 << 6) +#define SIRF_SAT_EPHEMERIS_AVAILABLE (1 << 7) + +struct aogps_sat { + int svid; + int state; + int c_n0; +}; + +struct aogps_tracking { + int channels; + struct aogps_sat sats[12]; +}; + struct aodata { char callsign[16]; int serial; @@ -93,6 +113,7 @@ struct aodata { int flight_pres; int ground_pres; struct aogps gps; + struct aogps_tracking gps_tracking; }; struct aostate { @@ -121,6 +142,7 @@ struct aostate { double max_speed; struct aogps gps; + struct aogps_tracking gps_tracking; int gps_valid; double pad_lat; diff --git a/ao-view/aoview_monitor.c b/ao-view/aoview_monitor.c index 9265a199..1f4c8f72 100644 --- a/ao-view/aoview_monitor.c +++ b/ao-view/aoview_monitor.c @@ -48,6 +48,12 @@ aoview_parse_int(int *target, char *source) } static void +aoview_parse_hex(int *target, char *source) +{ + *target = strtol(source, NULL, 16); +} + +static void aoview_parse_pos(double *target, char *source) { int deg; @@ -65,20 +71,23 @@ aoview_parse_pos(double *target, char *source) *target = r; } +#define PARSE_MAX_WORDS 256 + gboolean aoview_monitor_parse(const char *input_line) { char *saveptr; - char *words[64]; + char *words[PARSE_MAX_WORDS]; int nword; char line_buf[8192], *line; struct aodata data; + int tracking_pos; /* avoid smashing our input parameter */ strncpy (line_buf, input_line, sizeof (line_buf)-1); line_buf[sizeof(line_buf) - 1] = '\0'; line = line_buf; - for (nword = 0; nword < 64; nword++) { + for (nword = 0; nword < PARSE_MAX_WORDS; nword++) { words[nword] = strtok_r(line, " \t\n", &saveptr); line = NULL; if (words[nword] == NULL) @@ -112,6 +121,7 @@ aoview_monitor_parse(const char *input_line) data.gps.gps_time.hour = data.gps.gps_time.minute = data.gps.gps_time.second = 0; data.gps.lat = data.gps.lon = 0; data.gps.alt = 0; + tracking_pos = 37; } else if (nword >= 40) { data.gps.gps_locked = 1; data.gps.gps_connected = 1; @@ -119,6 +129,7 @@ aoview_monitor_parse(const char *input_line) aoview_parse_pos(&data.gps.lat, words[37]); aoview_parse_pos(&data.gps.lon, words[38]); sscanf(words[39], "%dm", &data.gps.alt); + tracking_pos = 46; } else { data.gps.gps_connected = 0; data.gps.gps_locked = 0; @@ -143,6 +154,25 @@ aoview_monitor_parse(const char *input_line) data.gps.h_error = 0; data.gps.v_error = 0; } + if (nword >= tracking_pos + 2 && strcmp(words[tracking_pos], "SAT") == 0) { + int c, n, pos; + aoview_parse_int(&n, words[tracking_pos + 1]); + pos = tracking_pos + 2; + if (nword >= pos + n * 3) { + data.gps_tracking.channels = n; + for (c = 0; c < n; c++) { + aoview_parse_int(&data.gps_tracking.sats[c].svid, + words[pos + 0]); + aoview_parse_hex(&data.gps_tracking.sats[c].state, + words[pos + 1]); + aoview_parse_int(&data.gps_tracking.sats[c].c_n0, + words[pos + 2]); + pos += 3; + } + } else { + data.gps_tracking.channels = 0; + } + } aoview_state_notify(&data); return TRUE; } diff --git a/ao-view/aoview_state.c b/ao-view/aoview_state.c index 7efd33b0..f75066dd 100644 --- a/ao-view/aoview_state.c +++ b/ao-view/aoview_state.c @@ -168,6 +168,8 @@ aoview_state_derive(struct aodata *data, struct aostate *state) aoview_great_circle(state->pad_lat, state->pad_lon, state->gps.lat, state->gps.lon, &state->distance, &state->bearing); } + if (data->gps_tracking.channels) + state->gps_tracking = data->gps_tracking; if (state->npad) { state->gps_height = state->gps.alt - state->pad_alt; } else { @@ -308,6 +310,7 @@ aoview_state_notify(struct aodata *data) if (state->gps_valid) { aoview_state_add_deg(1, "Latitude", state->gps.lat, 'N', 'S'); aoview_state_add_deg(1, "Longitude", state->gps.lon, 'E', 'W'); + aoview_table_add_row(1, "GPS altitude", "%d", state->gps.alt); aoview_table_add_row(1, "GPS height", "%d", state->gps_height); aoview_table_add_row(1, "GPS time", "%02d:%02d:%02d", state->gps.gps_time.hour, @@ -330,6 +333,27 @@ aoview_state_notify(struct aodata *data) aoview_state_add_deg(1, "Pad longitude", state->pad_lon, 'E', 'W'); aoview_table_add_row(1, "Pad GPS alt", "%gm", state->pad_alt); } + if (state->gps.gps_connected) { + int nsat_vis = 0; + int nsat_locked = 0; + int c; + + for (c = 0; c < state->gps_tracking.channels; c++) { + if ((state->gps_tracking.sats[c].state & 0xff) == 0xbf) + nsat_locked++; + } + aoview_table_add_row(2, "Satellites Visible", "%d", state->gps_tracking.channels); + aoview_table_add_row(2, "Satellites Locked", "%d", nsat_locked); + for (c = 0; c < state->gps_tracking.channels; c++) { + aoview_table_add_row(2, "Satellite id,state,C/N0", + "%3d,%02x,%2d%s", + state->gps_tracking.sats[c].svid, + state->gps_tracking.sats[c].state, + state->gps_tracking.sats[c].c_n0, + (state->gps_tracking.sats[c].state & 0xff) == 0xbf ? + " LOCKED" : ""); + } + } aoview_table_finish(); aoview_label_show(state); aoview_speak_state(state); diff --git a/ao-view/aoview_table.c b/ao-view/aoview_table.c index 93143009..e75ae670 100644 --- a/ao-view/aoview_table.c +++ b/ao-view/aoview_table.c @@ -17,7 +17,7 @@ #include "aoview.h" -#define NCOL 2 +#define NCOL 3 static GtkTreeView *dataview[NCOL]; static GtkListStore *datalist[NCOL]; |