From 7c2927d8364db7659378aacead9033ace33a0f01 Mon Sep 17 00:00:00 2001 From: wangfq Date: Thu, 2 Jul 2026 13:56:45 +0800 Subject: [PATCH] =?UTF-8?q?fix:=200xC0=20=E5=B8=A7=E5=BF=85=E9=A1=BB?= =?UTF-8?q?=E7=BB=8F=20lup=5Fprocess=5Fframe=20=E6=A0=A1=E9=AA=8C=E5=90=8E?= =?UTF-8?q?=E5=86=8D=E5=88=86=E6=B5=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修改前: 0xC0 帧绕过 lup_process_frame,校验未执行 修改后: 所有 0x7F 帧先统一校验,0xC0 由校验后的数据分流处理 流程: ISR→lup_feed_byte→uart_srv→lup_process_frame(校验)→ 0xC0→_report_flag→tcp_json_push_sensor→TCP推送 --- .../OnlyUpdateApp_Peripheral/APP/usart_biz.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/usart_biz.c b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/usart_biz.c index 50dcc0a..69ba924 100644 --- a/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/usart_biz.c +++ b/vd960DBN/BLE/OnlyUpdateApp_Peripheral/APP/usart_biz.c @@ -160,9 +160,15 @@ void uart_srv(void) if(g_pkg_uart_2.pkg[0] == 0x7F){ uint8_t cmd = g_pkg_uart_2.pkg[3]; - // --- 传感器上报 (0xC0) --- - if(cmd == 0xC0 && g_pkg_uart_2.pkg[4] == 0x0C) + // --- 所有 0x7F 帧先经过 lup_process_frame 校验 --- + // 对于 0xC0 帧: 校验 checksum,但不消费为命令响应 + // 对于其他帧: 校验 checksum,匹配挂起命令 + lup_process_frame(g_pkg_uart_2.pkg, g_pkg_uart_2.offset); + + // --- 传感器上报 (0xC0) 分流 --- + if(cmd == LUP_CMD_SENSOR_REPORT) { + // SensType=0x0C → 多线圈传感信息 if(g_dbn_ble_state_acs_enable.flag == 0){ // 无 BLE ACS 连接 → 标记为 TCP JSON 上报 _report_flag = 1; @@ -172,10 +178,6 @@ void uart_srv(void) g_pkg_uart_2.pkg[0] = 0x8F; } } - else { - // --- 命令响应 → 交给协议处理器 --- - lup_process_frame(g_pkg_uart_2.pkg, g_pkg_uart_2.offset); - } // 调试打印 for(i = 0; i < g_pkg_uart_2.offset; i++){ @@ -185,7 +187,7 @@ void uart_srv(void) if(_report_flag){ // 传感器帧保留在 pkg 中供上层 (tcp_json_srv) 处理 - // 不 InitPkgUart — 由上层消费后再 InitPkgUart + // 不 InitPkgUart — 由 tcp_json_push_sensor 消费后清理 } } else { @@ -206,7 +208,7 @@ void uart_srv(void) } // 只有非 _report_flag 时才立即清空 - // _report_flag 的帧由 tcp_json 消费后清理 + // _report_flag 的帧由 tcp_json_push_sensor 消费后清理 if (!_report_flag) { InitPkgUart(&g_pkg_uart_2); }