pCCU 锂电池通信切换为 CAN 总线(BMS 协议,经 pCanBridge 透传)
build-test-deploy / ci (push) Failing after 1h9m57s

协议层:
- 新增 protocol/CanBms.{h,cpp}:按 docs/BMS_协议字段定义.xlsx 解码
  0x10010000(总电压/SOC/故障码/状态位)、0x10010005(最大电流限制/
  总电流/最高单体电压)、0x10010006(总电压校验)。
  缩放用除法保证与十进制字面量严格一致;总电流按 2 字节 s16 实现
  (xlsx 标注 3 字节与其自身示例/实车帧矛盾,已在代码注释说明)。
- 删除 UDP 锂电池协议:protocol/BatProtocol.{h,cpp}、
  comm/BatLinkManager.h(动力/仪表双链路、自检/接触器/功率指令)。

pCCU 主体:
- CCU 订阅 pCanBridge 发布的 CAN_0x* 二进制消息并解码 BMS 报文;
  SystemData 双电池槽位改为单一 BmsStatusValue + CAN 帧计数;
  PM 电池启停/功率指令改为告警忽略(BMS CAN 协议未定义控制报文)。
- 修复两个本地联调发现的阻断性 bug:
  1) MOOS 通配订阅必须用三参数 Register("CAN_0x*","*",0),
     单参数形式不做通配匹配;
  2) 变量名前缀匹配偏移(compare 少比 1 字符 / sscanf +5 指向 'x'),
     改为 rfind 前缀判断 + +6 偏移。
- PowerCoordinator/CoordFsm 剥离电池接触器/切换时序(依赖已删除的
  UDP 指令),保留 FC 联动与协调策略占位(CoordSwitchingState 改为
  通用的 CoordBusyState)。

网页:
- 动力/仪表锂电池两个标签页合并为"锂电池BMS(CAN)":总电压/总电流/
  SOC/最大电流限制/最高单体电压/校验帧/故障码高亮/在线状态,
  附报文来源说明;链路状态页改为 CAN 链路行(pCanBridge)。

配置与测试:
- pCCU.moos / missions/h100.moos 移除电池 UDP 配置;
- pccuTest:删除旧电池编解码用例,新增 testCanBmsDecode
  (向量取自实车抓包:533.8V/20.1%/49/3.752V/-25.0A)103/103 通过;
- 集成测试改为纯 FC/PM 流程,本地实测 PASSED(含 Web 页面校验)。
This commit is contained in:
zjk
2026-08-31 21:42:26 +08:00
parent ee8819c610
commit 88bed850ee
23 changed files with 424 additions and 2115 deletions
+9 -15
View File
@@ -15,11 +15,11 @@ void showSynopsis() {
blk("SYNOPSIS: ");
blk("------------------------------------ ");
blk(" The pCCU application is the composite controller (CCU) ");
blk(" gateway between the fuel cell (FC) system / lithium battery ");
blk(" packs and pPowerManger. It receives FC & battery status, ");
blk(" integrates & forwards to pPowerManger, maps pPowerManger ");
blk(" commands to FC / battery operations, stores data in SQLite ");
blk(" and provides a web monitoring page. ");
blk(" gateway between the fuel cell (FC) system and pPowerManger. ");
blk(" It receives FC status, integrates & forwards to pPowerManger,");
blk(" maps pPowerManger commands to FC operations, receives CAN ");
blk(" bus BMS battery frames via pCanBridge (CAN_0x* MOOS msgs), ");
blk(" stores data in SQLite and provides a web monitoring page. ");
blk(" ");
}
@@ -68,13 +68,7 @@ void showExampleConfigAndExit() {
blk(" pm_local_port = 7000 // PM 指令接收端口 ");
blk(" pm_remote_ip = 192.168.0.140 // 控制主机 IP ");
blk(" pm_remote_port = 5001 // 控制主机接收端口 ");
blk(" dyn_bat_local_port = 7001 // 动力锂电池状态接收端口 ");
blk(" dyn_bat_remote_ip = 192.168.100.137 // 动力锂电池 IP ");
blk(" dyn_bat_remote_port = 7000 // 动力锂电池控制端口 ");
blk(" ins_bat_local_port = 7002 // 仪表锂电池状态接收端口 ");
blk(" ins_bat_remote_ip = 192.168.100.136 // 仪表锂电池 IP ");
blk(" ins_bat_remote_port = 7000 // 仪表锂电池控制端口 ");
blk(" bat_work_condition = 10 // 电池工况 10工房/30实航/50科研 ");
blk(" // 锂电池 BMS 走 CAN 总线(经 pCanBridge 的 CAN_0x* 透传) ");
blk(" dbpath = pccu_data.db // 数据库路径 ");
blk(" logpath = pCCU.log // 日志路径 ");
blk(" web_port = 8080 // 网页端口(避开8090/18080) ");
@@ -94,14 +88,14 @@ void showInterfaceAndExit() {
blk(" ");
blk("SUBSCRIPTIONS: ");
blk("------------------------------------ ");
blk(" (数据交换主要通过 UDP 链路完成,MOOSDB 交互有限) ");
blk(" CAN_0x* = pCanBridge 透传的 CAN 帧(锂电池 BMS) ");
blk(" CCU_FC_LINK_STATE = 运行状态字符串 ");
blk(" CCU_PM_LINK_STATE = 运行状态字符串 ");
blk(" ");
blk("PUBLICATIONS: ");
blk("------------------------------------ ");
blk(" CCU_FC_LINK_STATE = 运行状态字符串 ");
blk(" CCU_PM_LINK_STATE = 运行状态字符串 ");
blk(" CCU_DYN_BAT_LINK_STATE = 运行状态字符串 ");
blk(" CCU_INS_BAT_LINK_STATE = 运行状态字符串 ");
blk(" ");
exit(0);
}