fix: 0xC0 帧必须经 lup_process_frame 校验后再分流

修改前: 0xC0 帧绕过 lup_process_frame,校验未执行
修改后: 所有 0x7F 帧先统一校验,0xC0 由校验后的数据分流处理

流程: ISR→lup_feed_byte→uart_srv→lup_process_frame(校验)→
      0xC0→_report_flag→tcp_json_push_sensor→TCP推送
This commit is contained in:
wangfq
2026-07-02 13:56:45 +08:00
parent 8526023e06
commit 7c2927d836

View File

@@ -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);
}