Auto commit at 2025-05-30 16:48:18

This commit is contained in:
cxh 2025-05-30 16:48:18 +08:00
parent 6cd17d4a84
commit 3c73326531

View File

@ -45,10 +45,33 @@ void Msg_Handler(const mc::msg::CanFrame::SharedPtr msg)
case 0x1A2:
{
const uint8_t gearByte = msg->data[0];
info_report.gear = (gearByte & 0x01) ? 3 : ((gearByte >> 2) & 0x03);
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
const int tempRaw = (msg->data[5] << 8) | msg->data[6];
info_report.motorTemp = static_cast<int>(tempRaw * 0.1f - 100.0f);
break;
}