fix(vd960DBN): UART2 粘帧/checksum fail — 高频打印关中断丢字节 + flag 不清
现场: LUP 帧后 checksum fail 刷屏 (坏帧: 7F 03 39 EF... 多帧拼接)。 根因链条: 1. LUP Rx 打印 190B @256000 = 7.4ms 关中断 (PRINT 临界区) → UART2(19200) RX 溢出丢字节 → 帧解析错位 → 粘帧 2. g_pkg_uart_2.flag 清理缺失: uart_srv 0xC0 分支不 InitPkgUart, tcp_json_push_sensor not authed 提前 return 也不清 → 坏帧反复处理 → checksum fail 刷屏 修复: - LUP Rx 打印 #if 0 (高频打印关中断是丢字节根因, 调试时开) - json_sensor_callback not authed 打印 #if 0 (每帧刷屏) - uart_srv 所有分支消费后统一 InitPkgUart (0xC0 + 非0xC0无BLE) - 顺带修 report disabled 双反斜杠
This commit is contained in:
@@ -687,7 +687,10 @@ void lup_process_frame(const uint8_t *pkg, uint16_t len)
|
|||||||
if (len < 6) { FAULT_MARKER(MK_LUP_FRAME_OUT); return; }
|
if (len < 6) { FAULT_MARKER(MK_LUP_FRAME_OUT); return; }
|
||||||
|
|
||||||
// Debug: print raw (2026-08-13: 缓冲一次性输出 — 逐字节 PRINT 关中断 ~350us/字节
|
// Debug: print raw (2026-08-13: 缓冲一次性输出 — 逐字节 PRINT 关中断 ~350us/字节
|
||||||
// 会屏蔽 UART2 ISR 丢帧, 且高频打印放大 printf 重入窗口)
|
// 会屏蔽 UART2 ISR 丢帧, 且高频打印放大 printf 重入窗口。
|
||||||
|
// 再关闭: 190B 打印 @256000 = 7.4ms 关中断 → UART2(19200) 溢出丢字节 → 粘帧!
|
||||||
|
// 需要调试时打开 #if 1)
|
||||||
|
#if 0
|
||||||
{
|
{
|
||||||
char _hex[224];
|
char _hex[224];
|
||||||
int _p = snprintf(_hex, sizeof(_hex), "LUP Rx:");
|
int _p = snprintf(_hex, sizeof(_hex), "LUP Rx:");
|
||||||
@@ -696,6 +699,7 @@ void lup_process_frame(const uint8_t *pkg, uint16_t len)
|
|||||||
}
|
}
|
||||||
PRINT("%s\n", _hex);
|
PRINT("%s\n", _hex);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
// --- Checksum ---
|
// --- Checksum ---
|
||||||
csr = lup_verify_checksum(pkg, len);
|
csr = lup_verify_checksum(pkg, len);
|
||||||
|
|||||||
@@ -883,8 +883,13 @@ static void json_sensor_callback(const uint8_t *pkg, uint16_t len)
|
|||||||
|
|
||||||
// Check: socket active, authed, report enabled
|
// Check: socket active, authed, report enabled
|
||||||
if (g_json_socket_listen == 0xFF) { PRINT("JSON: sensor_cb skip: no socket\n"); return; }
|
if (g_json_socket_listen == 0xFF) { PRINT("JSON: sensor_cb skip: no socket\n"); return; }
|
||||||
|
/* 2026-08-13: not authed 每帧打印太吵 (Loop MCU 高频上报), 且占用主循环
|
||||||
|
关中断窗口 → UART2 丢字节。调试时打开 */
|
||||||
|
#if 0
|
||||||
if (g_json_auth_state != JSON_STATE_AUTHED) { PRINT("JSON: sensor_cb skip: not authed\n"); return; }
|
if (g_json_auth_state != JSON_STATE_AUTHED) { PRINT("JSON: sensor_cb skip: not authed\n"); return; }
|
||||||
if (!g_report_cfg.enable) { PRINT("JSON: sensor_cb skip: report disabled\\n"); return; }
|
#endif
|
||||||
|
if (g_json_auth_state != JSON_STATE_AUTHED) { return; }
|
||||||
|
if (!g_report_cfg.enable) { PRINT("JSON: sensor_cb skip: report disabled\n"); return; }
|
||||||
|
|
||||||
LUP_SensorReport sr;
|
LUP_SensorReport sr;
|
||||||
memset(&sr, 0, sizeof(sr));
|
memset(&sr, 0, sizeof(sr));
|
||||||
|
|||||||
@@ -174,13 +174,20 @@ void uart_srv(void)
|
|||||||
g_pkg_uart_2.pkg[0] = 0x8F;
|
g_pkg_uart_2.pkg[0] = 0x8F;
|
||||||
g_flag_notify_temp = set_response_tran_to_notify(g_pkg_uart_2.pkg, g_pkg_uart_2.offset, &g_notify_buftemp); // 保留给 BLE
|
g_flag_notify_temp = set_response_tran_to_notify(g_pkg_uart_2.pkg, g_pkg_uart_2.offset, &g_notify_buftemp); // 保留给 BLE
|
||||||
}
|
}
|
||||||
// else: 回调已推送 TCP,直接清理
|
/* 2026-08-13 修复: 0xC0 帧消费后必须清 flag —
|
||||||
|
原缺失, auth 未通过时 tcp_json_push_sensor 提前 return
|
||||||
|
也不清 → 坏帧/正常帧反复处理 (checksum fail 刷屏) */
|
||||||
|
InitPkgUart(&g_pkg_uart_2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(g_flag_bt_state){
|
if(g_flag_bt_state){
|
||||||
g_flag_notify_temp = set_response_tran_to_notify(g_pkg_uart_2.pkg, g_pkg_uart_2.offset, &g_notify_buftemp);
|
g_flag_notify_temp = set_response_tran_to_notify(g_pkg_uart_2.pkg, g_pkg_uart_2.offset, &g_notify_buftemp);
|
||||||
InitPkgUart(&g_pkg_uart_2);
|
InitPkgUart(&g_pkg_uart_2);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
/* 2026-08-13 修复: 非 0xC0 + 无 BLE 连接也清 flag (原缺失) */
|
||||||
|
InitPkgUart(&g_pkg_uart_2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 调试打印 (2026-08-13: LUP Rx 已在 lup_process_frame 缓冲打印,
|
// 调试打印 (2026-08-13: LUP Rx 已在 lup_process_frame 缓冲打印,
|
||||||
|
|||||||
Reference in New Issue
Block a user