Auto commit at 2025-05-30 17:17:43

This commit is contained in:
cxh 2025-05-30 17:17:43 +08:00
parent 3c73326531
commit a4f58aa70f

View File

@ -45,33 +45,11 @@ void Msg_Handler(const mc::msg::CanFrame::SharedPtr msg)
case 0x1A2: case 0x1A2:
{ {
const uint8_t gearByte = msg->data[0]; const uint8_t gearByte = msg->data[0];
if (gearByte & 0x01)
{
info_report.gear = 3;
}
else
{
// bit2-3 表示当前挡位:
switch ((gearByte >> 2) & 0x03)
{
case 1:
info_report.gear = 2;
break;
case 2:
info_report.gear = 0;
break;
case 3:
info_report.gear = 1;
break;
default:
break;
}
}
// 温度计算data[5-6] 是一个 16-bit 原始值,单位 0.1°C偏移量 -100°C info_report.gear = (gearByte & 0x01) ? 3 : ((gearByte >> 2) & 0x03);
const int tempRaw = (msg->data[5] << 8) | msg->data[6]; const int tempRaw = (msg->data[5] << 8) | msg->data[6];
info_report.motorTemp = static_cast<int>(tempRaw * 0.1f - 100.0f); info_report.motorTemp = static_cast<int>(tempRaw * 0.1f - 100.0f);
break; break;
} }