Auto commit at 2025-07-28 10:57:55
This commit is contained in:
parent
e5ecb2e441
commit
6962b2fd98
@ -17,6 +17,7 @@ struct GeneralMsg
|
||||
bool chargeStatus = false; // 是否在充电
|
||||
int gear = 0; // 档位
|
||||
float speed = 0.0f; // 当前速度 km/h
|
||||
float steeringAngle = 0.0f; // 转向角度
|
||||
int waterLevel = 0; // 水位
|
||||
int motorTemp = 0; // 电机温度 °C
|
||||
int64_t timestamp = 0; // 时间戳
|
||||
|
||||
@ -126,6 +126,9 @@ void Msg_Handler(const mc::msg::CanFrame::SharedPtr msg)
|
||||
|
||||
case 0x401:
|
||||
{
|
||||
int16_t angle = (msg->data[3] * 256 + msg->data[4]) - 1024;
|
||||
info_report.steeringAngle = angle / 5.0f;
|
||||
|
||||
// 清空所有 EPS 错误码
|
||||
for (int code = 1201; code <= 1218; ++code)
|
||||
{
|
||||
@ -133,7 +136,7 @@ void Msg_Handler(const mc::msg::CanFrame::SharedPtr msg)
|
||||
}
|
||||
|
||||
// 添加当前报文中的错误码(最多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 (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["gear"] = msg.gear;
|
||||
j["speed"] = msg.speed;
|
||||
j["steeringAngle"] = msg.steeringAngle;
|
||||
j["waterLevel"] = msg.waterLevel;
|
||||
j["motorTemp"] = msg.motorTemp;
|
||||
j["timestamp"] = msg.timestamp;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user