mirror of
https://github.com/dalathegreat/Battery-Emulator.git
synced 2025-10-05 10:49:42 +02:00
Dont read SOC if it is unavailable
This commit is contained in:
parent
75b59eaff6
commit
3c3e2fabe2
1 changed files with 12 additions and 6 deletions
|
@ -141,13 +141,19 @@ void receive_can_battery(CAN_frame_t rx_frame) {
|
|||
switch (rx_frame.MsgID) {
|
||||
case 0x374: //BMU message, 10ms - SOC
|
||||
temp_value = ((rx_frame.data.u8[1] - 10) / 2);
|
||||
if (temp_value < 0) {
|
||||
BMU_SOC = 0;
|
||||
} else if (temp_value > 100) {
|
||||
BMU_SOC = 100;
|
||||
} else { // Between 0-100
|
||||
BMU_SOC = temp_value;
|
||||
|
||||
if (temp_value == 205) {
|
||||
// Use the value we sampled last time
|
||||
} else { // We have a valid value
|
||||
if (temp_value < 0) {
|
||||
BMU_SOC = 0;
|
||||
} else if (temp_value > 100) {
|
||||
BMU_SOC = 100;
|
||||
} else { // Between 0-100
|
||||
BMU_SOC = temp_value;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 0x373: //BMU message, 100ms - Pack Voltage and current
|
||||
BMU_Current = ((((((rx_frame.data.u8[2] * 256.0) + rx_frame.data.u8[3])) - 32768)) * 0.01);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue