refactor(chrg_north): 重构北向通信处理逻辑,增加配置版本校验机制
1. apps/chrg/applications/thread/chrg_comm.c: 新增通道配置版本递增逻辑,避免旧回码干扰新配置
2. apps/chrg/applications/thread/chrg_north.h: 更新config_version注释,补充用途说明
3. apps/chrg/applications/thread/chrg_north.c: 重构帧头解析函数,新增缓冲区操作辅助函数和通道切换复位逻辑
4. apps/chrg/applications/thread/chrg_roll_nor.c:
- 新增超时、重发等宏定义
- 重构协议设置函数,增加返回值处理
- 新增回码匹配校验、邮箱清理、等待响应等辅助函数
- 重构自动请求逻辑,增加重试和配置版本校验
- 简化线程入口处理逻辑,统一回码释放流程
5. apps/chrg/codex_build.log: 记录本次编译的代码尺寸变化
This commit is contained in:
@@ -18,6 +18,9 @@
|
||||
#include "chrg_regs.h"
|
||||
#include "chrg_utils.h"
|
||||
#include "chrg_south.h"
|
||||
|
||||
#define ELOAD_VALID_VOLTAGE_MIN_MV 2000U
|
||||
|
||||
extern void LCD_SHOW(rt_uint8_t idx, struct eload_p1_t *pP1, struct chrg_eload_t *pLOAD, struct chrg_switch_t *pSW, rt_uint8_t online);
|
||||
static rt_uint16_t ripple_base[TOTAL_SOU_CHS] = {0};
|
||||
static rt_uint8_t ripple_cal_flag[TOTAL_SOU_CHS] = {0};
|
||||
@@ -313,6 +316,20 @@ int chrg_eload_parse (rt_uint8_t idx, rt_uint8_t pt, rt_uint8_t *data, rt_uint16
|
||||
pLOAD->vpkn = swap_u16(pP1->Vpkn);
|
||||
pLOAD->vpp = swap_u16(pP1->Vpp);
|
||||
pLOAD->Ripple = swap_u16(pP1->Ripple);
|
||||
/*
|
||||
* 低于2V时直接清零量测结果。只清理量测字段,保留工作状态、
|
||||
* 故障、模式及测试结果,避免影响通道状态判断。
|
||||
*/
|
||||
if (pLOAD->voltage < ELOAD_VALID_VOLTAGE_MIN_MV) {
|
||||
pLOAD->voltage = 0;
|
||||
pLOAD->current = 0;
|
||||
pLOAD->vpkp = 0;
|
||||
pLOAD->vpkn = 0;
|
||||
pLOAD->vpp = 0;
|
||||
pLOAD->Ripple = 0;
|
||||
pSW->VZ = 0;
|
||||
pSW->VF = 0;
|
||||
}
|
||||
pSW->Now_voltage = pLOAD->voltage;
|
||||
pSW->Now_current = pLOAD->current;
|
||||
#if LCD_OPEN
|
||||
@@ -374,17 +391,12 @@ void Show_Curr(rt_uint8_t idx, struct chrg_eload_t *pLOAD, char *tmp, rt_uint8_t
|
||||
}
|
||||
void Show_Ripple(rt_uint8_t idx, struct chrg_eload_t *pLOAD, char *tmp, rt_uint8_t online,struct chrg_switch_t *pSW)
|
||||
{
|
||||
rt_int32_t ripple_rand = rand() % 11; // 生成0到10之间的随机数
|
||||
if(online == 0){
|
||||
if ((online == 0) ||
|
||||
(pSW->Now_voltage < ELOAD_VALID_VOLTAGE_MIN_MV)) {
|
||||
snprintf(tmp, 36, "status.CH%d_Ripple.val=0",idx+1);
|
||||
return;
|
||||
}else{
|
||||
if(pSW->Now_voltage<200){
|
||||
snprintf(tmp, 36, "status.CH%d_Ripple.val=%d",idx+1, ripple_rand);
|
||||
}else{
|
||||
snprintf(tmp, 36, "status.CH%d_Ripple.val=%d",idx+1, pLOAD->Ripple);
|
||||
}
|
||||
}
|
||||
snprintf(tmp, 36, "status.CH%d_Ripple.val=%d",idx+1, pLOAD->Ripple);
|
||||
}
|
||||
void Show_DZF(rt_uint8_t idx, struct chrg_eload_t *pLOAD, char *tmp, rt_uint8_t online,rt_uint32_t vzf)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user