FC协议(0827 docx): - 控制指令域:字节12,13/16,17由纵倾/横倾姿态数据2改为预留(编码恒0、解码忽略) - 状态反馈域:字节147,148由预留12改为剩余发电量(MWh),贯通JSON/网页显示 - PM→CCU链路:姿态字段4xuchar改为2xshort(数据1),结构体大小与线上布局不变 - 同步更新:CCU转发映射、SnapshotBuilder、pCCU网页、fuelcell网页、SQLite列描述、单测/模拟器 - 修正集成测试遗留断言(20B→24B、心跳d[19]→d[23])并增强预留字节校验 CCU地址可配置: - pPowerManger 支持 moos 配置项 ccuhost/ccuport(默认127.0.0.1:7000) - build-board.sh 增加 --ccu-host/--ccu-port 参数 文档:FC协议文档更新为0827版,清理过期协议docx
This commit is contained in:
@@ -22,9 +22,9 @@ enum : size_t {
|
||||
CO_CMD = 1, // 操控指令 (字节8)
|
||||
CO_OUT_POWER = 2, // 输出功率指令 (字节9)
|
||||
CO_PITCH1 = 3, // 纵倾姿态数据1 int16 (字节10,11)
|
||||
CO_PITCH2 = 5, // 纵倾姿态数据2 int16 (字节12,13)
|
||||
CO_RESERVED1 = 5, // 预留 (字节12,13),0827协议由纵倾姿态数据2改为预留
|
||||
CO_ROLL1 = 7, // 横倾姿态数据1 int16 (字节14,15)
|
||||
CO_ROLL2 = 9, // 横倾姿态数据2 int16 (字节16,17)
|
||||
CO_RESERVED2 = 9, // 预留 (字节16,17),0827协议由横倾姿态数据2改为预留
|
||||
CO_EMER_ALLOW = 11, // 应急允许 (字节18)
|
||||
CO_DEPTH = 12, // 潜深深度 u16 (字节19,20)
|
||||
CO_SUPPLY_CMD = 14, // 补给/排放指令 (字节21)
|
||||
@@ -42,9 +42,9 @@ std::vector<uint8_t> FcControlMessage::encode(const void* obj) const {
|
||||
FieldCodec::putU8(payload, CO_CMD, v->cmd);
|
||||
FieldCodec::putU8(payload, CO_OUT_POWER, v->outputPower);
|
||||
FieldCodec::putU16(payload, CO_PITCH1, static_cast<uint16_t>(v->pitch1));
|
||||
FieldCodec::putU16(payload, CO_PITCH2, static_cast<uint16_t>(v->pitch2));
|
||||
FieldCodec::putU16(payload, CO_RESERVED1, 0); // 预留恒填0
|
||||
FieldCodec::putU16(payload, CO_ROLL1, static_cast<uint16_t>(v->roll1));
|
||||
FieldCodec::putU16(payload, CO_ROLL2, static_cast<uint16_t>(v->roll2));
|
||||
FieldCodec::putU16(payload, CO_RESERVED2, 0); // 预留恒填0
|
||||
FieldCodec::putU8(payload, CO_EMER_ALLOW, v->emergencyAllow);
|
||||
FieldCodec::putU16(payload, CO_DEPTH, v->depth);
|
||||
FieldCodec::putU8(payload, CO_SUPPLY_CMD, v->supplyCmd);
|
||||
@@ -64,9 +64,9 @@ bool FcControlMessage::decode(const std::vector<uint8_t>& frame, void* obj) cons
|
||||
v->cmd = FieldCodec::getU8(frame, o + CO_CMD);
|
||||
v->outputPower = FieldCodec::getU8(frame, o + CO_OUT_POWER);
|
||||
v->pitch1 = static_cast<int16_t>(FieldCodec::getU16(frame, o + CO_PITCH1));
|
||||
v->pitch2 = static_cast<int16_t>(FieldCodec::getU16(frame, o + CO_PITCH2));
|
||||
// 字节12,13 预留,忽略
|
||||
v->roll1 = static_cast<int16_t>(FieldCodec::getU16(frame, o + CO_ROLL1));
|
||||
v->roll2 = static_cast<int16_t>(FieldCodec::getU16(frame, o + CO_ROLL2));
|
||||
// 字节16,17 预留,忽略
|
||||
v->emergencyAllow = FieldCodec::getU8(frame, o + CO_EMER_ALLOW);
|
||||
v->depth = FieldCodec::getU16(frame, o + CO_DEPTH);
|
||||
v->supplyCmd = FieldCodec::getU8(frame, o + CO_SUPPLY_CMD);
|
||||
@@ -153,7 +153,8 @@ enum : size_t {
|
||||
OFF_ALLOY_H2_FLOW = 112, // 合金供氢流量 (字节119-120)
|
||||
OFF_FC_H2_FLOW = 114, // FC供氢流量 (字节121-122)
|
||||
OFF_FC_O2_FLOW = 116, // FC供氧流量 (字节123-124)
|
||||
OFF_RESERVED = 118, // 预留1~12 u16*12 -> 118..141 (字节125-148)
|
||||
OFF_RESERVED = 118, // 预留1~11 u16*11 -> 118..138 (字节125-146)
|
||||
OFF_REMAIN_GEN = 140, // 剩余发电量 u16 (字节147,148),0827协议由预留12改为
|
||||
OFF_HEARTBEAT = 142, // 通信心跳 (字节149)
|
||||
OFF_EMERGENCY_CMD = 143, // 应急指令 (字节150)
|
||||
};
|
||||
@@ -244,7 +245,8 @@ std::vector<uint8_t> FcStatusMessage::encode(const void* obj) const {
|
||||
FieldCodec::putU16(p, OFF_FC_H2_FLOW, v->fc_h2_flow);
|
||||
FieldCodec::putU16(p, OFF_FC_O2_FLOW, v->fc_o2_flow);
|
||||
|
||||
putU16Arr(p, OFF_RESERVED, v->reserved, 12);
|
||||
putU16Arr(p, OFF_RESERVED, v->reserved, 11);
|
||||
FieldCodec::putU16(p, OFF_REMAIN_GEN, v->remaining_generation);
|
||||
|
||||
FieldCodec::putU8(p, OFF_HEARTBEAT, v->heartbeat);
|
||||
FieldCodec::putU8(p, OFF_EMERGENCY_CMD, v->emergency_cmd);
|
||||
@@ -331,7 +333,8 @@ bool FcStatusMessage::decode(const std::vector<uint8_t>& frame, void* obj) const
|
||||
v->fc_h2_flow = FieldCodec::getU16(frame, o + OFF_FC_H2_FLOW);
|
||||
v->fc_o2_flow = FieldCodec::getU16(frame, o + OFF_FC_O2_FLOW);
|
||||
|
||||
getU16Arr(frame, o + OFF_RESERVED, v->reserved, 12);
|
||||
getU16Arr(frame, o + OFF_RESERVED, v->reserved, 11);
|
||||
v->remaining_generation = FieldCodec::getU16(frame, o + OFF_REMAIN_GEN);
|
||||
|
||||
v->heartbeat = FieldCodec::getU8(frame, o + OFF_HEARTBEAT);
|
||||
v->emergency_cmd = FieldCodec::getU8(frame, o + OFF_EMERGENCY_CMD);
|
||||
|
||||
Reference in New Issue
Block a user