From f15ba5a274fad568d81f7e4c2f67a8b98dead476 Mon Sep 17 00:00:00 2001 From: OPTOC <9159397+optoc@user.noreply.gitee.com> Date: Mon, 22 Sep 2025 14:32:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=92=A4=E9=94=80=E9=87=8D=E5=8F=91=E6=9C=BA?= =?UTF-8?q?=E5=88=B6=E4=BB=A5=E5=8F=8A=E9=AA=8C=E8=AF=81seq=E6=9C=BA?= =?UTF-8?q?=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/drivers/sertrf/protocol/resend_protl.c | 16 +++++++++------- app/drivers/sertrf/protocol/resend_protl.h | 3 ++- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/app/drivers/sertrf/protocol/resend_protl.c b/app/drivers/sertrf/protocol/resend_protl.c index 519f477..b713223 100644 --- a/app/drivers/sertrf/protocol/resend_protl.c +++ b/app/drivers/sertrf/protocol/resend_protl.c @@ -153,7 +153,7 @@ int resend_recv_data(resend_device_t *resend_device, int timeout) { if(!resend_decode(resend_device, data[ret - ret_later - 1])) { - printf("tx_req %d rx_req %d retry_cnt %d cmd %d\r\n", resend_device->tx_frame.seq, resend_device->rx_frame.seq, resend_device->rx_frame.retry_cnt, resend_device->rx_frame.cmd); + // printf("tx_req %d rx_req %d retry_cnt %d cmd %d\r\n", resend_device->tx_frame.seq, resend_device->rx_frame.seq, resend_device->rx_frame.retry_cnt, resend_device->rx_frame.cmd); if(seq_lat == resend_device->rx_frame.seq){ resend_device->status.resend_flag = 1; @@ -221,12 +221,14 @@ int resend_send_data(resend_device_t *resend_device, uint8_t cmd, void* data, ui os_thread_sleep(1); } // 超过允许的等待次数 - if(resend_device->tx_frame.retry_cnt > RESEND_MAX_RETRY_CNT) + if(resend_device->tx_frame.retry_cnt > RESEND_MAX_RETRY_CNT && resend_device->status.ack_flag) { printf("timeout cnt max\n"); resend_device->tx_frame.retry_cnt = 0; resend_device->status.ack_flag = 0; return -1; + } else if(!resend_device->status.ack_flag){ + return ret; } } @@ -254,14 +256,14 @@ int resend_parse_data(resend_device_t *resend_device) case RESEND_CMD_SET_PARAM: break; case RESEND_CMD_DATA_ACK: - for (size_t i = 0; i < resend_device->rx_frame.len; i++) - { - printf("%02X ", resend_device->rx_frame.payload[i]); - } - printf("\r\n"); resend_send_cmd(resend_device, RESEND_CMD_ACK, 0); break; + case RESEND_CMD_OTA_GET_PARAM: + //针对OTA的应答 + resend_device->status.ack_flag = 0; + break; case RESEND_CMD_OTA_START: + resend_device->handle_flag = RESEND_CMD_OTA_GET_PARAM; break; case RESEND_CMD_OTA_DATA: break; diff --git a/app/drivers/sertrf/protocol/resend_protl.h b/app/drivers/sertrf/protocol/resend_protl.h index 9fd4c8d..3232c6b 100644 --- a/app/drivers/sertrf/protocol/resend_protl.h +++ b/app/drivers/sertrf/protocol/resend_protl.h @@ -22,7 +22,7 @@ #define RESEND_HEADER_0 0xFD #define RESEND_HEADER_1 0xFE -#define RESEND_MAX_RETRY_CNT 5 +#define RESEND_MAX_RETRY_CNT 0 // 命令类型 typedef enum { @@ -34,6 +34,7 @@ typedef enum RESEND_CMD_DATA_ACK = 0x06, + RESEND_CMD_OTA_GET_PARAM = 0x010, RESEND_CMD_OTA_START = 0x011, RESEND_CMD_OTA_DATA = 0x012, RESEND_CMD_OTA_END = 0x013