ymodem:fix bug,When sending a retransmission, HEAD is overwritten.

Signed-off-by: anjiahao <anjiahao@xiaomi.com>
This commit is contained in:
anjiahao 2024-04-02 16:46:56 +08:00 committed by Xiang Xiao
parent 7dd4b28950
commit 95368deae2

View file

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