ao-postflight: don't try to use missing gps sat data
authorKeith Packard <keithp@keithp.com>
Sun, 22 Nov 2009 08:52:58 +0000 (00:52 -0800)
committerKeith Packard <keithp@keithp.com>
Sun, 22 Nov 2009 08:52:58 +0000 (00:52 -0800)
Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/ao-postflight/ao-postflight.c

index 51bcd6e..48752d0 100644 (file)
@@ -407,20 +407,22 @@ analyse_flight(struct cc_flightraw *f, FILE *summary_file, FILE *detail_file,
                        }
 
                        nsat = 0;
-                       for (k = 0; k < f->gps.sats[j].nsat; k++) {
-                               if (f->gps.sats[j].sat[k].svid != 0)
-                                       nsat++;
-                       }
-                       if (gps_file) {
-                               fprintf(gps_file, " %4d", nsat);
+                       if (f->gps.sats) {
                                for (k = 0; k < f->gps.sats[j].nsat; k++) {
-                                       if (f->gps.sats[j].sat[k].svid != 0) {
-                                               fprintf (gps_file, " %3d(%4.1f)",
-                                                        f->gps.sats[j].sat[k].svid,
-                                                        (double) f->gps.sats[j].sat[k].c_n);
+                                       if (f->gps.sats[j].sat[k].svid != 0)
+                                               nsat++;
+                               }
+                               if (gps_file) {
+                                       fprintf(gps_file, " %4d", nsat);
+                                       for (k = 0; k < f->gps.sats[j].nsat; k++) {
+                                               if (f->gps.sats[j].sat[k].svid != 0) {
+                                                       fprintf (gps_file, " %3d(%4.1f)",
+                                                                f->gps.sats[j].sat[k].svid,
+                                                                (double) f->gps.sats[j].sat[k].c_n);
+                                               }
                                        }
+                                       fprintf(gps_file, "\n");
                                }
-                               fprintf(gps_file, "\n");
                        }
                }
                if (kml_file)