Add GPS date/time output to ao-postflight.
authorKeith Packard <keithp@keithp.com>
Fri, 20 Nov 2009 19:56:48 +0000 (11:56 -0800)
committerKeith Packard <keithp@keithp.com>
Fri, 20 Nov 2009 20:10:19 +0000 (12:10 -0800)
GPS date/time information was already being stored in the log, it just
wasn't getting displayed by ao-postflight.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/ao-postflight/ao-postflight.c
ao-tools/lib/cc-logfile.c
ao-tools/lib/cc.h

index c12939a..a19b7eb 100644 (file)
@@ -208,6 +208,18 @@ analyse_flight(struct cc_flightraw *f, FILE *summary_file, FILE *detail_file,
                "Serial:  %9d\n"
                "Flight:  %9d\n",
                f->serial, f->flight);
+       if (f->year) {
+               fprintf(summary_file,
+                       "Date:   %04d-%02d-%02d\n",
+                       f->year, f->month, f->day);
+       }
+       if (f->gps.num) {
+               fprintf(summary_file,
+                       "Time:     %2d:%02d:%02d\n",
+                       f->gps.data[0].hour,
+                       f->gps.data[0].minute,
+                       f->gps.data[0].second);
+       }
        boost_start = f->accel.data[0].time;
        boost_stop = f->accel.data[f->accel.num-1].time;
        for (i = 0; i < f->state.num; i++) {
index 9d086c8..b0fff9f 100644 (file)
@@ -136,6 +136,7 @@ gpsdata_free(struct cc_gpsdata *data)
 #define AO_LOG_GPS_LON         'W'
 #define AO_LOG_GPS_ALT         'H'
 #define AO_LOG_GPS_SAT         'V'
+#define AO_LOG_GPS_DATE                'Y'
 
 #define AO_LOG_POS_NONE                (~0UL)
 
@@ -195,6 +196,10 @@ read_eeprom(const char *line, struct cc_flightraw *f, double *ground_pres, int *
                 * any stale data before adding this record
                 */
                gps.time = tick;
+               gps.hour = (a & 0xff);
+               gps.minute = (a >> 8) & 0xff;
+               gps.second = (b & 0xff);
+               gps.flags = (b >> 8) & 0xff;
                gps_valid = GPS_TIME;
                break;
        case AO_LOG_GPS_LAT:
@@ -215,6 +220,11 @@ read_eeprom(const char *line, struct cc_flightraw *f, double *ground_pres, int *
                sat.c_n = (b >> 8) & 0xff;
                gpssat_add(&f->gps, &sat);
                break;
+       case AO_LOG_GPS_DATE:
+               f->year = 2000 + (a & 0xff);
+               f->month = (a >> 8) & 0xff;
+               f->day = (b & 0xff);
+               break;
        default:
                return 0;
        }
@@ -266,10 +276,16 @@ read_telem(const char *line, struct cc_flightraw *f)
        timedata_add(&f->main, telem.tick, telem.main);
        timedata_add(&f->state, telem.tick, state_name_to_state(telem.state));
        if (telem.gps.gps_locked) {
+               f->year = telem.gps.gps_time.year;
+               f->month = telem.gps.gps_time.month;
+               f->day = telem.gps.gps_time.day;
                gps.time = telem.tick;
                gps.lat = telem.gps.lat;
                gps.lon = telem.gps.lon;
                gps.alt = telem.gps.alt;
+               gps.hour = telem.gps.gps_time.hour;
+               gps.minute = telem.gps.gps_time.minute;
+               gps.second = telem.gps.gps_time.second;
                gpsdata_add(&f->gps, &gps);
        }
        return 1;
index 0e8ced8..bdeeaaf 100644 (file)
@@ -86,6 +86,10 @@ struct cc_timedata {
 
 struct cc_gpselt {
        double          time;
+       int             hour;
+       int             minute;
+       int             second;
+       int             flags;
        double          lat;
        double          lon;
        double          alt;
@@ -149,6 +153,7 @@ struct cc_flightraw {
        int                     serial;
        double                  ground_accel;
        double                  ground_pres;
+       int                     year, month, day;
        struct cc_timedata      accel;
        struct cc_timedata      pres;
        struct cc_timedata      temp;