mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-02-28 01:57:05 +08:00
[ymodem]添加传输过程中的异常处理流程
This commit is contained in:
parent
fa1f6c22e5
commit
f54f2c2c91
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* COPYRIGHT (C) 2011-2021, Real-Thread Information Technology Ltd
|
* COPYRIGHT (C) 2011-2022, Real-Thread Information Technology Ltd
|
||||||
* All rights reserved
|
* All rights reserved
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* 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_ACK);
|
||||||
_rym_putchar(ctx, RYM_CODE_C);
|
_rym_putchar(ctx, RYM_CODE_C);
|
||||||
ctx->stage = RYM_STAGE_ESTABLISHED;
|
ctx->stage = RYM_STAGE_ESTABLISHED;
|
||||||
|
rt_size_t errors;
|
||||||
|
|
||||||
while (1)
|
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);
|
err = _rym_trans_data(ctx, data_sz, &code);
|
||||||
if (err != RT_EOK)
|
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)
|
switch (code)
|
||||||
{
|
{
|
||||||
case RYM_CODE_CAN:
|
case RYM_CODE_CAN:
|
||||||
|
@ -58,6 +58,11 @@ enum rym_code
|
|||||||
#define RYM_END_SESSION_SEND_CAN_NUM 0x07
|
#define RYM_END_SESSION_SEND_CAN_NUM 0x07
|
||||||
#endif
|
#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
|
enum rym_stage
|
||||||
{
|
{
|
||||||
RYM_STAGE_NONE = 0,
|
RYM_STAGE_NONE = 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user