Auto commit at 2025-07-28 10:57:55

This commit is contained in:
cxh 2025-07-28 10:57:55 +08:00
parent e5ecb2e441
commit 6962b2fd98
2 changed files with 13 additions and 8 deletions

View File

@ -13,13 +13,14 @@ int64_t getCurrentTimestampMs()
struct GeneralMsg struct GeneralMsg
{ {
float power = 0.0f; // 电量 % float power = 0.0f; // 电量 %
bool chargeStatus = false; // 是否在充电 bool chargeStatus = false; // 是否在充电
int gear = 0; // 档位 int gear = 0; // 档位
float speed = 0.0f; // 当前速度 km/h float speed = 0.0f; // 当前速度 km/h
int waterLevel = 0; // 水位 float steeringAngle = 0.0f; // 转向角度
int motorTemp = 0; // 电机温度 °C int waterLevel = 0; // 水位
int64_t timestamp = 0; // 时间戳 int motorTemp = 0; // 电机温度 °C
int64_t timestamp = 0; // 时间戳
}; };
struct BMSFault struct BMSFault

View File

@ -126,6 +126,9 @@ void Msg_Handler(const mc::msg::CanFrame::SharedPtr msg)
case 0x401: case 0x401:
{ {
int16_t angle = (msg->data[3] * 256 + msg->data[4]) - 1024;
info_report.steeringAngle = angle / 5.0f;
// 清空所有 EPS 错误码 // 清空所有 EPS 错误码
for (int code = 1201; code <= 1218; ++code) for (int code = 1201; code <= 1218; ++code)
{ {
@ -133,7 +136,7 @@ void Msg_Handler(const mc::msg::CanFrame::SharedPtr msg)
} }
// 添加当前报文中的错误码最多2个 // 添加当前报文中的错误码最多2个
uint8_t data_bytes[2] = {msg->data[3], msg->data[7]}; uint8_t data_bytes[2] = {msg->data[2], msg->data[6]};
for (uint8_t byte : data_bytes) for (uint8_t byte : data_bytes)
{ {
for (int i = 0; i < 18; ++i) for (int i = 0; i < 18; ++i)
@ -210,6 +213,7 @@ std::string pack_general_info_to_json(const GeneralMsg &msg)
j["chargeStatus"] = msg.chargeStatus; j["chargeStatus"] = msg.chargeStatus;
j["gear"] = msg.gear; j["gear"] = msg.gear;
j["speed"] = msg.speed; j["speed"] = msg.speed;
j["steeringAngle"] = msg.steeringAngle;
j["waterLevel"] = msg.waterLevel; j["waterLevel"] = msg.waterLevel;
j["motorTemp"] = msg.motorTemp; j["motorTemp"] = msg.motorTemp;
j["timestamp"] = msg.timestamp; j["timestamp"] = msg.timestamp;