changeset 1985:b6d1bd49a61d

Better handling of Y-modem (^Z chars) - from David Vrabel
author gthomas
date Fri, 10 Jun 2005 13:25:59 +0000
parents f199806a09e0
children e256aea3e373
files packages/redboot/current/ChangeLog packages/redboot/current/src/xyzModem.c
diffstat 2 files changed, 14 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/packages/redboot/current/ChangeLog
+++ b/packages/redboot/current/ChangeLog
@@ -1,3 +1,11 @@
+2005-06-09  David Vrabel  <dvrabel@arcom.com>
+
+	* src/xyzModem.c: Use the Ymodem length field by #define'ing
+	USE_YMODEM_LENGTH.
+	(xyzModem_stream_read): Only discard runs of ^Z's if we're using
+	Xmodem or the Ymodem length field is 0.  This allows binary files
+	with runs of ^Z's to be transferred.
+
 2005-06-07  Andrew Lunn  <andrew.lunn@ascom.ch>
 
 	* src/flash.c (_flash_info): Fixed a warning about a diag_printf
--- a/packages/redboot/current/src/xyzModem.c
+++ b/packages/redboot/current/src/xyzModem.c
@@ -68,7 +68,7 @@
 #define CAN 0x18
 #define EOF 0x1A  // ^Z for DOS officionados
 
-#define nUSE_YMODEM_LENGTH
+#define USE_YMODEM_LENGTH
 
 // Data & state local to the protocol
 static struct {
@@ -416,13 +416,14 @@ xyzModem_stream_read(char *buf, int size
                         xyz.tx_ack = true;
                         ZM_DEBUG(zm_dprintf("ACK block %d (%d)\n", xyz.blk, __LINE__));
                         xyz.next_blk = (xyz.next_blk + 1) & 0xFF;
-                        // Data blocks can be padded with ^Z (EOF) characters
-                        // This code tries to detect and remove them
-#ifdef xyzModem_zmodem
-                        if (xyz.mode != xyzModem_zmodem) {
+
+#if defined(xyzModem_zmodem) || defined(USE_YMODEM_LENGTH)
+                        if (xyz.mode == xyzModem_xmodem || xyz.file_length == 0) {
 #else
                         if (1) {
 #endif
+                            // Data blocks can be padded with ^Z (EOF) characters
+                            // This code tries to detect and remove them
                             if ((xyz.bufp[xyz.len-1] == EOF) &&
                                 (xyz.bufp[xyz.len-2] == EOF) &&
                                 (xyz.bufp[xyz.len-3] == EOF)) {