Read AMS min voltage & max temp as 16 bit ints
This commit is contained in:
parent
c6f237b87e
commit
583017c22e
|
@ -18,8 +18,8 @@
|
||||||
#define CAN_ID_SHUNT_CURRENT 0x521
|
#define CAN_ID_SHUNT_CURRENT 0x521
|
||||||
#define CAN_ID_SHUNT_VOLTAGE2 0x523
|
#define CAN_ID_SHUNT_VOLTAGE2 0x523
|
||||||
#define CAN_ID_SHUNT_VOLTAGE3 0x524
|
#define CAN_ID_SHUNT_VOLTAGE3 0x524
|
||||||
#define CAN_AMS_STATUS_VOLTAGE_FACTOR (1e-3 * 0x100)
|
#define CAN_AMS_STATUS_VOLTAGE_FACTOR 1e-4
|
||||||
#define CAN_AMS_STATUS_TEMP_FACTOR (0.0625 * 0x10)
|
#define CAN_AMS_STATUS_TEMP_FACTOR 0.0625
|
||||||
|
|
||||||
VehicleState vehicle_state = {0};
|
VehicleState vehicle_state = {0};
|
||||||
|
|
||||||
|
@ -50,8 +50,11 @@ void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t *data) {
|
||||||
case CAN_ID_AMS_STATUS:
|
case CAN_ID_AMS_STATUS:
|
||||||
vehicle_state.ts_state = data[0] & 0x7F;
|
vehicle_state.ts_state = data[0] & 0x7F;
|
||||||
vehicle_state.soc = data[1];
|
vehicle_state.soc = data[1];
|
||||||
vehicle_state.min_cell_volt = data[2] * CAN_AMS_STATUS_VOLTAGE_FACTOR;
|
const uint8_t *ptr = &data[2];
|
||||||
vehicle_state.max_cell_temp = data[3] * CAN_AMS_STATUS_TEMP_FACTOR;
|
vehicle_state.min_cell_volt =
|
||||||
|
ftcan_unmarshal_unsigned(&ptr, 2) * CAN_AMS_STATUS_VOLTAGE_FACTOR;
|
||||||
|
vehicle_state.max_cell_temp =
|
||||||
|
ftcan_unmarshal_signed(&ptr, 2) * CAN_AMS_STATUS_TEMP_FACTOR;
|
||||||
msg = VEH_UPD_AMS;
|
msg = VEH_UPD_AMS;
|
||||||
break;
|
break;
|
||||||
case CAN_ID_AS_MISSION_FB:
|
case CAN_ID_AS_MISSION_FB:
|
||||||
|
|
Loading…
Reference in New Issue