修复当传输字节大于255是存在解析失败的问题

This commit is contained in:
OPTOC
2025-09-10 14:09:03 +08:00
parent d925d4ab7e
commit 06a4a94a52

View File

@@ -82,14 +82,16 @@ int resend_decode(resend_device_t *resend_device, uint8_t c)
resend_device->status.c_state = RESEND_RETRY_CNT;
break;
case RESEND_RETRY_CNT:
printf("cnt %d\r\n",c);
resend_device->rx_frame.retry_cnt = c;
//超过最大允许重传次数
if(resend_device->rx_frame.retry_cnt > RESEND_MAX_RETRY_CNT)
resend_device->status.c_state = RESEND_IDLE;
fmav_crc_accumulate(&frame_crc, c);
resend_device->status.c_state = RESEND_LEN_1;
break;
case RESEND_LEN_1:
resend_device->rx_frame.len = 0;
resend_device->rx_frame.len = (uint16_t)(c << 8) & 0xF0;
resend_device->rx_frame.len = (uint16_t)(c << 8);
fmav_crc_accumulate(&frame_crc, c);
resend_device->status.c_state = RESEND_LEN_2;
break;
@@ -100,6 +102,9 @@ int resend_decode(resend_device_t *resend_device, uint8_t c)
{
resend_device->status.data_offset = 0;
resend_device->status.c_state = RESEND_DATA;
//超过允许的字节数
if(resend_device->rx_frame.len > RESEND_DATA_SIZE)
resend_device->status.c_state = RESEND_IDLE;
}
else
resend_device->status.c_state = RESEND_CRC_1;