From c46e832b28820d7c5be4efaacbbd7c0607927fe5 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 5 Sep 2009 22:03:31 -0700 Subject: Add simple post-flight analysis tool (ao-postflight) This tool reads either an eeprom or telem log file and displays some rudimentary data (max accel/alt for each flight stage). Signed-off-by: Keith Packard --- ao-tools/lib/cc-telem.c | 164 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 ao-tools/lib/cc-telem.c (limited to 'ao-tools/lib/cc-telem.c') diff --git a/ao-tools/lib/cc-telem.c b/ao-tools/lib/cc-telem.c new file mode 100644 index 00000000..a6ac0313 --- /dev/null +++ b/ao-tools/lib/cc-telem.c @@ -0,0 +1,164 @@ +/* + * Copyright © 2009 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "cc.h" +#include +#include + +static void +cc_parse_string(char *target, int len, char *source) +{ + strncpy(target, source, len-1); + target[len-1] = '\0'; +} + +static void +cc_parse_int(int *target, char *source) +{ + *target = strtol(source, NULL, 0); +} + +static void +cc_parse_hex(int *target, char *source) +{ + *target = strtol(source, NULL, 16); +} + +static void +cc_parse_pos(double *target, char *source) +{ + int deg; + double min; + char dir; + double r; + + if (sscanf(source, "%d°%lf'%c", °, &min, &dir) != 3) { + *target = 0; + return; + } + r = deg + min / 60.0; + if (dir == 'S' || dir == 'W') + r = -r; + *target = r; +} + +#define PARSE_MAX_WORDS 512 + +int +cc_telem_parse(const char *input_line, struct cc_telem *telem) +{ + char *saveptr; + char *words[PARSE_MAX_WORDS]; + int nword; + char line_buf[8192], *line; + 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 < PARSE_MAX_WORDS; nword++) { + words[nword] = strtok_r(line, " \t\n", &saveptr); + line = NULL; + if (words[nword] == NULL) + break; + } + if (nword < 36) + return FALSE; + if (strcmp(words[0], "CALL") != 0) + return FALSE; + cc_parse_string(telem->callsign, sizeof (telem->callsign), words[1]); + cc_parse_int(&telem->serial, words[3]); + + cc_parse_int(&telem->rssi, words[5]); + cc_parse_string(telem->state, sizeof (telem->state), words[9]); + cc_parse_int(&telem->tick, words[10]); + cc_parse_int(&telem->accel, words[12]); + cc_parse_int(&telem->pres, words[14]); + cc_parse_int(&telem->temp, words[16]); + cc_parse_int(&telem->batt, words[18]); + cc_parse_int(&telem->drogue, words[20]); + cc_parse_int(&telem->main, words[22]); + cc_parse_int(&telem->flight_accel, words[24]); + cc_parse_int(&telem->ground_accel, words[26]); + cc_parse_int(&telem->flight_vel, words[28]); + cc_parse_int(&telem->flight_pres, words[30]); + cc_parse_int(&telem->ground_pres, words[32]); + cc_parse_int(&telem->gps.nsat, words[34]); + if (strcmp (words[36], "unlocked") == 0) { + telem->gps.gps_connected = 1; + telem->gps.gps_locked = 0; + telem->gps.gps_time.hour = telem->gps.gps_time.minute = telem->gps.gps_time.second = 0; + telem->gps.lat = telem->gps.lon = 0; + telem->gps.alt = 0; + tracking_pos = 37; + } else if (nword >= 40) { + telem->gps.gps_locked = 1; + telem->gps.gps_connected = 1; + sscanf(words[36], "%d:%d:%d", &telem->gps.gps_time.hour, &telem->gps.gps_time.minute, &telem->gps.gps_time.second); + cc_parse_pos(&telem->gps.lat, words[37]); + cc_parse_pos(&telem->gps.lon, words[38]); + sscanf(words[39], "%dm", &telem->gps.alt); + tracking_pos = 46; + } else { + telem->gps.gps_connected = 0; + telem->gps.gps_locked = 0; + telem->gps.gps_time.hour = telem->gps.gps_time.minute = telem->gps.gps_time.second = 0; + telem->gps.lat = telem->gps.lon = 0; + telem->gps.alt = 0; + tracking_pos = -1; + } + if (nword >= 46) { + telem->gps.gps_extended = 1; + sscanf(words[40], "%lfm/s", &telem->gps.ground_speed); + sscanf(words[41], "%d", &telem->gps.course); + sscanf(words[42], "%lfm/s", &telem->gps.climb_rate); + sscanf(words[43], "%lf", &telem->gps.hdop); + sscanf(words[44], "%d", &telem->gps.h_error); + sscanf(words[45], "%d", &telem->gps.v_error); + } else { + telem->gps.gps_extended = 0; + telem->gps.ground_speed = 0; + telem->gps.course = 0; + telem->gps.climb_rate = 0; + telem->gps.hdop = 0; + telem->gps.h_error = 0; + telem->gps.v_error = 0; + } + if (tracking_pos >= 0 && nword >= tracking_pos + 2 && strcmp(words[tracking_pos], "SAT") == 0) { + int c, n, pos; + cc_parse_int(&n, words[tracking_pos + 1]); + pos = tracking_pos + 2; + if (nword >= pos + n * 3) { + telem->gps_tracking.channels = n; + for (c = 0; c < n; c++) { + cc_parse_int(&telem->gps_tracking.sats[c].svid, + words[pos + 0]); + cc_parse_hex(&telem->gps_tracking.sats[c].state, + words[pos + 1]); + cc_parse_int(&telem->gps_tracking.sats[c].c_n0, + words[pos + 2]); + pos += 3; + } + } else { + telem->gps_tracking.channels = 0; + } + } else { + telem->gps_tracking.channels = 0; + } + return TRUE; +} -- cgit v1.2.3 From 4cffc9c4b079e39c8196ddbaf91129cda6df7f8b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 14 Nov 2009 22:24:37 -0800 Subject: Share telemetry parsing code in cc library. ao-view had a private copy of the telemetry parsing code which included the ability to parse the newer version of that file. Those changes have been moved to the library version and the private copy removed. Signed-off-by: Keith Packard --- ao-tools/ao-view/aoview.h | 77 ++---------------- ao-tools/ao-view/aoview_monitor.c | 159 +------------------------------------- ao-tools/ao-view/aoview_state.c | 4 +- ao-tools/lib/cc-telem.c | 24 +++++- ao-tools/lib/cc.h | 2 + 5 files changed, 33 insertions(+), 233 deletions(-) (limited to 'ao-tools/lib/cc-telem.c') diff --git a/ao-tools/ao-view/aoview.h b/ao-tools/ao-view/aoview.h index b6d5bcdf..b937df7c 100644 --- a/ao-tools/ao-view/aoview.h +++ b/ao-tools/ao-view/aoview.h @@ -43,79 +43,12 @@ #include #include -struct aogps_time { - int hour; - int minute; - int second; -}; - -struct aogps { - int nsat; - int gps_locked; - int gps_connected; - struct aogps_time gps_time; - double lat; /* degrees (+N -S) */ - double lon; /* degrees (+E -W) */ - int alt; /* m */ - - int gps_extended; /* has extra data */ - double ground_speed; /* m/s */ - int course; /* degrees */ - double climb_rate; /* m/s */ - double hdop; /* unitless? */ - int h_error; /* m */ - 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; - int rssi; - char state[16]; - int tick; - int accel; - int pres; - int temp; - int batt; - int drogue; - int main; - int flight_accel; - int ground_accel; - int flight_vel; - int flight_pres; - int ground_pres; - int accel_plus_g; - int accel_minus_g; - struct aogps gps; - struct aogps_tracking gps_tracking; -}; - struct aostate { - struct aodata data; + struct cc_telem data; /* derived data */ - struct aodata prev_data; + struct cc_telem prev_data; double report_time; @@ -135,8 +68,8 @@ struct aostate { double max_acceleration; double max_speed; - struct aogps gps; - struct aogps_tracking gps_tracking; + struct cc_gps gps; + struct cc_gps_tracking gps_tracking; int gps_valid; double pad_lat; @@ -201,7 +134,7 @@ void aoview_dev_dialog_init(GladeXML *xml); void -aoview_state_notify(struct aodata *data); +aoview_state_notify(struct cc_telem *data); void aoview_state_new(void); diff --git a/ao-tools/ao-view/aoview_monitor.c b/ao-tools/ao-view/aoview_monitor.c index 6d57f556..0f4afb0f 100644 --- a/ao-tools/ao-view/aoview_monitor.c +++ b/ao-tools/ao-view/aoview_monitor.c @@ -34,167 +34,14 @@ aoview_monitor_disconnect(void) aoview_log_new(); } -static void -aoview_parse_string(char *target, int len, char *source) -{ - strncpy(target, source, len-1); - target[len-1] = '\0'; -} - -static void -aoview_parse_int(int *target, char *source) -{ - *target = strtol(source, NULL, 0); -} - -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; - double min; - char dir; - double r; - - if (sscanf(source, "%d°%lf'%c", °, &min, &dir) != 3) { - *target = 0; - return; - } - r = deg + min / 60.0; - if (dir == 'S' || dir == 'W') - r = -r; - *target = r; -} - -#define PARSE_MAX_WORDS 256 - gboolean aoview_monitor_parse(const char *input_line) { - char *saveptr; - char *raw_words[PARSE_MAX_WORDS]; - char **words; - int version = 0; - int nword; - char line_buf[8192], *line; - struct aodata data; - int tracking_pos; - int channel; + struct cc_telem telem; - /* 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 < PARSE_MAX_WORDS; nword++) { - raw_words[nword] = strtok_r(line, " \t\n", &saveptr); - line = NULL; - if (raw_words[nword] == NULL) - break; - } - if (nword < 36) - return FALSE; - words = raw_words; - if (strcmp(words[0], "VERSION") == 0) { - aoview_parse_int(&version, words[1]); - words += 2; - nword -= 2; - } - if (strcmp(words[0], "CALL") != 0) + if (!cc_telem_parse(input_line, &telem)) return FALSE; - aoview_parse_string(data.callsign, sizeof (data.callsign), words[1]); - aoview_parse_int(&data.serial, words[3]); - - aoview_parse_int(&data.rssi, words[5]); - aoview_parse_string(data.state, sizeof (data.state), words[9]); - aoview_parse_int(&data.tick, words[10]); - aoview_parse_int(&data.accel, words[12]); - aoview_parse_int(&data.pres, words[14]); - aoview_parse_int(&data.temp, words[16]); - aoview_parse_int(&data.batt, words[18]); - aoview_parse_int(&data.drogue, words[20]); - aoview_parse_int(&data.main, words[22]); - aoview_parse_int(&data.flight_accel, words[24]); - aoview_parse_int(&data.ground_accel, words[26]); - aoview_parse_int(&data.flight_vel, words[28]); - aoview_parse_int(&data.flight_pres, words[30]); - aoview_parse_int(&data.ground_pres, words[32]); - if (version >= 1) { - aoview_parse_int(&data.accel_plus_g, words[34]); - aoview_parse_int(&data.accel_minus_g, words[36]); - words += 4; - nword -= 4; - } else { - data.accel_plus_g = data.ground_accel; - data.accel_minus_g = data.ground_accel + 530; - } - aoview_parse_int(&data.gps.nsat, words[34]); - if (strcmp (words[36], "unlocked") == 0) { - data.gps.gps_connected = 1; - data.gps.gps_locked = 0; - 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; - sscanf(words[36], "%d:%d:%d", &data.gps.gps_time.hour, &data.gps.gps_time.minute, &data.gps.gps_time.second); - 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; - 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 = -1; - } - if (nword >= 46) { - data.gps.gps_extended = 1; - sscanf(words[40], "%lfm/s", &data.gps.ground_speed); - sscanf(words[41], "%d", &data.gps.course); - sscanf(words[42], "%lfm/s", &data.gps.climb_rate); - sscanf(words[43], "%lf", &data.gps.hdop); - sscanf(words[44], "%d", &data.gps.h_error); - sscanf(words[45], "%d", &data.gps.v_error); - } else { - data.gps.gps_extended = 0; - data.gps.ground_speed = 0; - data.gps.course = 0; - data.gps.climb_rate = 0; - data.gps.hdop = 0; - data.gps.h_error = 0; - data.gps.v_error = 0; - } - if (tracking_pos >= 0 && 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; - } - } else { - data.gps_tracking.channels = 0; - } - aoview_state_notify(&data); + aoview_state_notify(&telem); return TRUE; } diff --git a/ao-tools/ao-view/aoview_state.c b/ao-tools/ao-view/aoview_state.c index f8f01685..a7545c51 100644 --- a/ao-tools/ao-view/aoview_state.c +++ b/ao-tools/ao-view/aoview_state.c @@ -99,7 +99,7 @@ aoview_time(void) * Fill out the derived data fields */ static void -aoview_state_derive(struct aodata *data, struct aostate *state) +aoview_state_derive(struct cc_telem *data, struct aostate *state) { int i; double new_height; @@ -274,7 +274,7 @@ aoview_state_reset(void) } void -aoview_state_notify(struct aodata *data) +aoview_state_notify(struct cc_telem *data) { struct aostate *state = &aostate; aoview_state_derive(data, state); diff --git a/ao-tools/lib/cc-telem.c b/ao-tools/lib/cc-telem.c index a6ac0313..f82ab961 100644 --- a/ao-tools/lib/cc-telem.c +++ b/ao-tools/lib/cc-telem.c @@ -62,7 +62,9 @@ int cc_telem_parse(const char *input_line, struct cc_telem *telem) { char *saveptr; - char *words[PARSE_MAX_WORDS]; + char *raw_words[PARSE_MAX_WORDS]; + char **words; + int version = 0; int nword; char line_buf[8192], *line; int tracking_pos; @@ -72,13 +74,20 @@ cc_telem_parse(const char *input_line, struct cc_telem *telem) line_buf[sizeof(line_buf) - 1] = '\0'; line = line_buf; for (nword = 0; nword < PARSE_MAX_WORDS; nword++) { - words[nword] = strtok_r(line, " \t\n", &saveptr); + raw_words[nword] = strtok_r(line, " \t\n", &saveptr); line = NULL; - if (words[nword] == NULL) + if (raw_words[nword] == NULL) break; } if (nword < 36) return FALSE; + words = raw_words; + if (strcmp(words[0], "VERSION") == 0) { + cc_parse_int(&version, words[1]); + words += 2; + nword -= 2; + } + if (strcmp(words[0], "CALL") != 0) return FALSE; cc_parse_string(telem->callsign, sizeof (telem->callsign), words[1]); @@ -98,6 +107,15 @@ cc_telem_parse(const char *input_line, struct cc_telem *telem) cc_parse_int(&telem->flight_vel, words[28]); cc_parse_int(&telem->flight_pres, words[30]); cc_parse_int(&telem->ground_pres, words[32]); + if (version >= 1) { + cc_parse_int(&telem->accel_plus_g, words[34]); + cc_parse_int(&telem->accel_minus_g, words[36]); + words += 4; + nword -= 4; + } else { + telem->accel_plus_g = telem->ground_accel; + telem->accel_minus_g = telem->ground_accel + 530; + } cc_parse_int(&telem->gps.nsat, words[34]); if (strcmp (words[36], "unlocked") == 0) { telem->gps.gps_connected = 1; diff --git a/ao-tools/lib/cc.h b/ao-tools/lib/cc.h index b5f1132f..fd461e5c 100644 --- a/ao-tools/lib/cc.h +++ b/ao-tools/lib/cc.h @@ -252,6 +252,8 @@ struct cc_telem { int flight_vel; int flight_pres; int ground_pres; + int accel_plus_g; + int accel_minus_g; struct cc_gps gps; struct cc_gps_tracking gps_tracking; }; -- cgit v1.2.3 From 3ee279ba76c2a79d142c466f19ef758cf4c01d70 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 15 Nov 2009 15:59:01 -0800 Subject: Add flight number to telemetry stream. This makes it easier to tie the telemetry and eeprom files together as they're now both labeled with serial and flight numbers, which should be unique. Signed-off-by: Keith Packard --- ao-tools/ao-view/aoview_state.c | 1 + ao-tools/lib/cc-telem.c | 7 ++++++ ao-tools/lib/cc.h | 1 + src/ao.h | 11 +++++---- src/ao_log.c | 51 +++++++++++------------------------------ src/ao_monitor.c | 3 ++- src/ao_telemetry.c | 3 +++ 7 files changed, 34 insertions(+), 43 deletions(-) (limited to 'ao-tools/lib/cc-telem.c') diff --git a/ao-tools/ao-view/aoview_state.c b/ao-tools/ao-view/aoview_state.c index a7545c51..2f613d44 100644 --- a/ao-tools/ao-view/aoview_state.c +++ b/ao-tools/ao-view/aoview_state.c @@ -288,6 +288,7 @@ aoview_state_notify(struct cc_telem *data) aoview_table_add_row(0, "Rocket state", "%s", state->data.state); aoview_table_add_row(0, "Callsign", "%s", state->data.callsign); aoview_table_add_row(0, "Rocket serial", "%d", state->data.serial); + aoview_table_add_row(0, "Rocket flight", "%d", state->data.flight); aoview_table_add_row(0, "RSSI", "%6ddBm", state->data.rssi); aoview_table_add_row(0, "Height", "%6dm", state->height); diff --git a/ao-tools/lib/cc-telem.c b/ao-tools/lib/cc-telem.c index f82ab961..0e1483f7 100644 --- a/ao-tools/lib/cc-telem.c +++ b/ao-tools/lib/cc-telem.c @@ -93,6 +93,13 @@ cc_telem_parse(const char *input_line, struct cc_telem *telem) cc_parse_string(telem->callsign, sizeof (telem->callsign), words[1]); cc_parse_int(&telem->serial, words[3]); + if (version >= 2) { + cc_parse_int(&telem->flight, words[5]); + words += 2; + nword -= 2; + } else + telem->flight = 0; + cc_parse_int(&telem->rssi, words[5]); cc_parse_string(telem->state, sizeof (telem->state), words[9]); cc_parse_int(&telem->tick, words[10]); diff --git a/ao-tools/lib/cc.h b/ao-tools/lib/cc.h index fd461e5c..b8e3c061 100644 --- a/ao-tools/lib/cc.h +++ b/ao-tools/lib/cc.h @@ -238,6 +238,7 @@ struct cc_gps_tracking { struct cc_telem { char callsign[16]; int serial; + int flight; int rssi; char state[16]; int tick; diff --git a/src/ao.h b/src/ao.h index 2df81d2a..f266ac64 100644 --- a/src/ao.h +++ b/src/ao.h @@ -553,11 +553,11 @@ ao_log_data(struct ao_log_record *log); void ao_log_flush(void); -/* Log dumping API: - * ao_log_dump_first() - get first log record - * ao_log_dump_next() - get next log record +/* We record flight numbers in the first record of + * the log. Tasks may wait for this to be initialized + * by sleeping on this variable. */ -extern __xdata struct ao_log_record ao_log_dump; +extern __xdata uint16_t ao_flight_number; /* Retrieve first log record for the current flight */ uint8_t @@ -788,10 +788,11 @@ ao_gps_report_init(void); */ #define AO_MAX_CALLSIGN 8 -#define AO_TELEMETRY_VERSION 1 +#define AO_TELEMETRY_VERSION 2 struct ao_telemetry { uint8_t addr; + uint16_t flight; uint8_t flight_state; int16_t flight_accel; int16_t ground_accel; diff --git a/src/ao_log.c b/src/ao_log.c index 50778f55..44ce90e0 100644 --- a/src/ao_log.c +++ b/src/ao_log.c @@ -59,51 +59,30 @@ ao_log_flush(void) ao_ee_flush(); } -__xdata struct ao_log_record ao_log_dump; -static __xdata uint16_t ao_log_dump_flight; -static __xdata uint32_t ao_log_dump_pos; +__xdata struct ao_log_record log; +__xdata uint16_t ao_flight_number; static uint8_t ao_log_dump_check_data(void) { - if (ao_log_csum((uint8_t *) &ao_log_dump) != 0) + if (ao_log_csum((uint8_t *) &log) != 0) return 0; return 1; } -static uint8_t -ao_log_dump_scan(void) +static void +ao_log_scan(void) { - if (!ao_ee_read(0, (uint8_t *) &ao_log_dump, sizeof (struct ao_log_record))) + if (!ao_ee_read(0, (uint8_t *) &log, sizeof (struct ao_log_record))) ao_panic(AO_PANIC_LOG); - if (ao_log_dump_check_data() && ao_log_dump.type == AO_LOG_FLIGHT) { - ao_log_dump_flight = ao_log_dump.u.flight.flight; - return 1; + if (ao_log_dump_check_data() && log.type == AO_LOG_FLIGHT) { + ao_flight_number = log.u.flight.flight + 1; + if (ao_flight_number == 0) + ao_flight_number = 1; } else { - ao_log_dump_flight = 0; - return 0; + ao_flight_number = 1; } -} - -uint8_t -ao_log_dump_first(void) -{ - ao_log_dump_pos = 0; - if (!ao_log_dump_scan()) - return 0; - return 1; -} - -uint8_t -ao_log_dump_next(void) -{ - ao_log_dump_pos += sizeof (struct ao_log_record); - if (ao_log_dump_pos >= AO_EE_DEVICE_SIZE) - return 0; - if (!ao_ee_read(ao_log_dump_pos, (uint8_t *) &ao_log_dump, - sizeof (struct ao_log_record))) - return 0; - return ao_log_dump_check_data(); + ao_wakeup(&ao_flight_number); } __xdata uint8_t ao_log_adc_pos; @@ -115,9 +94,7 @@ typedef uint8_t check_log_size[1-(256 % sizeof(struct ao_log_record))] ; void ao_log(void) { - static __xdata struct ao_log_record log; - - ao_log_dump_scan(); + ao_log_scan(); while (!ao_log_running) ao_sleep(&ao_log_running); @@ -125,7 +102,7 @@ ao_log(void) log.type = AO_LOG_FLIGHT; log.tick = ao_flight_tick; log.u.flight.ground_accel = ao_ground_accel; - log.u.flight.flight = ao_log_dump_flight + 1; + log.u.flight.flight = ao_flight_number; ao_log_data(&log); /* Write the whole contents of the ring to the log diff --git a/src/ao_monitor.c b/src/ao_monitor.c index cd0d693e..628b6e67 100644 --- a/src/ao_monitor.c +++ b/src/ao_monitor.c @@ -37,10 +37,11 @@ ao_monitor(void) if (state > ao_flight_invalid) state = ao_flight_invalid; if (recv.status & PKT_APPEND_STATUS_1_CRC_OK) { - printf("VERSION %d CALL %s SERIAL %3d RSSI %4d STATUS %02x STATE %7s ", + printf("VERSION %d CALL %s SERIAL %3d FLIGHT %5u RSSI %4d STATUS %02x STATE %7s ", AO_TELEMETRY_VERSION, callsign, recv.telemetry.addr, + recv.telemetry.flight, (int) recv.rssi - 74, recv.status, ao_state_names[state]); printf("%5u a: %5d p: %5d t: %5d v: %5d d: %5d m: %5d " diff --git a/src/ao_telemetry.c b/src/ao_telemetry.c index 9c923984..88ac142c 100644 --- a/src/ao_telemetry.c +++ b/src/ao_telemetry.c @@ -30,8 +30,11 @@ ao_telemetry(void) static __xdata struct ao_telemetry telemetry; ao_config_get(); + while (!ao_flight_number) + ao_sleep(&ao_flight_number); memcpy(telemetry.callsign, ao_config.callsign, AO_MAX_CALLSIGN); telemetry.addr = ao_serial_number; + telemetry.flight = ao_flight_number; telemetry.accel_plus_g = ao_config.accel_plus_g; telemetry.accel_minus_g = ao_config.accel_minus_g; ao_rdf_time = ao_time(); -- cgit v1.2.3 From 524665fc221b0d483453c67b7211e282cebc8980 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 15 Nov 2009 16:04:41 -0800 Subject: Add date to GPS data, captured from GPRMC packet. Pull the date out of the GPS stream and send it over the telemetry link and write it to the eeprom. Signed-off-by: Keith Packard --- ao-tools/ao-view/aoview_state.c | 4 +++ ao-tools/lib/cc-telem.c | 12 ++++++++ ao-tools/lib/cc.h | 3 ++ src/ao.h | 10 ++++++ src/ao_gps_print.c | 4 +++ src/ao_gps_report.c | 12 ++++++-- src/ao_gps_skytraq.c | 67 ++++++++++++++++++++++++++++++++++++----- src/ao_gps_test.c | 4 +++ src/ao_gps_test_skytraq.c | 4 +++ 9 files changed, 111 insertions(+), 9 deletions(-) (limited to 'ao-tools/lib/cc-telem.c') diff --git a/ao-tools/ao-view/aoview_state.c b/ao-tools/ao-view/aoview_state.c index 2f613d44..21cea99a 100644 --- a/ao-tools/ao-view/aoview_state.c +++ b/ao-tools/ao-view/aoview_state.c @@ -315,6 +315,10 @@ aoview_state_notify(struct cc_telem *data) 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 date", "%04d-%02d-%02d", + state->gps.gps_time.year, + state->gps.gps_time.month, + state->gps.gps_time.day); aoview_table_add_row(1, "GPS time", "%02d:%02d:%02d", state->gps.gps_time.hour, state->gps.gps_time.minute, diff --git a/ao-tools/lib/cc-telem.c b/ao-tools/lib/cc-telem.c index 0e1483f7..9a2f6155 100644 --- a/ao-tools/lib/cc-telem.c +++ b/ao-tools/lib/cc-telem.c @@ -127,6 +127,7 @@ cc_telem_parse(const char *input_line, struct cc_telem *telem) if (strcmp (words[36], "unlocked") == 0) { telem->gps.gps_connected = 1; telem->gps.gps_locked = 0; + telem->gps.gps_time.year = telem->gps.gps_time.month = telem->gps.gps_time.day = 0; telem->gps.gps_time.hour = telem->gps.gps_time.minute = telem->gps.gps_time.second = 0; telem->gps.lat = telem->gps.lon = 0; telem->gps.alt = 0; @@ -134,6 +135,16 @@ cc_telem_parse(const char *input_line, struct cc_telem *telem) } else if (nword >= 40) { telem->gps.gps_locked = 1; telem->gps.gps_connected = 1; + if (version >= 2) { + sscanf(words[36], "%d-%d-%d", + &telem->gps.gps_time.year, + &telem->gps.gps_time.month, + &telem->gps.gps_time.day); + words += 1; + nword -= 1; + } else { + telem->gps.gps_time.year = telem->gps.gps_time.month = telem->gps.gps_time.day = 0; + } sscanf(words[36], "%d:%d:%d", &telem->gps.gps_time.hour, &telem->gps.gps_time.minute, &telem->gps.gps_time.second); cc_parse_pos(&telem->gps.lat, words[37]); cc_parse_pos(&telem->gps.lon, words[38]); @@ -142,6 +153,7 @@ cc_telem_parse(const char *input_line, struct cc_telem *telem) } else { telem->gps.gps_connected = 0; telem->gps.gps_locked = 0; + telem->gps.gps_time.year = telem->gps.gps_time.month = telem->gps.gps_time.day = 0; telem->gps.gps_time.hour = telem->gps.gps_time.minute = telem->gps.gps_time.second = 0; telem->gps.lat = telem->gps.lon = 0; telem->gps.alt = 0; diff --git a/ao-tools/lib/cc.h b/ao-tools/lib/cc.h index b8e3c061..ebc0db7d 100644 --- a/ao-tools/lib/cc.h +++ b/ao-tools/lib/cc.h @@ -192,6 +192,9 @@ struct cc_flightcooked { struct cc_gps_time { + int year; + int month; + int day; int hour; int minute; int second; diff --git a/src/ao.h b/src/ao.h index f266ac64..c1a0f6e3 100644 --- a/src/ao.h +++ b/src/ao.h @@ -493,6 +493,7 @@ ao_ee_init(void); #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) @@ -538,6 +539,11 @@ struct ao_log_record { uint8_t state; uint8_t c_n; } gps_sat; + struct { + uint8_t year; + uint8_t month; + uint8_t day; + } gps_date; struct { uint16_t d0; uint16_t d1; @@ -720,8 +726,12 @@ ao_serial_init(void); #define AO_GPS_VALID (1 << 4) #define AO_GPS_RUNNING (1 << 5) +#define AO_GPS_DATE_VALID (1 << 6) struct ao_gps_data { + uint8_t year; + uint8_t month; + uint8_t day; uint8_t hour; uint8_t minute; uint8_t second; diff --git a/src/ao_gps_print.c b/src/ao_gps_print.c index cc751337..95439ec7 100644 --- a/src/ao_gps_print.c +++ b/src/ao_gps_print.c @@ -53,6 +53,10 @@ ao_gps_print(__xdata struct ao_gps_data *gps_data) __reentrant ao_gps_split(gps_data->latitude, &lat); ao_gps_split(gps_data->longitude, &lon); + printf(" 20%02d-%02d-%02d", + gps_data->year, + gps_data->month, + gps_data->day); printf(" %2d:%02d:%02d", gps_data->hour, gps_data->minute, diff --git a/src/ao_gps_report.c b/src/ao_gps_report.c index 75c944f5..e3e27523 100644 --- a/src/ao_gps_report.c +++ b/src/ao_gps_report.c @@ -22,6 +22,7 @@ ao_gps_report(void) { static __xdata struct ao_log_record gps_log; static __xdata struct ao_gps_data gps_data; + uint8_t date_reported = 0; for (;;) { ao_sleep(&ao_gps_data); @@ -49,6 +50,14 @@ ao_gps_report(void) gps_log.u.gps_altitude.altitude = gps_data.altitude; gps_log.u.gps_altitude.unused = 0xffff; ao_log_data(&gps_log); + if (!date_reported && (gps_data.flags & AO_GPS_DATE_VALID)) { + date_reported = 1; + gps_log.type = AO_LOG_GPS_DATE; + gps_log.u.gps_date.year = gps_data.year; + gps_log.u.gps_date.month = gps_data.month; + gps_log.u.gps_date.day = gps_data.day; + ao_log_data(&gps_log); + } } } @@ -71,8 +80,7 @@ ao_gps_tracking_report(void) gps_log.tick = ao_time(); gps_log.type = AO_LOG_GPS_SAT; for (c = 0; c < n; c++) - if ((gps_log.u.gps_sat.svid = gps_tracking_data.sats[c].svid) && - (gps_log.u.gps_sat.state = gps_tracking_data.sats[c].state)) + if ((gps_log.u.gps_sat.svid = gps_tracking_data.sats[c].svid)) { gps_log.u.gps_sat.c_n = gps_tracking_data.sats[c].c_n_1; ao_log_data(&gps_log); diff --git a/src/ao_gps_skytraq.c b/src/ao_gps_skytraq.c index cd5f78b9..b2eef04b 100644 --- a/src/ao_gps_skytraq.c +++ b/src/ao_gps_skytraq.c @@ -19,9 +19,9 @@ #include "ao.h" #endif -#define AO_GPS_LEADER 3 +#define AO_GPS_LEADER 2 -static const char ao_gps_header[] = "GPG"; +static const char ao_gps_header[] = "GP"; __xdata uint8_t ao_gps_mutex; static __xdata char ao_gps_char; @@ -32,6 +32,7 @@ __xdata struct ao_gps_data ao_gps_data; __xdata struct ao_gps_tracking_data ao_gps_tracking_data; static __xdata struct ao_gps_data ao_gps_next; +static __xdata uint8_t ao_gps_date_flags; static __xdata struct ao_gps_tracking_data ao_gps_tracking_next; static const char ao_gps_config[] = { @@ -181,7 +182,7 @@ ao_gps_parse_flag(char no_c, char yes_c) __reentrant void ao_gps(void) __reentrant { - char c; + char a, c; uint8_t i; ao_serial_set_speed(AO_SERIAL_SPEED_9600); @@ -198,7 +199,7 @@ ao_gps(void) __reentrant ao_gps_cksum = 0; ao_gps_error = 0; - /* Skip anything other than GPG */ + /* Skip anything other than GP */ for (i = 0; i < AO_GPS_LEADER; i++) { ao_gps_lexchar(); if (ao_gps_char != ao_gps_header[i]) @@ -209,6 +210,8 @@ ao_gps(void) __reentrant /* pull the record identifier characters off the link */ ao_gps_lexchar(); + a = ao_gps_char; + ao_gps_lexchar(); c = ao_gps_char; ao_gps_lexchar(); i = ao_gps_char; @@ -216,7 +219,7 @@ ao_gps(void) __reentrant if (ao_gps_char != ',') continue; - if (c == (uint8_t) 'G' && i == (uint8_t) 'A') { + if (a == (uint8_t) 'G' && c == (uint8_t) 'G' && i == (uint8_t) 'A') { /* Now read the data into the gps data record * * $GPGGA,025149.000,4528.1723,N,12244.2480,W,1,05,2.0,103.5,M,-19.5,M,,0000*66 @@ -245,7 +248,7 @@ ao_gps(void) __reentrant * *66 checksum */ - ao_gps_next.flags = AO_GPS_RUNNING; + ao_gps_next.flags = AO_GPS_RUNNING | ao_gps_date_flags; ao_gps_next.hour = ao_gps_decimal(2); ao_gps_next.minute = ao_gps_decimal(2); ao_gps_next.second = ao_gps_decimal(2); @@ -290,7 +293,7 @@ ao_gps(void) __reentrant ao_mutex_put(&ao_gps_mutex); ao_wakeup(&ao_gps_data); } - } else if (c == (uint8_t) 'S' && i == (uint8_t) 'V') { + } else if (a == (uint8_t) 'G' && c == (uint8_t) 'S' && i == (uint8_t) 'V') { uint8_t done; /* Now read the data into the GPS tracking data record * @@ -345,6 +348,56 @@ ao_gps(void) __reentrant ao_mutex_put(&ao_gps_mutex); ao_wakeup(&ao_gps_tracking_data); } + } else if (a == (uint8_t) 'R' && c == (uint8_t) 'M' && i == (uint8_t) 'C') { + /* Parse the RMC record to read out the current date */ + + /* $GPRMC,111636.932,A,2447.0949,N,12100.5223,E,000.0,000.0,030407,,,A*61 + * + * Recommended Minimum Specific GNSS Data + * + * 111636.932 UTC time 11:16:36.932 + * A Data Valid (V = receiver warning) + * 2447.0949 Latitude + * N North/south indicator + * 12100.5223 Longitude + * E East/west indicator + * 000.0 Speed over ground + * 000.0 Course over ground + * 030407 UTC date (ddmmyy format) + * A Mode indicator: + * N = data not valid + * A = autonomous mode + * D = differential mode + * E = estimated (dead reckoning) mode + * M = manual input mode + * S = simulator mode + * 61 checksum + */ + ao_gps_skip_field(); + for (i = 0; i < 8; i++) { + ao_gps_lexchar(); + ao_gps_skip_field(); + } + a = ao_gps_decimal(2); + c = ao_gps_decimal(2); + i = ao_gps_decimal(2); + /* Skip remaining fields */ + while (ao_gps_char != '*' && ao_gps_char != '\n' && ao_gps_char != '\r') { + ao_gps_lexchar(); + ao_gps_skip_field(); + } + if (ao_gps_char == '*') { + uint8_t cksum = ao_gps_cksum ^ '*'; + if (cksum != ao_gps_hex(2)) + ao_gps_error = 1; + } else + ao_gps_error = 1; + if (!ao_gps_error) { + ao_gps_next.year = i; + ao_gps_next.month = c; + ao_gps_next.day = a; + ao_gps_date_flags = AO_GPS_DATE_VALID; + } } } } diff --git a/src/ao_gps_test.c b/src/ao_gps_test.c index 366bca71..3692f0e5 100644 --- a/src/ao_gps_test.c +++ b/src/ao_gps_test.c @@ -27,8 +27,12 @@ #define AO_GPS_VALID (1 << 4) #define AO_GPS_RUNNING (1 << 5) +#define AO_GPS_DATE_VALID (1 << 6) struct ao_gps_data { + uint8_t year; + uint8_t month; + uint8_t day; uint8_t hour; uint8_t minute; uint8_t second; diff --git a/src/ao_gps_test_skytraq.c b/src/ao_gps_test_skytraq.c index 510bc419..ccf96378 100644 --- a/src/ao_gps_test_skytraq.c +++ b/src/ao_gps_test_skytraq.c @@ -27,8 +27,12 @@ #define AO_GPS_VALID (1 << 4) #define AO_GPS_RUNNING (1 << 5) +#define AO_GPS_DATE_VALID (1 << 6) struct ao_gps_data { + uint8_t year; + uint8_t month; + uint8_t day; uint8_t hour; uint8_t minute; uint8_t second; -- cgit v1.2.3 From b0d7e3f9c9322542e9b649bb6ad7f7e5bb99dffa Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 15 Nov 2009 16:20:18 -0800 Subject: Stop using SiRF state info. With the switch to the skytraq GPS unit, we don't have the same level of detail in the GPS stream, so stop reporting that in the telemetry stream, in the UI and writing it to eeprom. Signed-off-by: Keith Packard --- ao-tools/ao-postflight/ao-postflight.c | 4 ++-- ao-tools/lib/cc-logfile.c | 1 - ao-tools/lib/cc-telem.c | 17 ++++++++++++----- ao-tools/lib/cc.h | 1 - src/ao.h | 12 +----------- src/ao_gps_print.c | 7 +++---- src/ao_gps_sirf.c | 5 +---- src/ao_gps_skytraq.c | 6 ++---- src/ao_gps_test.c | 5 ++--- 9 files changed, 23 insertions(+), 35 deletions(-) (limited to 'ao-tools/lib/cc-telem.c') diff --git a/ao-tools/ao-postflight/ao-postflight.c b/ao-tools/ao-postflight/ao-postflight.c index 733eb38c..c12939aa 100644 --- a/ao-tools/ao-postflight/ao-postflight.c +++ b/ao-tools/ao-postflight/ao-postflight.c @@ -360,7 +360,7 @@ analyse_flight(struct cc_flightraw *f, FILE *summary_file, FILE *detail_file, nsat = 0; for (k = 0; k < f->gps.sats[j].nsat; k++) { fprintf (gps_file, " %12.7f", (double) f->gps.sats[j].sat[k].c_n); - if (f->gps.sats[j].sat[k].state == 0xbf) + if (f->gps.sats[j].sat[k].svid != 0) nsat++; } fprintf(gps_file, " %d\n", nsat); @@ -381,7 +381,7 @@ 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].state == 0xbf) + if (f->gps.sats[j].sat[k].svid != 0) nsat++; fprintf(kml_file, "%12.7f, %12.7f, %12.7f ", diff --git a/ao-tools/lib/cc-logfile.c b/ao-tools/lib/cc-logfile.c index 3d346bcc..9d086c82 100644 --- a/ao-tools/lib/cc-logfile.c +++ b/ao-tools/lib/cc-logfile.c @@ -212,7 +212,6 @@ read_eeprom(const char *line, struct cc_flightraw *f, double *ground_pres, int * case AO_LOG_GPS_SAT: sat.time = tick; sat.svid = a; - sat.state = (b & 0xff); sat.c_n = (b >> 8) & 0xff; gpssat_add(&f->gps, &sat); break; diff --git a/ao-tools/lib/cc-telem.c b/ao-tools/lib/cc-telem.c index 9a2f6155..ccd40ac2 100644 --- a/ao-tools/lib/cc-telem.c +++ b/ao-tools/lib/cc-telem.c @@ -178,18 +178,25 @@ cc_telem_parse(const char *input_line, struct cc_telem *telem) } if (tracking_pos >= 0 && nword >= tracking_pos + 2 && strcmp(words[tracking_pos], "SAT") == 0) { int c, n, pos; + int per_sat; + int state; + + if (version >= 2) + per_sat = 2; + else + per_sat = 3; cc_parse_int(&n, words[tracking_pos + 1]); pos = tracking_pos + 2; - if (nword >= pos + n * 3) { + if (nword >= pos + n * per_sat) { telem->gps_tracking.channels = n; for (c = 0; c < n; c++) { cc_parse_int(&telem->gps_tracking.sats[c].svid, words[pos + 0]); - cc_parse_hex(&telem->gps_tracking.sats[c].state, - words[pos + 1]); + if (version < 2) + cc_parse_hex(&state, words[pos + 1]); cc_parse_int(&telem->gps_tracking.sats[c].c_n0, - words[pos + 2]); - pos += 3; + words[pos + per_sat - 1]); + pos += per_sat; } } else { telem->gps_tracking.channels = 0; diff --git a/ao-tools/lib/cc.h b/ao-tools/lib/cc.h index ebc0db7d..0e8ced8a 100644 --- a/ao-tools/lib/cc.h +++ b/ao-tools/lib/cc.h @@ -103,7 +103,6 @@ struct cc_gpselt { struct cc_gpssat { double time; uint16_t svid; - uint8_t state; uint8_t c_n; }; diff --git a/src/ao.h b/src/ao.h index c1a0f6e3..b72cac5c 100644 --- a/src/ao.h +++ b/src/ao.h @@ -536,7 +536,7 @@ struct ao_log_record { } gps_altitude; struct { uint16_t svid; - uint8_t state; + uint8_t unused; uint8_t c_n; } gps_sat; struct { @@ -747,18 +747,8 @@ struct ao_gps_data { uint16_t 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 ao_gps_sat_data { uint8_t svid; - uint8_t state; uint8_t c_n_1; }; diff --git a/src/ao_gps_print.c b/src/ao_gps_print.c index 95439ec7..b8b73cd2 100644 --- a/src/ao_gps_print.c +++ b/src/ao_gps_print.c @@ -112,17 +112,16 @@ ao_gps_tracking_print(__xdata struct ao_gps_tracking_data *gps_tracking_data) __ sat = gps_tracking_data->sats; v = 0; for (c = 0; c < n; c++) { - if (sat->svid && sat->state) + if (sat->svid) v++; sat++; } printf("%d ", v); sat = gps_tracking_data->sats; for (c = 0; c < n; c++) { - if (sat->svid && sat->state) - printf (" %3d %02x %3d", + if (sat->svid) + printf (" %3d %3d", sat->svid, - sat->state, sat->c_n_1); sat++; } diff --git a/src/ao_gps_sirf.c b/src/ao_gps_sirf.c index 58438760..eb00224c 100644 --- a/src/ao_gps_sirf.c +++ b/src/ao_gps_sirf.c @@ -108,7 +108,6 @@ static __xdata struct sirf_geodetic_nav_data ao_sirf_data; struct sirf_measured_sat_data { uint8_t svid; - uint16_t state; uint8_t c_n_1; }; @@ -264,8 +263,7 @@ static const struct sirf_packet_parse measured_tracker_data_packet[] = { static const struct sirf_packet_parse measured_sat_data_packet[] = { { SIRF_U8, offsetof (struct sirf_measured_sat_data, svid) }, /* 0 SV id */ - { SIRF_DISCARD, 2 }, /* 1 azimuth, 2 elevation */ - { SIRF_U16, offsetof (struct sirf_measured_sat_data, state) }, /* 2 state */ + { SIRF_DISCARD, 4 }, /* 1 azimuth, 2 elevation, 3 state */ { SIRF_U8, offsetof (struct sirf_measured_sat_data, c_n_1) }, /* C/N0 1 */ { SIRF_DISCARD, 9 }, /* C/N0 2-10 */ { SIRF_END, 0 }, @@ -421,7 +419,6 @@ ao_gps(void) __reentrant ao_gps_tracking_data.channels = ao_sirf_tracker_data.channels; for (i = 0; i < 12; i++) { ao_gps_tracking_data.sats[i].svid = ao_sirf_tracker_data.sats[i].svid; - ao_gps_tracking_data.sats[i].state = (uint8_t) ao_sirf_tracker_data.sats[i].state; ao_gps_tracking_data.sats[i].c_n_1 = ao_sirf_tracker_data.sats[i].c_n_1; } ao_mutex_put(&ao_gps_mutex); diff --git a/src/ao_gps_skytraq.c b/src/ao_gps_skytraq.c index b2eef04b..bf192f28 100644 --- a/src/ao_gps_skytraq.c +++ b/src/ao_gps_skytraq.c @@ -326,10 +326,8 @@ ao_gps(void) __reentrant ao_gps_skip_field(); /* elevation */ ao_gps_lexchar(); ao_gps_skip_field(); /* azimuth */ - if (ao_gps_tracking_next.sats[i].c_n_1 = ao_gps_decimal(2)) /* C/N0 */ - ao_gps_tracking_next.sats[i].state = 0xbf; - else - ao_gps_tracking_next.sats[i].state = 0; + if (!(ao_gps_tracking_next.sats[i].c_n_1 = ao_gps_decimal(2))) /* C/N0 */ + ao_gps_tracking_next.sats[i].svid = 0; ao_gps_tracking_next.channels = i + 1; } if (ao_gps_char == '*') { diff --git a/src/ao_gps_test.c b/src/ao_gps_test.c index 3692f0e5..fddfedfd 100644 --- a/src/ao_gps_test.c +++ b/src/ao_gps_test.c @@ -59,7 +59,6 @@ struct ao_gps_data { struct ao_gps_sat_data { uint8_t svid; - uint8_t state; uint8_t c_n_1; }; @@ -435,9 +434,9 @@ ao_dump_state(void *wchan) printf("\n"); printf ("\t"); for (i = 0; i < 12; i++) - printf (" %2d(%02x)", + printf (" %2d(%02d)", ao_gps_tracking_data.sats[i].svid, - ao_gps_tracking_data.sats[i].state); + ao_gps_tracking_data.sats[i].c_n_1); printf ("\n"); } -- cgit v1.2.3 From a9ec6be0e92dee01f7aac006ef6f7779c1da1b36 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 3 Jul 2010 17:42:36 -0400 Subject: Telemetry code was mis-computing RSSI The RSSI data from the hardware reports in 1/2 dBm increments, and so must be divided to report plain RSSI numbers. Signed-off-by: Keith Packard --- ao-tools/lib/cc-telem.c | 4 ++++ configure.ac | 2 ++ src/ao.h | 2 +- src/ao_monitor.c | 10 +++++++--- 4 files changed, 14 insertions(+), 4 deletions(-) (limited to 'ao-tools/lib/cc-telem.c') diff --git a/ao-tools/lib/cc-telem.c b/ao-tools/lib/cc-telem.c index ccd40ac2..aa52b7c5 100644 --- a/ao-tools/lib/cc-telem.c +++ b/ao-tools/lib/cc-telem.c @@ -101,6 +101,10 @@ cc_telem_parse(const char *input_line, struct cc_telem *telem) telem->flight = 0; cc_parse_int(&telem->rssi, words[5]); + if (version <= 2) { + /* Older telemetry versions mis-computed the rssi value */ + telem->rssi = (telem->rssi + 74) / 2 - 74; + } cc_parse_string(telem->state, sizeof (telem->state), words[9]); cc_parse_int(&telem->tick, words[10]); cc_parse_int(&telem->accel, words[12]); diff --git a/configure.ac b/configure.ac index d6c8682b..fafc6b34 100644 --- a/configure.ac +++ b/configure.ac @@ -77,6 +77,8 @@ PKG_CHECK_MODULES([ALSA], [alsa]) PKG_CHECK_MODULES([PLPLOT], [plplotd]) +PKG_CHECK_MODULES([SNDFILE], [sndfile]) + AC_OUTPUT([ Makefile ao-tools/Makefile diff --git a/src/ao.h b/src/ao.h index a2dfadd0..dfff8a8d 100644 --- a/src/ao.h +++ b/src/ao.h @@ -804,7 +804,7 @@ ao_gps_report_init(void); */ #define AO_MAX_CALLSIGN 8 -#define AO_TELEMETRY_VERSION 2 +#define AO_TELEMETRY_VERSION 3 struct ao_telemetry { uint8_t addr; diff --git a/src/ao_monitor.c b/src/ao_monitor.c index f2f3fc2e..f019d3b4 100644 --- a/src/ao_monitor.c +++ b/src/ao_monitor.c @@ -26,6 +26,7 @@ ao_monitor(void) __xdata struct ao_radio_recv recv; __xdata char callsign[AO_MAX_CALLSIGN+1]; uint8_t state; + int16_t rssi; for (;;) { __critical while (!ao_monitoring) @@ -33,6 +34,9 @@ ao_monitor(void) if (!ao_radio_recv(&recv)) continue; state = recv.telemetry.flight_state; + + /* Typical RSSI offset for 38.4kBaud at 433 MHz is 74 */ + rssi = (int16_t) (recv.rssi >> 1) - 74; memcpy(callsign, recv.telemetry.callsign, AO_MAX_CALLSIGN); if (state > ao_flight_invalid) state = ao_flight_invalid; @@ -42,7 +46,7 @@ ao_monitor(void) callsign, recv.telemetry.addr, recv.telemetry.flight, - (int) recv.rssi - 74, recv.status, + rssi, recv.status, ao_state_names[state]); printf("%5u a: %5d p: %5d t: %5d v: %5d d: %5d m: %5d " "fa: %5d ga: %d fv: %7ld fp: %5d gp: %5d a+: %5d a-: %5d ", @@ -64,9 +68,9 @@ ao_monitor(void) putchar(' '); ao_gps_tracking_print(&recv.telemetry.gps_tracking); putchar('\n'); - ao_rssi_set((int) recv.rssi - 74); + ao_rssi_set(rssi); } else { - printf("CRC INVALID RSSI %3d\n", (int) recv.rssi - 74); + printf("CRC INVALID RSSI %3d\n", rssi); } ao_usb_flush(); ao_led_toggle(ao_monitor_led); -- cgit v1.2.3