Add telem replay and larger labels
[fw/altos] / aoview / aoview_monitor.c
index e2ba75bab0f8f9d92e7a3c47fe43ad697aca3c6b..faa24474de50feaee06b02277ed653a21300dd33 100644 (file)
@@ -66,16 +66,15 @@ aoview_parse_pos(double *target, char *source)
        *target = r;
 }
 
-static void
+static struct aostate  state;
+
+gboolean
 aoview_monitor_parse(char *line)
 {
        char *saveptr;
        char *words[64];
        int nword;
-       struct aostate  state;
 
-       if (aoview_log_get_serial())
-               aoview_log_printf ("%s\n", line);
        for (nword = 0; nword < 64; nword++) {
                words[nword] = strtok_r(line, " \t\n", &saveptr);
                line = NULL;
@@ -83,12 +82,11 @@ aoview_monitor_parse(char *line)
                        break;
        }
        if (nword < 36)
-               return;
+               return FALSE;
        if (strcmp(words[0], "CALL") != 0)
-               return;
+               return FALSE;
        aoview_parse_string(state.callsign, sizeof (state.callsign), words[1]);
        aoview_parse_int(&state.serial, words[3]);
-       aoview_log_set_serial(state.serial);
 
        aoview_parse_int(&state.rssi, words[5]);
        aoview_parse_string(state.state, sizeof (state.state), words[9]);
@@ -117,7 +115,23 @@ aoview_monitor_parse(char *line)
                state.lat = state.lon = 0;
                state.alt = 0;
        }
+       if (nword >= 46) {
+               sscanf(words[40], "%lfm/s", &state.ground_speed);
+               sscanf(words[41], "%d", &state.course);
+               sscanf(words[42], "%lfm/s", &state.climb_rate);
+               sscanf(words[43], "%lf", &state.hdop);
+               sscanf(words[44], "%d", &state.h_error);
+               sscanf(words[45], "%d", &state.v_error);
+       } else {
+               state.ground_speed = 0;
+               state.course = 0;
+               state.climb_rate = 0;
+               state.hdop = 0;
+               state.h_error = 0;
+               state.v_error = 0;
+       }
        aoview_state_notify(&state);
+       return TRUE;
 }
 
 static void
@@ -140,8 +154,13 @@ aoview_monitor_callback(gpointer user_data,
                                continue;
                        if (c == '\n') {
                                monitor_line[monitor_pos] = '\0';
-                               if (monitor_pos)
-                               aoview_monitor_parse(monitor_line);
+                               if (monitor_pos) {
+                                       if (aoview_monitor_parse(monitor_line)) {
+                                               aoview_log_set_serial(state.serial);
+                                               if (aoview_log_get_serial())
+                                                       aoview_log_printf ("%s\n", monitor_line);
+                                       }
+                               }
                                monitor_pos = 0;
                        } else if (monitor_pos < MONITOR_LEN)
                                monitor_line[monitor_pos++] = c;