summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurphyZhao <[email protected]>2018-09-06 11:00:36 +0800
committerMurphyZhao <[email protected]>2018-09-06 11:02:49 +0800
commitdcbbb05f50b253c4c679ea75d81198af300908cd (patch)
tree28b9f09ea43aed6f9f5e9fd80d3991d04391cc06
parent6abe7e4ebd4c4cbd19aa68d348376ea668770d6b (diff)
[components][ymodem] 修复 ymodem 不支持 secureCRT 下 1024字节传输的问题
Signed-off-by: MurphyZhao <[email protected]>
-rw-r--r--components/utilities/ymodem/ymodem.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/components/utilities/ymodem/ymodem.c b/components/utilities/ymodem/ymodem.c
index 1643429647..a1f21cf6c6 100644
--- a/components/utilities/ymodem/ymodem.c
+++ b/components/utilities/ymodem/ymodem.c
@@ -122,6 +122,7 @@ static rt_err_t _rym_do_handshake(
enum rym_code code;
rt_size_t i;
rt_uint16_t recv_crc, cal_crc;
+ rt_size_t data_sz;
ctx->stage = RYM_STAGE_ESTABLISHING;
/* send C every second, so the sender could know we are waiting for it. */
@@ -131,26 +132,36 @@ static rt_err_t _rym_do_handshake(
code = _rym_read_code(ctx,
RYM_CHD_INTV_TICK);
if (code == RYM_CODE_SOH)
+ {
+ data_sz = _RYM_SOH_PKG_SZ;
+ break;
+ }
+ else if(code == RYM_CODE_STX)
+ {
+ data_sz = _RYM_STX_PKG_SZ;
break;
+ }
}
if (i == tm_sec)
+ {
return -RYM_ERR_TMO;
+ }
- i = _rym_read_data(ctx, _RYM_SOH_PKG_SZ-1);
- if (i != (_RYM_SOH_PKG_SZ-1))
+ i = _rym_read_data(ctx, data_sz-1);
+ if (i != (data_sz-1))
return -RYM_ERR_DSZ;
/* sanity check */
if (ctx->buf[1] != 0 || ctx->buf[2] != 0xFF)
return -RYM_ERR_SEQ;
- recv_crc = (rt_uint16_t)(*(ctx->buf+_RYM_SOH_PKG_SZ-2) << 8) | *(ctx->buf+_RYM_SOH_PKG_SZ-1);
- cal_crc = CRC16(ctx->buf+3, _RYM_SOH_PKG_SZ-5);
+ recv_crc = (rt_uint16_t)(*(ctx->buf+data_sz-2) << 8) | *(ctx->buf+data_sz-1);
+ cal_crc = CRC16(ctx->buf+3, data_sz-5);
if (recv_crc != cal_crc)
return -RYM_ERR_CRC;
/* congratulations, check passed. */
- if (ctx->on_begin && ctx->on_begin(ctx, ctx->buf+3, 128) != RYM_CODE_ACK)
+ if (ctx->on_begin && ctx->on_begin(ctx, ctx->buf+3, data_sz-5) != RYM_CODE_ACK)
return -RYM_ERR_CAN;
return RT_EOK;