feat(canfd): 添加CANFD发送邮箱占用处理机制
当CAN控制器因总线无ACK导致邮箱卡死时,实现两段式恢复策略: 1) 短自旋轮询邮箱状态,大多数场景下可避免触发abort而不丢帧 2) 若仍全部PENDING则只中止第一个占用邮箱,限制最坏丢帧数量为1帧 添加了tx_abort_count诊断计数器用于监控该情况,并引入SysTick延时功能 refactor(spi-cmd): 优化SPI命令日志输出格式 将CAN发送相关日志改为统一的格式化函数输出,增加数据字段十六进制显示功能, 并扩大日志缓冲区大小从128到256字节以支持更详细的日志信息 chore(spi-command): 添加SPI帧类型分类和非刷写帧日志记录 新增isFlashRelatedFrame函数区分刷写相关帧类型,在处理命令时对非刷写帧进行日志记录 perf(diagnostic): 在诊断打印中添加发送中止计数统计 更新诊断信息打印格式,增加tx_abort计数项,便于监控CAN发送异常情况
This commit is contained in:
@@ -92,6 +92,19 @@ static bool shouldIgnoreTransaction(const uint8_t *data, uint8_t len)
|
||||
!(len == 1U && data[0] == CONFIG_SPI_APP_OTA_BOOT_CMD);
|
||||
}
|
||||
|
||||
static bool isFlashRelatedFrame(uint8_t frame_type)
|
||||
{
|
||||
switch (frame_type) {
|
||||
case kTypeOtaReq:
|
||||
case kTypeOtaData:
|
||||
case kTypeOtaCancel:
|
||||
case kTypeBootReq:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
* CRC8 / 帧构建 / 帧解析(与 BOOT SpiOta 一致)
|
||||
* ============================================================ */
|
||||
@@ -328,6 +341,10 @@ void AppSpiCommand::processCommand()
|
||||
uint16_t payload_len = 0U;
|
||||
|
||||
if (spi_try_parse_frame(m_rxBuf, m_rxLen, &frame_type, &payload, &payload_len)) {
|
||||
if (!isFlashRelatedFrame(frame_type)) {
|
||||
postLogFmt("[SPI-APP] 收到非刷写 SPI type=0x%02X", frame_type);
|
||||
}
|
||||
|
||||
/* 合法帧:按 TYPE 分发给已注册命令处理器 */
|
||||
uint16_t tx_len = 0U;
|
||||
bool handled = false;
|
||||
|
||||
Reference in New Issue
Block a user