altos: flush pending output when terminating packet mode
authorKeith Packard <keithp@keithp.com>
Mon, 30 Aug 2010 05:41:18 +0000 (22:41 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 30 Aug 2010 05:41:18 +0000 (22:41 -0700)
Just in case the last command sent hasn't been transmitted, hang
around for up to a second waiting for the data to get across the link.

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

index 72bb908..5e13a91 100644 (file)
@@ -121,6 +121,10 @@ ao_packet_forward(void) __reentrant
                if (c == '\r') c = '\n';
                ao_packet_putchar(c);
        }
+
+       /* Wait for a second if there is any pending data */
+       for (c = 0; (ao_packet_tx_used || ao_tx_packet.len) && c < 10; c++)
+               ao_delay(AO_MS_TO_TICKS(100));
        ao_packet_enable = 0;
        ao_radio_abort();
        while (ao_packet_echo_task.wchan || ao_packet_task.wchan) {