Skip to contentSkip to conversation

common/xyzModem.c: Fix delay timeout calculation

PATCH New Andrew F. Davis 1 participant 1 message Aug 25, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/xyzModem.c: Fix delay timeout calculation

When waiting for input in CYGACC_COMM_IF_GETC_TIMEOUT we delay 2 seconds by incrementing and checking a counter variable every 20 uSeconds. The overhead in the loop calling tstc() millions of times causes the timeout to be closer to 20 seconds. Delay longer per iteration to reduce overhead and bring the timeout back closer to the correct time.

---
 common/xyzModem.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
common/xyzModem.c +2 -3
index 5656aac..c3f2afc 100644
@@ -71,11 +71,10 @@ typedef int cyg_int32;
 static int
 CYGACC_COMM_IF_GETC_TIMEOUT (char chan, char *c)
 {
-#define DELAY 20
   unsigned long counter = 0;
-  while (!tstc () && (counter < xyzModem_CHAR_TIMEOUT * 1000 / DELAY))
+  while (!tstc () && (counter < xyzModem_CHAR_TIMEOUT))
     {
-      udelay (DELAY);
+      mdelay (1);
       counter++;
     }
   if (tstc ())
Signature · 1 line
2.9.3