+ break;
+ default:
+ printf("Error %d\n", r);
+ break;
+ }
+}
+
+static void
+launch_fire_cmd(void) __reentrant
+{
+ static __xdata struct ao_launch_command command;
+ uint8_t channel;
+ uint16_t serial;
+ uint8_t secs;
+ uint8_t i;
+ int8_t r;
+ uint16_t tick_offset;
+
+ ao_cmd_decimal();
+ serial = ao_cmd_lex_i;
+ ao_cmd_decimal();
+ channel = ao_cmd_lex_i;
+ ao_cmd_decimal();
+ secs = ao_cmd_lex_i;
+ if (ao_cmd_status != ao_cmd_success)
+ return;
+ tick_offset = ao_time();
+ r = launch_query(serial, channel);
+ tick_offset -= query.tick;
+
+ for (i = 0; i < 4; i++) {
+ printf("arm %d\n", i); flush();
+ command.tick = ao_time() - tick_offset;
+ command.serial = serial;
+ command.cmd = AO_LAUNCH_ARM;
+ command.channel = channel;
+ ao_radio_cmac_send(&command, sizeof (command));
+ }
+ secs = secs * 10 - 5;
+ if (secs > 100)
+ secs = 100;
+ for (i = 0; i < secs; i++) {
+ printf("fire %d\n", i); flush();
+ command.tick = ao_time() - tick_offset;
+ command.serial = serial;
+ command.cmd = AO_LAUNCH_FIRE;
+ command.channel = 0;
+ ao_radio_cmac_send(&command, sizeof (command));
+ ao_delay(AO_MS_TO_TICKS(100));