Only have the slave return a packet if it received one.
authorKeith Packard <keithp@keithp.com>
Sat, 10 Apr 2010 00:51:01 +0000 (17:51 -0700)
committerKeith Packard <keithp@keithp.com>
Sat, 10 Apr 2010 00:51:01 +0000 (17:51 -0700)
When the receive is aborted to switch modes, it's important to not
immediately re-acquire the radio and try to send a packet as the
aborting thread won't know to kick the receiver again.

This prevents the 'C' command from locking up as it tries to stop the
packet slave before turning on the transmitter.

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

index 4c947fbffed989f324f24b98f08107ad6ef80a4a..e03ebdc3a20cd90475ee00ea1610b3a3a6f28260 100644 (file)
 void
 ao_packet_slave(void)
 {
 void
 ao_packet_slave(void)
 {
+       uint8_t status;
+
        ao_radio_set_packet();
        ao_tx_packet.addr = ao_serial_number;
        ao_tx_packet.len = AO_PACKET_SYN;
        while (ao_packet_enable) {
        ao_radio_set_packet();
        ao_tx_packet.addr = ao_serial_number;
        ao_tx_packet.len = AO_PACKET_SYN;
        while (ao_packet_enable) {
-               ao_packet_recv();
-               ao_packet_send();
+               status = ao_packet_recv();
+               if (status & AO_DMA_DONE)
+                       ao_packet_send();
        }
        ao_exit();
 }
        }
        ao_exit();
 }