altos: When slave mode first starts, accept any packet
authorKeith Packard <keithp@keithp.com>
Thu, 25 Oct 2012 06:52:49 +0000 (23:52 -0700)
committerKeith Packard <keithp@keithp.com>
Thu, 25 Oct 2012 07:07:14 +0000 (00:07 -0700)
This eliminates the packet sequence matching for the first packet,
allowing outstanding send data to arrive from the master instead of
ignoring packets with data until they match the seqno

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

index f232a87826dfbcfd6a21f2511c32e0a03d160a25..9058c347f05876ace2ce7d64cf2bb44f2102bc27 100644 (file)
@@ -48,6 +48,7 @@ extern __xdata struct ao_task ao_packet_task;
 extern __xdata uint8_t ao_packet_enable;
 extern __xdata uint8_t ao_packet_master_sleeping;
 extern __pdata uint8_t ao_packet_rx_len, ao_packet_rx_used, ao_packet_tx_used;
+extern __xdata uint8_t ao_packet_restart;
 
 void
 ao_packet_send(void);
index d813b25f27448c43c3707dc0f46d689b4024f94b..2bada949e9c04769d60c0ed8748ca3266f46ec11 100644 (file)
@@ -27,6 +27,7 @@ static __pdata uint8_t rx_seq;
 
 __xdata struct ao_task ao_packet_task;
 __xdata uint8_t ao_packet_enable;
+__xdata uint8_t ao_packet_restart;
 
 #if PACKET_HAS_MASTER
 __xdata uint8_t ao_packet_master_sleeping;
@@ -106,7 +107,8 @@ ao_packet_recv(void)
                /* Check for incoming data at the next sequence and
                 * for an empty data buffer
                 */
-               if (ao_rx_packet.packet.seq == (uint8_t) (rx_seq + (uint8_t) 1) &&
+               if ((ao_rx_packet.packet.seq == (uint8_t) (rx_seq + (uint8_t) 1) ||
+                    ao_packet_restart) &&
                    ao_packet_rx_used == ao_packet_rx_len) {
 
                        /* Copy data to the receive data buffer and set up the
@@ -126,6 +128,7 @@ ao_packet_recv(void)
                        ao_wakeup(&ao_stdin_ready);
                }
        }
+       ao_packet_restart = 0;
 
        /* If the other side has seen the latest data we queued,
         * wake up any task waiting to send data and let them go again
index fd5d443efa52a71fc92f5ec13a5529ced53aba6d..e45775cb00e1a20817c2f9a13e1e80c6e5503665 100644 (file)
@@ -22,6 +22,7 @@ ao_packet_slave(void)
 {
        ao_tx_packet.addr = ao_serial_number;
        ao_tx_packet.len = AO_PACKET_SYN;
+       ao_packet_restart = 1;
        while (ao_packet_enable) {
                if (ao_packet_recv()) {
                        ao_xmemcpy(&ao_tx_packet.callsign, &ao_rx_packet.packet.callsign, AO_MAX_CALLSIGN);