V1.5: 485排障加帧提交/缓冲丢弃两条日志(定位9字节去向)
This commit is contained in:
parent
d2104fd90f
commit
eb2b27ddbc
|
|
@ -1,5 +1,6 @@
|
|||
#include "uart.h"
|
||||
#include "network.h"
|
||||
#include "log.h"
|
||||
#include "hlw8032.h"
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
|
@ -274,6 +275,12 @@ uint16_t USART2_GetRxIndex(void) { return uart2_cmd_index; } /*
|
|||
|
||||
void USART2_FlushRxBuf(void)
|
||||
{
|
||||
if (uart2_cmd_index > 0) {
|
||||
char hex[3 * 24 + 1] = {0};
|
||||
uint16_t n = uart2_cmd_index < 24 ? uart2_cmd_index : 24;
|
||||
for (uint16_t i = 0; i < n; i++) snprintf(hex + i * 3, 4, "%02X ", uart2_cmd_buf[i]);
|
||||
log_warn("> UART2: 清缓冲丢弃 %d 字节: %s", (int)uart2_cmd_index, hex);
|
||||
}
|
||||
uart2_rx_ready = 0;
|
||||
uart2_cmd_index = 0;
|
||||
/* 兜底:接收中断意外停摆时(ORE 后状态卡 BUSY_RX)拉起来。不 Abort,不动正常状态 */
|
||||
|
|
@ -366,6 +373,11 @@ void USART2_Tick(void)
|
|||
{
|
||||
if (uart2_cmd_index > 0 &&
|
||||
(HAL_GetTick() - uart2_last_rx_tick) > UART2_CMD_TIMEOUT_MS) {
|
||||
/* 排障:帧提交时打印内容(485 丢帧定位) */
|
||||
char hex[3 * 24 + 1] = {0};
|
||||
uint16_t n = uart2_cmd_index < 24 ? uart2_cmd_index : 24;
|
||||
for (uint16_t i = 0; i < n; i++) snprintf(hex + i * 3, 4, "%02X ", uart2_cmd_buf[i]);
|
||||
log_info("> UART2: 帧提交 %d 字节: %s", (int)uart2_cmd_index, hex);
|
||||
uart2_rx_ready = 1;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue