feat: 发布V1.1.35版本,

北向轮询无回码让行逻辑
当空载时电流显示为0
1.  修改chrg_comm.c:更新协议板固件版本为0x0133,新增Source初始化事务保护逻辑
2.  修改chrg_roll_nor.c:优化北向轮询机制,单次请求超时后直接切换通道
3.  修改chrg_eload.h/c:新增小电流归零阈值宏,实现功率板小电流采样归零处理
4.  更新chrg_def.h版本号为V1.1.35
5.  更新修改日志文档,补充V1.1.33~V1.1.35版本更新内容
This commit is contained in:
wrh
2026-09-21 19:33:37 +08:00
parent 212d9ede6f
commit 4a79d9a4de
9 changed files with 145 additions and 102 deletions
+16 -2
View File
@@ -1,7 +1,7 @@
/****************************************************************************
文件名称 : chrg_comm.c
完成日期 :
当前版本号 : V1.1.32
当前版本号 : V1.1.35
主要功能 : 实现对外通讯协议 MODBUS 服务端,以独立线程等待处理响应请求数据。
版本历史 : 创建原始版本
说明 :
@@ -27,7 +27,7 @@
#include "stm32f4xx_hal.h"
#define HOLD_REG_FIRMWARE_VERSION 0x0300U /* 协议板固件版本,只读 */
#define CHRG_FIRMWARE_VERSION 0x0130U /* 当前协议板版本:V1.1.32 */
#define CHRG_FIRMWARE_VERSION 0x0133U /* 当前协议板版本:V1.1.35 */
rt_uint8_t ucDiscInBuf[(TOTAL_DISC_REGS+BITS_UCHAR-1)/BITS_UCHAR];
@@ -2897,6 +2897,20 @@ static eMBException chrg_comm_apply_source_effect(rt_uint8_t ch,
chrg_comm_get_param_diff(ID_SOURCE, pReal, pShadow, &diff_info);
rt_memcpy(&old_pd_set, &pReal->source.pd_set, sizeof(old_pd_set));
/*
* Source初始化批次未完成时,重复ON只能继续当前事务;否则会把
* INIT/INIT_WAIT直接改为WAIT,跳过南向批次结果检查。
*/
if ((source_work == 0x01U) &&
((old_work_mode == SOURCE_WORK_INIT) ||
(old_work_mode == SOURCE_WORK_INIT_WAIT))) {
if (diff_info.protocol_changed || diff_info.cc_changed ||
diff_info.cv_changed || diff_info.pd_changed) {
return MB_EX_SLAVE_BUSY;
}
return (chrg_source_work_state(ch, pReal) == 0) ?
MB_EX_NONE : MB_EX_SLAVE_BUSY;
}
/* 标准协议的电压电流直接交给功率板,不因pd_set数值变化重发0xD0。 */
protocol_config_changed = diff_info.protocol_changed ||
((pShadow->source.protocol != PRO_NONE) && diff_info.pd_changed);
+9 -23
View File
@@ -1,7 +1,7 @@
/****************************************************************************
文件名称 : chrg_roll_nor.c
完成日期 :
当前版本号 : V1.1.26
当前版本号 : V1.1.35
主要功能 : 实现北向通信轮巡请求命令。以独立线程处理。
版本历史 : 创建原始版本
说明 :
@@ -28,9 +28,7 @@
#include <rtdbg.h>
#define NORTH_RESPONSE_TIMEOUT_MS 50U // 单次北向请求等待匹配回码的总时间
#define NORTH_REQUEST_MAX_RETRIES 2U // 首次发送失败后最多重发2次,总发送次数为3次
#define NORTH_MEASURE_MAX_ATTEMPTS 1U // 0x20量测查询失败后直接留给下一轮轮询重发
#define NORTH_RETRY_INTERVAL_MS 5U // 相同请求两次发送之间的保护间隔
#define NORTH_REQUEST_MAX_ATTEMPTS 1U // 每次轮到通道只发送并等待一次,超时后留给下一轮
#define NORTH_POLL_INTERVAL_MS 10U // 一个通道事务结束后到下一通道的轮询间隔
#define SOURCE_PROTOCOL_WAIT_MS 100U // 每通道0xD0应答后的协议生效保护时间
#define SINK_CC_WAIT_MS 50U // Sink设置目标CC应答后的非阻塞保护时间
@@ -824,11 +822,11 @@ static int chrg_roll_nor_set(rt_uint8_t ch, struct chrg_switch_t *pSW,
/*****************************************************************
函数名称: chrg_roll_nor_auto_request
函数描述: 执行一次自动北向请求事务,并在超时后有限次数重发
函数描述: 执行一次自动北向请求事务,超时后由下一轮通道轮询继续请求
输入参数: idx:通道 pSW:通道状态 pTHR:轮询线程 pTN:北向接收线程
pNOR:北向共享状态
输出参数: -
返回说明: 0:请求成功 1:等待期间COM配置变化,旧事务已取消 <0:重试后失败
返回说明: 0:请求成功 1:等待期间COM配置变化,旧事务已取消 <0:本轮失败
其它说明: 匹配回码有效且配置版本未变化时解析量测值并提交next_sub;
发送时不修改实时sub,CRC错误帧由north.c丢弃并表现为本次等待超时
*****************************************************************/
@@ -837,7 +835,7 @@ static int chrg_roll_nor_auto_request(rt_uint8_t idx,
struct chrg_thread_t *pTN, struct chrg_north_t *pNOR)
{
rt_bool_t advance_sub = RT_TRUE;
rt_uint8_t attempt; // 当前发送序号:0为首次,1~2为重发
rt_uint8_t attempt; // 当前发送序号:每轮仅一次
rt_uint8_t request_sub = 0; // 本次请求实际使用的sub快照
rt_uint8_t next_sub = 0; // 正确回码后准备提交的候选sub
rt_uint8_t expected_cmd = 0; // 本次请求期望收到的命令码
@@ -853,27 +851,19 @@ static int chrg_roll_nor_auto_request(rt_uint8_t idx,
return -1;
}
/* 默认保留设置命令的3次发送;首轮取得实际命令码后,0x20会改为
* 单次发送并留给下一轮轮询重试,避免量测无回码时长期占用通道。 */
max_attempts = NORTH_REQUEST_MAX_RETRIES + 1U;
/* 每次轮到该通道只等待一次回码;超时后主循环立即转下一个通道,
* 下次轮到本通道时保持原sub重新发送,避免无回码通道长期占用轮询。 */
max_attempts = NORTH_REQUEST_MAX_ATTEMPTS;
for (attempt = 0; attempt < max_attempts; attempt++) {
rt_mutex_take(pTHR->mutex, RT_WAITING_FOREVER);
if (attempt == 0U) {
/* 首次发送固定请求状态,后续重发必须继续使用同一份请求上下文。 */
/* 固定本轮请求状态。 */
request_sub = pSW->sub;
expected_id = pSW->id;
expected_cmd = chrg_roll_nor_expected_cmd(pSW);
if (expected_cmd == SRC_CMD_GET_VOLTAGE) {
max_attempts = NORTH_MEASURE_MAX_ATTEMPTS;
}
request_version = pNOR->config_version[idx];
/* 新事务发送前清理已结束或已超时事务遗留的邮箱回码。 */
chrg_roll_nor_drain_mailbox(pTN);
} else if ((pNOR->config_version[idx] != request_version) ||
(pSW->id != expected_id) || (pSW->sub != request_sub)) {
/* COM或其它控制入口已修改配置,禁止继续重发旧命令。 */
rt_mutex_release(pTHR->mutex);
return 1;
}
if (expected_cmd == 0U) {
@@ -942,10 +932,6 @@ static int chrg_roll_nor_auto_request(rt_uint8_t idx,
}
}
if ((attempt + 1U) < max_attempts) {
/* 本次发送失败或等待超时,保持request_sub并准备重发同一命令。 */
rt_thread_mdelay(NORTH_RETRY_INTERVAL_MS);
}
}
LOG_W("north request failed: ch=%d id=%02x cmd=%02x sub=%d attempts=%d",
+3 -3
View File
@@ -1,7 +1,7 @@
/****************************************************************************
文件名称 : chrg_def.h
完成日期 :
当前版本号 : V1.1.32
当前版本号 : V1.1.35
主要功能 : 全局宏定义,常量,及结构体。
版本历史 : 创建原始版本
说明 :
@@ -15,8 +15,8 @@
/* CHRG application version. Keep this value synchronized with the changelog. */
#define CHRG_VERSION_MAJOR 1U
#define CHRG_VERSION_MINOR 1U
#define CHRG_VERSION_PATCH 32U
#define CHRG_VERSION_STRING "V1.1.32"
#define CHRG_VERSION_PATCH 35U
#define CHRG_VERSION_STRING "V1.1.35"
/*
* Channel polling mode:
+4 -1
View File
@@ -1,7 +1,7 @@
/****************************************************************************
文件名称 : chrg_eload.c
完成日期 :
当前版本号 : V1.1.24
当前版本号 : V1.1.34
主要功能 : 源载命令数据解析,封装,读写请求。
版本历史 : 创建原始版本
说明 :
@@ -452,6 +452,9 @@ int chrg_eload_parse (rt_uint8_t idx, rt_uint8_t pt, rt_uint8_t *data, rt_uint16
pLOAD->mode = (rt_uint8_t)pP1->work_mode;
pLOAD->voltage = swap_u32(pP1->voltage);
pLOAD->current = swap_u32(pP1->current);
if (pLOAD->current < ELOAD_CURRENT_ZERO_THRESHOLD_MA) {
pLOAD->current = 0U;
}
pLOAD->SHORT_volt = swap_u16(pP1->SHORT_volt);
pLOAD->SHORT_curr = swap_u16(pP1->SHORT_curr);
pLOAD->OCP_volt = swap_u16(pP1->OCP_volt);
+2 -1
View File
@@ -1,7 +1,7 @@
/****************************************************************************
文件名称 : chrg_eload.h
完成日期 :
当前版本号 : V1.1.28
当前版本号 : V1.1.34
主要功能 : 源载命令数据解析,封装,读写请求,寄存器定义,数据结构定义。
版本历史 : 创建原始版本
说明 :
@@ -111,6 +111,7 @@ static const rt_uint8_t LOAD[30] = {
#define REG_TEMPERATUE (0x0B) // RWP 16bit 读取温度 0.01C (0~100C)
#define REG_VERSION (0x0C) // R 16bit 版本号 0~0xFFFF
#define ELOAD_CURRENT_ZERO_THRESHOLD_MA 20U /* 小于该值的采样电流按0mA处理 */
#define REG_ADDRESS (0x0D) // RWP 16bit 从机地址
+16 -2
View File
@@ -1,9 +1,23 @@
*** Using Compiler 'V6.16', folder: 'D:\keil mdk 2\ARM\ARMCLANG\Bin'
Build target 'chrg'
compiling chrg_switch.c...
compiling chrg_lcd.c...
compiling chrg_thread.c...
compiling main.c...
compiling chrg_vcom.c...
compiling chrg_rel.c...
compiling chrg_north_pkg.c...
compiling chrg_south.c...
compiling chrg_north.c...
compiling chrg_sink.c...
compiling chrg_source.c...
compiling chrg_roll_nor.c...
compiling chrg_eload.c...
compiling chrg_roll_sou.c...
compiling chrg_comm.c...
linking...
Program Size: Code=147104 RO-data=15312 RW-data=9328 ZI-data=16000
Program Size: Code=154164 RO-data=15916 RW-data=9356 ZI-data=16276
FromELF: creating hex file...
After Build - User command #1: fromelf --bin .\build\keil\Obj\chrg.axf -o build/chrg.bin
".\build\keil\Obj\chrg.axf" - 0 Error(s), 0 Warning(s).
Build Time Elapsed: 00:00:01
Build Time Elapsed: 00:00:04