All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Pali Rohár" <pali@kernel.org>
To: Simon Glass <sjg@chromium.org>, Heinrich Schuchardt <xypron.glpk@gmx.de>
Cc: u-boot@lists.denx.de
Subject: [PATCH 2/2] xyz-modem: Wait infinitely for initial x-modem packet
Date: Fri, 10 Sep 2021 22:46:53 +0200	[thread overview]
Message-ID: <20210910204653.3066-2-pali@kernel.org> (raw)
In-Reply-To: <20210910204653.3066-1-pali@kernel.org>

Implement same thing also for x-modem protocol. As x-modem protocol does
not have header packet, first packet is directly first data packet.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 common/xyzModem.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/common/xyzModem.c b/common/xyzModem.c
index d6be489a174b..39b40071a13b 100644
--- a/common/xyzModem.c
+++ b/common/xyzModem.c
@@ -50,6 +50,7 @@ static struct
   int len, mode, total_retries;
   int total_SOH, total_STX, total_CAN;
   bool crc_mode, at_eof, tx_ack;
+  bool first_xmodem_packet;
   unsigned long file_length, read_length;
 } xyz;
 
@@ -439,12 +440,14 @@ xyzModem_stream_open (connection_info_t * info, int *err)
   xyz.total_CAN = 0;
   xyz.read_length = 0;
   xyz.file_length = 0;
+  xyz.first_xmodem_packet = false;
 
   CYGACC_COMM_IF_PUTC (*xyz.__chan, (xyz.crc_mode ? 'C' : NAK));
 
   if (xyz.mode == xyzModem_xmodem)
     {
       /* X-modem doesn't have an information header - exit here */
+      xyz.first_xmodem_packet = true;
       xyz.next_blk = 1;
       return 0;
     }
@@ -512,6 +515,8 @@ xyzModem_stream_read (char *buf, int size, int *err)
 	      stat = xyzModem_get_hdr ();
 	      if (stat == 0)
 		{
+		  if (xyz.mode == xyzModem_xmodem && xyz.first_xmodem_packet)
+		    xyz.first_xmodem_packet = false;
 		  if (xyz.blk == xyz.next_blk)
 		    {
 		      xyz.tx_ack = true;
@@ -589,7 +594,7 @@ xyzModem_stream_read (char *buf, int size, int *err)
 	      xyz.total_retries++;
 	      ZM_DEBUG (zm_dprintf ("NAK (%d)\n", __LINE__));
 	    }
-	  if (stat < 0)
+	  if (stat < 0 && (!xyz.first_xmodem_packet || stat != xyzModem_timeout))
 	    {
 	      *err = stat;
 	      xyz.len = -1;
-- 
2.20.1


  reply	other threads:[~2021-09-10 20:50 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-10 20:46 [PATCH 1/2] xyz-modem: Wait infinitely for initial y-modem packet Pali Rohár
2021-09-10 20:46 ` Pali Rohár [this message]
2021-09-13 10:43   ` [PATCH 2/2] xyz-modem: Wait infinitely for initial x-modem packet Wolfgang Denk
2021-09-13 10:42 ` [PATCH 1/2] xyz-modem: Wait infinitely for initial y-modem packet Wolfgang Denk
2021-09-13 11:08   ` Pali Rohár
2021-09-13 12:12     ` Wolfgang Denk
2021-09-13 12:22       ` Pali Rohár
2021-09-13 13:02         ` Wolfgang Denk
2022-08-27 11:50           ` Pali Rohár
2021-09-13 14:32     ` Tom Rini
2022-08-27 11:48 ` [PATCH v2] xyz-modem: Allow to configure initial timeout for loadx and loady Pali Rohár
2022-08-27 12:53   ` Tom Rini
2022-08-27 12:56     ` Pali Rohár
2022-08-27 14:30       ` Tom Rini
2022-08-27 14:32         ` Pali Rohár
2022-08-27 14:41           ` Tom Rini
2022-08-27 14:47             ` Pali Rohár
2022-08-29 14:54   ` Heinrich Schuchardt
2022-08-27 14:37 ` [PATCH v3] " Pali Rohár

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210910204653.3066-2-pali@kernel.org \
    --to=pali@kernel.org \
    --cc=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.