Skip to content

Commit 95368de

Browse files
anjiahao1xiaoxiang781216
authored andcommitted
ymodem:fix bug,When sending a retransmission, HEAD is overwritten.
Signed-off-by: anjiahao <[email protected]>
1 parent 7dd4b28 commit 95368de

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

system/ymodem/ymodem.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,24 +307,25 @@ static int ymodem_recv_file(FAR struct ymodem_ctx_s *ctx)
307307

308308
static int ymodem_recv_cmd(FAR struct ymodem_ctx_s *ctx, uint8_t cmd)
309309
{
310+
uint8_t recv;
310311
int ret;
311312

312-
ret = ymodem_recv_buffer(ctx, ctx->header, 1);
313+
ret = ymodem_recv_buffer(ctx, &recv, 1);
313314
if (ret < 0)
314315
{
315316
ymodem_debug("recv cmd error\n");
316317
return ret;
317318
}
318319

319-
if (ctx->header[0] == NAK)
320+
if (recv == NAK)
320321
{
321322
return -EAGAIN;
322323
}
323324

324-
if (ctx->header[0] != cmd)
325+
if (recv != cmd)
325326
{
326327
ymodem_debug("recv cmd error, must 0x%x, but receive 0x%x\n",
327-
cmd, ctx->header[0]);
328+
cmd, recv);
328329
return -EINVAL;
329330
}
330331

0 commit comments

Comments
 (0)