[components][ymodem] 修复 ymodem 不支持 secureCRT 下 1024字节传输的问题
Signed-off-by: MurphyZhao <d2014zjt@163.com>
This commit is contained in:
parent
6abe7e4ebd
commit
dcbbb05f50
|
@ -122,6 +122,7 @@ static rt_err_t _rym_do_handshake(
|
||||||
enum rym_code code;
|
enum rym_code code;
|
||||||
rt_size_t i;
|
rt_size_t i;
|
||||||
rt_uint16_t recv_crc, cal_crc;
|
rt_uint16_t recv_crc, cal_crc;
|
||||||
|
rt_size_t data_sz;
|
||||||
|
|
||||||
ctx->stage = RYM_STAGE_ESTABLISHING;
|
ctx->stage = RYM_STAGE_ESTABLISHING;
|
||||||
/* send C every second, so the sender could know we are waiting for it. */
|
/* 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,
|
code = _rym_read_code(ctx,
|
||||||
RYM_CHD_INTV_TICK);
|
RYM_CHD_INTV_TICK);
|
||||||
if (code == RYM_CODE_SOH)
|
if (code == RYM_CODE_SOH)
|
||||||
|
{
|
||||||
|
data_sz = _RYM_SOH_PKG_SZ;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
else if(code == RYM_CODE_STX)
|
||||||
|
{
|
||||||
|
data_sz = _RYM_STX_PKG_SZ;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (i == tm_sec)
|
if (i == tm_sec)
|
||||||
|
{
|
||||||
return -RYM_ERR_TMO;
|
return -RYM_ERR_TMO;
|
||||||
|
}
|
||||||
|
|
||||||
i = _rym_read_data(ctx, _RYM_SOH_PKG_SZ-1);
|
i = _rym_read_data(ctx, data_sz-1);
|
||||||
if (i != (_RYM_SOH_PKG_SZ-1))
|
if (i != (data_sz-1))
|
||||||
return -RYM_ERR_DSZ;
|
return -RYM_ERR_DSZ;
|
||||||
|
|
||||||
/* sanity check */
|
/* sanity check */
|
||||||
if (ctx->buf[1] != 0 || ctx->buf[2] != 0xFF)
|
if (ctx->buf[1] != 0 || ctx->buf[2] != 0xFF)
|
||||||
return -RYM_ERR_SEQ;
|
return -RYM_ERR_SEQ;
|
||||||
|
|
||||||
recv_crc = (rt_uint16_t)(*(ctx->buf+_RYM_SOH_PKG_SZ-2) << 8) | *(ctx->buf+_RYM_SOH_PKG_SZ-1);
|
recv_crc = (rt_uint16_t)(*(ctx->buf+data_sz-2) << 8) | *(ctx->buf+data_sz-1);
|
||||||
cal_crc = CRC16(ctx->buf+3, _RYM_SOH_PKG_SZ-5);
|
cal_crc = CRC16(ctx->buf+3, data_sz-5);
|
||||||
if (recv_crc != cal_crc)
|
if (recv_crc != cal_crc)
|
||||||
return -RYM_ERR_CRC;
|
return -RYM_ERR_CRC;
|
||||||
|
|
||||||
/* congratulations, check passed. */
|
/* 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 -RYM_ERR_CAN;
|
||||||
|
|
||||||
return RT_EOK;
|
return RT_EOK;
|
||||||
|
|
Loading…
Reference in New Issue