From 06a4a94a52bc444117b17760369a8cf96ca9031f Mon Sep 17 00:00:00 2001 From: OPTOC <9159397+optoc@user.noreply.gitee.com> Date: Wed, 10 Sep 2025 14:09:03 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=93=E4=BC=A0=E8=BE=93?= =?UTF-8?q?=E5=AD=97=E8=8A=82=E5=A4=A7=E4=BA=8E255=E6=98=AF=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E8=A7=A3=E6=9E=90=E5=A4=B1=E8=B4=A5=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/drivers/sertrf/protocol/resend_protl.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/drivers/sertrf/protocol/resend_protl.c b/app/drivers/sertrf/protocol/resend_protl.c index 818aa7e..e13f415 100644 --- a/app/drivers/sertrf/protocol/resend_protl.c +++ b/app/drivers/sertrf/protocol/resend_protl.c @@ -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;