Files
H100PowerManger/src/pMotor/Motor_Info.cpp
T
zjk 873a1a9b09
build-test-deploy / ci (push) Failing after 32m37s
新增 pMotor 推进电机操作程序:经 pCanBridge(CAN1) 与电机控制器交互
- 协议模块(protocol/MotorCan):12 条 CAN ID、指令帧 0x18EF2010 编码、
  状态帧(转速/母线电压/温度)与支路一/二故障报警帧解码,故障位按协议
  逐位映射中文描述(docs/推进电机通信协议20260321.docx)
- 主程序(MOOS 应用):订阅 pCanBridge 透传 CAN_0x* 解码电机状态;
  500ms 周期下发指令帧(CAN_TX_0x18EF2010,m_sSrcAux=CAN1),
  可选 red_channel 冗余下发 0x18EF2011;复位位保持 reset_hold_sec
- 网页(18081):按协议指令帧字段独立下发(使能命令 Byte0 bit0 /
  复位命令 Byte0 bit1 / 期望转速 Byte2/3,无联动按钮);
  WebSocket 1Hz 推送转速/电压/温度/故障告警/链路统计
- 配置接入:missions/h100.moos 增加 pMotor 配置块(can_channel=CAN1)
- 测试:pmotorTest 92 项(指令帧字节级对照协议示例、解码/故障表)
- 部署:scripts/build-board.sh 增加 pMotor 产物拷贝 + pMotor.service;
  .gitignore 补 bin/pMotor、bin/pmotorTest
- 联调验证:MOOSDB+pCanBridge+假CANET 全链路,下行帧 01 00 E8 03
  与协议文档示例一致,复位位 3s 保持行为正确
2026-09-02 10:50:28 +08:00

104 lines
5.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/****************************************************************/
/* NAME: Motor_Info */
/* FILE: Motor_Info.cpp */
/****************************************************************/
#include <cstdlib>
#include <iostream>
#include "Motor_Info.h"
#include "ColorParse.h"
#include "ReleaseInfo.h"
using namespace std;
void showSynopsis() {
blk("SYNOPSIS: ");
blk("------------------------------------ ");
blk(" The pMotor application is the propulsion motor operation ");
blk(" program. It talks to the motor controller over CAN (via ");
blk(" pCanBridge pass-through, default channel CAN1): ");
blk(" subscribes motor state/fault frames (CAN_0x*), sends the ");
blk(" 500ms periodic command frame 0x18EF2010 (enable/reset/speed) ");
blk(" via MOOS CAN_TX_0x*, and provides a web page for control ");
blk(" and monitoring. Protocol: ");
blk(" docs/推进电机通信协议20260321.docx. ");
blk(" ");
}
void showHelpAndExit() {
blk(" ");
blu("=============================================================== ");
blu("Usage: pMotor file.moos [OPTIONS] ");
blu("=============================================================== ");
blk(" ");
showSynopsis();
blk(" ");
blk("Options: ");
mag(" --alias","=<ProcessName> ");
blk(" Launch pMotor with the given process name ");
blk(" rather than pMotor. ");
mag(" --example, -e ");
blk(" Display example MOOS configuration block. ");
mag(" --help, -h ");
blk(" Display this help message. ");
mag(" --interface, -i ");
blk(" Display MOOS publications and subscriptions. ");
mag(" --version,-v ");
blk(" Display the release version of pMotor. ");
blk(" ");
blk("Note: If argv[2] does not otherwise match a known option, ");
blk(" then it will be interpreted as a run alias. This is ");
blk(" to support pAntler launching conventions. ");
blk(" ");
exit(0);
}
void showExampleConfigAndExit() {
blk(" ");
blu("=============================================================== ");
blu("pMotor Example MOOS Configuration ");
blu("=============================================================== ");
blk(" ");
blk("ProcessConfig = pMotor ");
blk("{ ");
blk(" AppTick = 4 ");
blk(" CommsTick = 4 ");
blk(" ");
blk(" can_channel = CAN1 // 电机 CAN 通道(pCanBridge 配置名) ");
blk(" red_channel = // 冗余 CAN 通道(空=不发冗余帧) ");
blk(" cmd_period_ms = 500 // 指令帧周期(协议 500ms) ");
blk(" reset_hold_sec= 5 // 复位位保持时长(秒) ");
blk(" web_port = 18081 // 网页端口(避开8080/8090/18080) ");
blk(" web_enable = true // 是否启用网页 ");
blk(" logpath = pMotor.log // 日志路径 ");
blk("} ");
blk(" ");
exit(0);
}
void showInterfaceAndExit() {
blk(" ");
blu("=============================================================== ");
blu("pMotor INTERFACE ");
blu("=============================================================== ");
blk(" ");
showSynopsis();
blk(" ");
blk("SUBSCRIPTIONS: ");
blk("------------------------------------ ");
blk(" CAN_0x* = pCanBridge 透传的 CAN 帧(电机状态/故障) ");
blk(" ");
blk("PUBLICATIONS: ");
blk("------------------------------------ ");
blk(" CAN_TX_0x18EF2010 = 主控指令帧(二进制 8 字节数据域, ");
blk(" m_sSrcAux=CAN1,经 pCanBridge 下行) ");
blk(" CAN_TX_0x18EF2011 = 指令帧冗余(配置 red_channel 时发送) ");
blk(" ");
exit(0);
}
void showReleaseInfoAndExit() {
showReleaseInfo("pMotor", "gpl");
exit(0);
}