Fix for bug 15218 - iAP detect sequence can fail after rapid reconnection attempts. On reset drain the c_iap channel of old data until the iAP core returns a reset token.

This commit is contained in:
Sam Chesney
2014-02-06 11:48:59 +00:00
parent ef52f39b7f
commit f625904415

View File

@@ -170,6 +170,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
int iap_data_remaining_to_device = 0; int iap_data_remaining_to_device = 0;
int iap_data_collected_from_device = 0; int iap_data_collected_from_device = 0;
int iap_expected_data_length = 0; int iap_expected_data_length = 0;
int iap_draining_chan = 0;
#endif #endif
@@ -555,7 +556,8 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
else if(tmp==-1) else if(tmp==-1)
{ {
XUD_ResetEndpoint(ep_iap_from_host, null); XUD_ResetEndpoint(ep_iap_from_host, null);
iap_send_reset(c_iap); // What if this happen in the middle of a send/ack? iap_send_reset(c_iap);
iap_draining_chan = 1; // Drain c_iap until a reset is sent back
iap_data_collected_from_device = 0; iap_data_collected_from_device = 0;
iap_data_remaining_to_device = -1; iap_data_remaining_to_device = -1;
iap_expected_data_length = 0; iap_expected_data_length = 0;
@@ -644,6 +646,17 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
/* Received word from iap thread - Check for ACK or Data */ /* Received word from iap thread - Check for ACK or Data */
case iap_get_ack_or_reset_or_data(c_iap, is_ack_iap, is_reset, datum_iap): case iap_get_ack_or_reset_or_data(c_iap, is_ack_iap, is_reset, datum_iap):
if (iap_draining_chan)
{
/* As we're draining the iAP channel now, ignore ACKs and data */
if (is_reset)
{
// The iAP core has returned a reset token, so we can stop draining the iAP channel now
iap_draining_chan = 0;
}
}
else
{
if (is_ack_iap) if (is_ack_iap)
{ {
/* An ack from the iap/uart thread means it has accepted some data we sent it /* An ack from the iap/uart thread means it has accepted some data we sent it
@@ -662,7 +675,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
iap_data_remaining_to_device -= 1; iap_data_remaining_to_device -= 1;
} }
} }
else else if (!is_reset)
{ {
if (iap_expected_data_length == 0) if (iap_expected_data_length == 0)
{ {
@@ -699,6 +712,7 @@ void buffer(register chanend c_aud_out, register chanend c_aud_in, chanend c_aud
} }
} }
} }
}
break; break;
#endif #endif