diff options
author | Keith Packard <keithp@keithp.com> | 2009-11-14 22:24:37 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2009-11-14 22:24:37 -0800 |
commit | 4cffc9c4b079e39c8196ddbaf91129cda6df7f8b (patch) | |
tree | 624fbbd5e838da5fbb0676c9e1137a911e53a81e /ao-tools/lib/cc-telem.c | |
parent | 0e0db8ca3af4c07bae909938486766c646bf580b (diff) |
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 <keithp@keithp.com>
Diffstat (limited to 'ao-tools/lib/cc-telem.c')
-rw-r--r-- | ao-tools/lib/cc-telem.c | 24 |
1 files changed, 21 insertions, 3 deletions
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; |