protocol_v2: added implementation to bms basic and bms extended msg

This commit is contained in:
rdu
2022-07-05 12:51:22 +08:00
parent 9b7fc33d38
commit d8f7278477

View File

@@ -185,8 +185,7 @@ bool DecodeCanFrameV2(const struct can_frame *rx_frame, AgxMessage *msg) {
msg->body.actuator_ls_state_msg.driver_temp =
(int16_t)((uint16_t)(frame->driver_temp.low_byte) |
(uint16_t)(frame->driver_temp.high_byte) << 8);
msg->body.actuator_ls_state_msg.motor_temp =
frame->motor_temp;
msg->body.actuator_ls_state_msg.motor_temp = frame->motor_temp;
msg->body.actuator_ls_state_msg.driver_state = frame->driver_state;
break;
}
@@ -256,12 +255,34 @@ bool DecodeCanFrameV2(const struct can_frame *rx_frame, AgxMessage *msg) {
}
case CAN_MSG_BMS_BASIC_ID: {
msg->type = AgxMsgBmsBasic;
// TODO
BmsBasicFrame *frame = (BmsBasicFrame *)(rx_frame->data);
msg->body.bms_basic_msg.battery_soc = frame->battery_soc;
msg->body.bms_basic_msg.battery_soh = frame->battery_soh;
msg->body.bms_basic_msg.voltage =
((uint16_t)(frame->voltage.low_byte) |
(uint16_t)(frame->voltage.high_byte) << 8) /
10.0f;
msg->body.bms_basic_msg.current =
(int16_t)((uint16_t)(frame->current.low_byte) |
(uint16_t)(frame->current.high_byte) << 8) /
10.0f;
msg->body.bms_basic_msg.temperature =
(int16_t)(((uint16_t)(frame->temperature.low_byte) |
(uint16_t)(frame->temperature.high_byte) << 8)) /
10.0f;
break;
}
case CAN_MSG_BMS_EXTENDED_ID: {
msg->type = AgxMsgBmsExtended;
// TODO
BmsExtendedFrame *frame = (BmsExtendedFrame *)(rx_frame->data);
msg->body.bms_extended_msg.protection_code1 = frame->protection_code1;
msg->body.bms_extended_msg.protection_code2 = frame->protection_code2;
msg->body.bms_extended_msg.protection_code3 = frame->protection_code3;
msg->body.bms_extended_msg.protection_code4 = frame->protection_code4;
msg->body.bms_extended_msg.battery_max_teperature =
frame->battery_max_teperature;
msg->body.bms_extended_msg.battery_min_teperature =
frame->battery_min_teperature;
break;
}
/*************** query/config frame **************/