summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2009-04-25 14:42:20 -0700
committerKeith Packard <keithp@keithp.com>2009-04-25 14:42:20 -0700
commite45fce7f82d704d677f84c69b0e07588d109d780 (patch)
tree05161a95f3c9263635cc403bf42ca63877b9c7f0
parent61510f98404bca6861b2da98f6cd9ba9deb76968 (diff)
Add RDF beacon and callsign to telemetry
-rw-r--r--ao.h18
-rw-r--r--ao_monitor.c8
-rw-r--r--ao_telemetry.c44
3 files changed, 59 insertions, 11 deletions
diff --git a/ao.h b/ao.h
index 6b861de1..338a40b0 100644
--- a/ao.h
+++ b/ao.h
@@ -29,7 +29,7 @@
/* Stack runs from above the allocated __data space to 0xfe, which avoids
* writing to 0xff as that triggers the stack overflow indicator
*/
-#define AO_STACK_START 0x7e
+#define AO_STACK_START 0x80
#define AO_STACK_END 0xfe
#define AO_STACK_SIZE (AO_STACK_END - AO_STACK_START + 1)
@@ -702,13 +702,27 @@ ao_gps_init(void);
* ao_telemetry.c
*/
+#define AO_MAX_CALLSIGN 8
+
struct ao_telemetry {
uint8_t addr;
uint8_t flight_state;
struct ao_adc adc;
struct ao_gps_data gps;
+ char callsign[AO_MAX_CALLSIGN];
};
+/* Set delay between telemetry reports (0 to disable) */
+
+#define AO_TELEMETRY_INTERVAL_FLIGHT AO_MS_TO_TICKS(50)
+#define AO_TELEMETRY_INTERVAL_RECOVER AO_MS_TO_TICKS(1000)
+
+void
+ao_telemetry_set_interval(uint16_t interval);
+
+void
+ao_rdf_set(uint8_t rdf);
+
void
ao_telemetry_init(void);
@@ -721,7 +735,7 @@ ao_radio_send(__xdata struct ao_telemetry *telemetry) __reentrant;
struct ao_radio_recv {
struct ao_telemetry telemetry;
- uint8_t rssi;
+ int8_t rssi;
uint8_t status;
};
diff --git a/ao_monitor.c b/ao_monitor.c
index 15b56f05..d62f69da 100644
--- a/ao_monitor.c
+++ b/ao_monitor.c
@@ -29,6 +29,7 @@ void
ao_monitor(void)
{
__xdata struct ao_radio_recv recv;
+ __xdata char callsign[AO_MAX_CALLSIGN+1];
uint8_t state;
for (;;) {
@@ -36,10 +37,13 @@ ao_monitor(void)
ao_sleep(&ao_monitoring);
ao_radio_recv(&recv);
state = recv.telemetry.flight_state;
+ memcpy(callsign, recv.telemetry.callsign, AO_MAX_CALLSIGN);
if (state > ao_flight_invalid)
state = ao_flight_invalid;
- printf ("SERIAL %3d RSSI %3d STATUS %02x STATE %s ",
- recv.telemetry.addr, recv.rssi, recv.status,
+ printf ("CALL %s SERIAL %3d RSSI %3d STATUS %02x STATE %s ",
+ callsign,
+ recv.telemetry.addr,
+ (int) recv.rssi - 74, recv.status,
ao_state_names[state]);
if (!(recv.status & PKT_APPEND_STATUS_1_CRC_OK))
printf("CRC INVALID ");
diff --git a/ao_telemetry.c b/ao_telemetry.c
index 752c7142..ffee9bee 100644
--- a/ao_telemetry.c
+++ b/ao_telemetry.c
@@ -19,29 +19,59 @@
/* XXX make serial numbers real */
-uint8_t ao_serial_number = 2;
+__xdata uint8_t ao_serial_number = 2;
+
+/* XXX make callsigns real */
+__xdata char ao_callsign[AO_MAX_CALLSIGN] = "KD7SQG";
+
+__xdata uint16_t ao_telemetry_interval = 0;
+__xdata uint8_t ao_rdf = 0;
+__xdata uint16_t ao_rdf_time;
+
+#define AO_RDF_INTERVAL AO_SEC_TO_TICKS(3)
void
ao_telemetry(void)
{
static __xdata struct ao_telemetry telemetry;
- static uint8_t state;
-
- while (ao_flight_state == ao_flight_startup || ao_flight_state == ao_flight_idle)
- ao_sleep(DATA_TO_XDATA(&ao_flight_state));
+ telemetry.addr = ao_serial_number;
+ memcpy(telemetry.callsign, ao_callsign, AO_MAX_CALLSIGN);
+ ao_rdf_time = ao_time();
for (;;) {
- telemetry.addr = ao_serial_number;
+ while (ao_telemetry_interval == 0)
+ ao_sleep(&ao_telemetry_interval);
telemetry.flight_state = ao_flight_state;
ao_adc_get(&telemetry.adc);
ao_mutex_get(&ao_gps_mutex);
memcpy(&telemetry.gps, &ao_gps_data, sizeof (struct ao_gps_data));
ao_mutex_put(&ao_gps_mutex);
ao_radio_send(&telemetry);
- ao_delay(AO_MS_TO_TICKS(100));
+ ao_delay(ao_telemetry_interval);
+ if (ao_rdf &&
+ (int16_t) (ao_time() - ao_rdf_time) >= 0)
+ {
+ ao_rdf_time = ao_time() + AO_RDF_INTERVAL;
+ ao_radio_rdf();
+ }
}
}
+void
+ao_telemetry_set_interval(uint16_t interval)
+{
+ ao_telemetry_interval = interval;
+ ao_wakeup(&ao_telemetry_interval);
+}
+
+void
+ao_rdf_set(uint8_t rdf)
+{
+ ao_rdf = rdf;
+ if (rdf == 0)
+ ao_radio_rdf_abort();
+}
+
__xdata struct ao_task ao_telemetry_task;
void