altos: TM: Don't turn on packet slave mode until idle/invalid state
authorKeith Packard <keithp@keithp.com>
Wed, 28 Sep 2011 04:06:54 +0000 (21:06 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 7 Oct 2011 14:37:02 +0000 (08:37 -0600)
Leave the packet link disabled until we've checked the
accelerometer. That way, we cannot accidentally get to idle mode when
the rocket is on the rail.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/ao_flight.c
src/ao_packet_slave.c
src/ao_telemetrum.c

index 85c1825bddfebf68c06f2d2b055c511eddae4164..0a9cc046f2c946e74585c6bd307a5dbe148e96f3 100644 (file)
@@ -91,6 +91,8 @@ ao_flight(void)
                                 */
                                ao_flight_state = ao_flight_invalid;
 
+                               /* Turn on packet system in invalid mode on TeleMetrum */
+                               ao_packet_slave_start();
                        } else
 #endif
                                if (!ao_flight_force_idle
@@ -108,8 +110,10 @@ ao_flight(void)
                                ao_usb_disable();
 #endif
 
-                               /* Disable packet mode in pad state */
+#if !HAS_ACCEL
+                               /* Disable packet mode in pad state on TeleMini */
                                ao_packet_slave_stop();
+#endif
 
                                /* Turn on telemetry system */
                                ao_rdf_set(1);
@@ -121,6 +125,11 @@ ao_flight(void)
                                /* Set idle mode */
                                ao_flight_state = ao_flight_idle;
  
+#if HAS_ACCEL
+                               /* Turn on packet system in idle mode on TeleMetrum */
+                               ao_packet_slave_start();
+#endif
+
                                /* signal successful initialization by turning off the LED */
                                ao_led_off(AO_LED_RED);
                        }
index 9f14052af406c9293b3fbeeb7a73b92c3fff438c..d7cafa680d5a7a470de654ae3eae73ed8743afd6 100644 (file)
@@ -37,8 +37,10 @@ ao_packet_slave(void)
 void
 ao_packet_slave_start(void)
 {
-       ao_packet_enable = 1;
-       ao_add_task(&ao_packet_task, ao_packet_slave, "slave");
+       if (!ao_packet_enable) {
+               ao_packet_enable = 1;
+               ao_add_task(&ao_packet_task, ao_packet_slave, "slave");
+       }
 }
 
 void
index f560740a455eb26484234478246063389c172c39..ea77f5afe83e55c5a5808fe50cb023ea194f48f2 100644 (file)
@@ -57,7 +57,7 @@ main(void)
        ao_gps_report_init();
        ao_telemetry_init();
        ao_radio_init();
-       ao_packet_slave_init(TRUE);
+       ao_packet_slave_init(FALSE);
        ao_igniter_init();
 #if HAS_DBG
        ao_dbg_init();