From 06f4076fcf97911c97c296ca7cf2fc36ab6d9680 Mon Sep 17 00:00:00 2001
From: Michal Ludvig <mludvig@logix.net.nz>
Date: Sun, 18 Jul 2010 13:15:07 +0000
Subject: [PATCH] * buspirate.c: Added compatibility with BusPirate "NewUI"
 firmware 5.x   (contributed by Kari Knuuttila)

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@946 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 avrdude/ChangeLog   | 7 ++++++-
 avrdude/buspirate.c | 9 +++++++--
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/avrdude/ChangeLog b/avrdude/ChangeLog
index e6dc5efb..7c7e7f49 100644
--- a/avrdude/ChangeLog
+++ b/avrdude/ChangeLog
@@ -1,5 +1,10 @@
+2010-07-19  Michal Ludvig <mludvig@logix.net.nz>
+
+	* buspirate.c: Added compatibility with BusPirate "NewUI" firmware 5.x
+	  (contributed by Kari Knuuttila)
+
 2010-07-12  Nils Springob <nils@nicai-systems.de>
-        
+
 	* avrdude.conf.in (atmega88p): New device.
 
 2010-06-03  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
diff --git a/avrdude/buspirate.c b/avrdude/buspirate.c
index af8de155..d57b9c3c 100644
--- a/avrdude/buspirate.c
+++ b/avrdude/buspirate.c
@@ -256,8 +256,9 @@ static int buspirate_send(struct programmer_t *pgm, char *str)
 
 static int buspirate_is_prompt(char *str)
 {
-	/* Prompt ends with '>' all other input probably ends with '\n' */
-	return (str[strlen(str) - 1] == '>');
+	/* Prompt ends with '>' or '> '
+	 * all other input probably ends with '\n' */
+	return (str[strlen(str) - 1] == '>' || str[strlen(str) - 2] == '>');
 }
 
 static int buspirate_expect(struct programmer_t *pgm, char *send,
@@ -536,6 +537,7 @@ static int buspirate_start_spi_mode_ascii(struct programmer_t *pgm)
 static void buspirate_enable(struct programmer_t *pgm)
 {
 	unsigned char *reset_str = "#\n";
+	unsigned char *accept_str = "y\n";
 	char *rcvd;
 	int fw_v1 = 0, fw_v2 = 0;
 	int rc, print_banner = 0;
@@ -559,6 +561,9 @@ static void buspirate_enable(struct programmer_t *pgm)
 			buspirate_enable(pgm);
 			return;
 		}
+		if (strncmp(rcvd, "Are you sure?", 13) == 0) {
+			buspirate_send_bin(pgm, accept_str, strlen(accept_str));
+		}
 		if (strncmp(rcvd, "RESET", 5) == 0) {
 			print_banner = 1;
 			continue;