From d8363d853cca327be948d2691a336436cace02bb Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Thu, 23 Jun 2011 13:17:31 -0300 Subject: [PATCH] tools/lib/misctxrx.c (wait_for_interrupt): enforce a minimum timeout of 10 ms Seems that just one millisecond isn't enough to get a byte from the USB device, even if the byte is already waiting in the endpoint FIFO there. --- tools/lib/misctxrx.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/lib/misctxrx.c b/tools/lib/misctxrx.c index 786f038..216c8e2 100644 --- a/tools/lib/misctxrx.c +++ b/tools/lib/misctxrx.c @@ -24,6 +24,9 @@ #include "misctxrx.h" +#define MIN_TIMEOUT_MS 10 + + /* ----- Interrupts -------------------------------------------------------- */ @@ -59,8 +62,11 @@ uint8_t wait_for_interrupt(struct atrf_dsc *dsc, uint8_t wait_for, sigint = 0; old_sig = signal(SIGINT, die); - if (timeout_ms) + if (timeout_ms) { + if (timeout_ms < MIN_TIMEOUT_MS) + timeout_ms = MIN_TIMEOUT_MS; timeout_start(&to, timeout_ms); + } while (!sigint && !timedout) { while (!sigint && !timedout) { if (timeout_ms) {