From 6af6fe9b3a0c1f17edd70408e8b49fcebbe67fa7 Mon Sep 17 00:00:00 2001
From: Joerg Wunsch <j@uriah.heep.sax.de>
Date: Wed, 11 May 2005 16:58:12 +0000
Subject: [PATCH] Make the retrier in case of rx timeouts more robust, by
 increasing the receive timeout once a timeout happened.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@458 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 avrdude/jtagmkII.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/avrdude/jtagmkII.c b/avrdude/jtagmkII.c
index dca287a7..d3f8d357 100644
--- a/avrdude/jtagmkII.c
+++ b/avrdude/jtagmkII.c
@@ -1234,8 +1234,10 @@ static int jtagmkII_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
 		"%s: jtagmkII_paged_write(): "
 		"timeout/error communicating with programmer (status %d)\n",
 		progname, status);
-      if (tries++ < 3)
+      if (tries++ < 4) {
+	serial_recv_timeout *= 2;
 	goto retry;
+      }
       fprintf(stderr,
 	      "%s: jtagmkII_paged_write(): fatal timeout/"
 	      "error communicating with programmer (status %d)\n",
@@ -1326,8 +1328,10 @@ static int jtagmkII_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
 		"%s: jtagmkII_paged_load(): "
 		"timeout/error communicating with programmer (status %d)\n",
 		progname, status);
-      if (tries++ < 3)
+      if (tries++ < 4) {
+	serial_recv_timeout *= 2;
 	goto retry;
+      }
       fprintf(stderr,
 	      "%s: jtagmkII_paged_load(): fatal timeout/"
 	      "error communicating with programmer (status %d)\n",