Skip to content

Commit

Permalink
ymodem:fix bug,When sending a retransmission, HEAD is overwritten.
Browse files Browse the repository at this point in the history
Signed-off-by: anjiahao <[email protected]>
  • Loading branch information
anjiahao1 authored and xiaoxiang781216 committed Oct 29, 2024
1 parent 7dd4b28 commit 95368de
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions system/ymodem/ymodem.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,24 +307,25 @@ static int ymodem_recv_file(FAR struct ymodem_ctx_s *ctx)

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;
}

Expand Down

0 comments on commit 95368de

Please sign in to comment.