@@ -59,7 +59,7 @@ bool checkingPrechargeStatus = false;
59
59
bool checkingShutdownStatus = false ;
60
60
61
61
bool prechargeDone = false ;
62
- bool hasBmsFault = true ;
62
+ bool hasBmsFault = false ; // assume no fault at start
63
63
bool isCharging = false ;
64
64
bool hasFansOn = false ;
65
65
bool isBalancing = false ;
@@ -127,7 +127,6 @@ int main() {
127
127
continue ; // If not an osEventMessage, continue
128
128
}
129
129
// Status Message unpacking from bmsEvent
130
- hasBmsFault = false ;
131
130
132
131
133
132
maxCellTemp = bmsEvent->maxTemp ; // Assign the maxTemp from bmsEvent
@@ -168,6 +167,7 @@ int main() {
168
167
// Process the bmsState value in bmsEvent
169
168
case BMSThreadState::BMSStartup:
170
169
printf (" BMS Fault Startup State\n " );
170
+ hasBmsFault = false ;
171
171
break ;
172
172
case BMSThreadState::BMSIdle:
173
173
// printf("BMS Fault Idle State\n");
@@ -184,7 +184,6 @@ int main() {
184
184
break ;
185
185
case BMSThreadState::BMSFaultRecover:
186
186
printf (" BMS Fault Recovery State\n " );
187
- hasBmsFault = false ;
188
187
break ;
189
188
case BMSThreadState::BMSFault:
190
189
printf (" *** BMS FAULT ***\n " );
@@ -251,7 +250,7 @@ int main() {
251
250
}
252
251
253
252
bms_fault_pin = !hasBmsFault;
254
- bms_fault_inverse_pin = !bms_fault_pin ;
253
+ bms_fault_inverse_pin = hasBmsFault ;
255
254
256
255
257
256
precharge_control_pin = prechargeDone;
@@ -264,7 +263,7 @@ int main() {
264
263
}
265
264
fan_pwm.write (fan_percent / 100.0 );
266
265
267
- printf (" shutdown state: %x\n " , shutdown_measure_pin.read ());
266
+ // printf("shutdown state: %x\n", shutdown_measure_pin.read());
268
267
269
268
status_message.bmsFault = hasBmsFault;
270
269
status_message.shutdownState = shutdown_measure_pin.read ();
@@ -336,8 +335,8 @@ void initIO() {
336
335
fan_pwm.period_us (40 );
337
336
fan_pwm.write (0 );
338
337
fan_percent = 0 ;
339
- bms_fault_pin = 1 ; // assume no fault at start, 1 is no fault
340
- bms_fault_inverse_pin = 0 ; // assume no fault at start, 0 is no fault
338
+ bms_fault_pin = !hasBmsFault ; // assume no fault at start, 1 is no fault
339
+ bms_fault_inverse_pin = hasBmsFault ; // assume no fault at start, 0 is no fault
341
340
precharge_control_pin = 0 ; // positive AIR open at start
342
341
state_of_charge = 100 ; // TODO: CHANGE TO ACCOUNT FOR POSSIBLE DISCHARGE
343
342
0 commit comments