Mercurial > ~darius > hgwebdir.cgi > wh1080
changeset 7:9a14029b3782
- 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.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Thu, 11 Feb 2010 12:47:59 +1030 |
parents | e0b32014ed14 |
children | e3d2b5500b53 |
files | wh1080.c |
diffstat | 1 files changed, 6 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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; }