提交 f54f2c2c 编写于 作者: 哈哈哈可是开电脑's avatar 哈哈哈可是开电脑 提交者: mysterywolf

[ymodem]添加传输过程中的异常处理流程

上级 fa1f6c22
/*
* COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd
* COPYRIGHT (C) 2011-2022, Real-Thread Information Technology Ltd
* All rights reserved
*
* SPDX-License-Identifier: Apache-2.0
......@@ -362,6 +362,7 @@ static rt_err_t _rym_do_trans(struct rym_ctx *ctx)
_rym_putchar(ctx, RYM_CODE_ACK);
_rym_putchar(ctx, RYM_CODE_C);
ctx->stage = RYM_STAGE_ESTABLISHED;
rt_size_t errors;
while (1)
{
......@@ -387,7 +388,22 @@ static rt_err_t _rym_do_trans(struct rym_ctx *ctx)
err = _rym_trans_data(ctx, data_sz, &code);
if (err != RT_EOK)
return err;
{
errors++;
if(errors > RYM_MAX_ERRORS)
{
return err;/* Abort communication */
}
else
{
_rym_putchar(ctx, RYM_CODE_NAK);/* Ask for a packet */
continue;
}
}
else
{
errors = 0;
}
switch (code)
{
case RYM_CODE_CAN:
......
......@@ -58,6 +58,11 @@ enum rym_code
#define RYM_END_SESSION_SEND_CAN_NUM 0x07
#endif
/* how many retries were made when the error occurred */
#ifndef RYM_MAX_ERRORS
#define RYM_MAX_ERRORS ((rt_size_t)5)
#endif
enum rym_stage
{
RYM_STAGE_NONE = 0,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册