From 95368deae28a350c7390ac8e7ae69daf73cfbc55 Mon Sep 17 00:00:00 2001 From: anjiahao Date: Tue, 2 Apr 2024 16:46:56 +0800 Subject: [PATCH] ymodem:fix bug,When sending a retransmission, HEAD is overwritten. Signed-off-by: anjiahao --- system/ymodem/ymodem.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/system/ymodem/ymodem.c b/system/ymodem/ymodem.c index 961af3a6c..0a717030e 100644 --- a/system/ymodem/ymodem.c +++ b/system/ymodem/ymodem.c @@ -307,24 +307,25 @@ cancel: static int ymodem_recv_cmd(FAR struct ymodem_ctx_s *ctx, uint8_t cmd) { + uint8_t recv; int ret; - ret = ymodem_recv_buffer(ctx, ctx->header, 1); + ret = ymodem_recv_buffer(ctx, &recv, 1); if (ret < 0) { ymodem_debug("recv cmd error\n"); return ret; } - if (ctx->header[0] == NAK) + if (recv == NAK) { return -EAGAIN; } - if (ctx->header[0] != cmd) + if (recv != cmd) { ymodem_debug("recv cmd error, must 0x%x, but receive 0x%x\n", - cmd, ctx->header[0]); + cmd, recv); return -EINVAL; }