# HG changeset patch # User Daniel O'Connor # Date 1265854679 -37800 # Node ID 9a14029b3782c45c23911fb85ec73b73a70f60ba # Parent e0b32014ed147616abc0b8aa63f7a035f62bf5f8 - Wait longer (100msec) for a read, and reduce the number of retries to match. - Print out if we read OK after more than 1 attempt for diagnostic purposes. diff -r e0b32014ed14 -r 9a14029b3782 wh1080.c --- a/wh1080.c Thu Feb 11 12:45:22 2010 +1030 +++ b/wh1080.c Thu Feb 11 12:47:59 2010 +1030 @@ -230,7 +230,7 @@ */ int read_station (char *buf) { -#define MAXTRIES 100 +#define MAXTRIES 10 int bytes_read, i = 0; /* XXX Find out what all this means, and be cleverer about retries */ @@ -240,22 +240,20 @@ USB_ENDPOINT_IN | USB_RECIP_INTERFACE, buf, 8, - 10 )) == 8 ){ - if (i > 5) + 100 )) == 8 ){ + if (i > 0) fprintf(stderr, "Read OK after %d tries\n", i + 1); return bytes_read; } - - if (errno == EAGAIN) - usleep (10000); + fprintf(stderr, "Retrying..\n"); + + usleep (10000); i++; } while (errno != EINTR && i < MAXTRIES); if (i == MAXTRIES) { -#if 0 fprintf(stderr, "Can't read from device after %d attempts\n", MAXTRIES); -#endif } else fprintf (stderr, "Can't read device: %s (%d)\n", @@ -293,9 +291,7 @@ while (bytes_read < 32) { if ((i = read_station ((char *) &buf [bytes_read])) == 0) { -#if 0 fprintf(stderr, "Couldn't read from the device, rerequesting\n"); -#endif goto rerequest; }