summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ao-tools/ao-view/aoview_state.c1
-rw-r--r--ao-tools/lib/cc-telem.c7
-rw-r--r--ao-tools/lib/cc.h1
-rw-r--r--src/ao.h11
-rw-r--r--src/ao_log.c51
-rw-r--r--src/ao_monitor.c3
-rw-r--r--src/ao_telemetry.c3
7 files changed, 34 insertions, 43 deletions
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();