@@ -185,7 +185,8 @@ stateTransition_t * readyForLaunchAction() {
185185
186186
187187 // CHECK PRESSURE
188- if (!checkPrerunPressures ()){
188+ if (!checkPrerunPressures ())
189+ {
189190 return findTransition (stateMachine .currState , PRE_RUN_FAULT_NAME );
190191 }
191192
@@ -321,23 +322,23 @@ stateTransition_t * stoppedAction() {
321322 // CHECK FAULT CRITERIA
322323
323324 if (!checkBrakingPressures ()){ // Still unchanged
324- return findTransition (stateMachine .currState , POST_RUN_FAULT_NAME );
325+ return findTransition (stateMachine .currState , RUN_FAULT_NAME );
325326 }
326327
327328 // TODO check LV Power
328329 // TODO check LV Temp
329330
330331 if (!checkBrakingBattery ()){ // Still unchanged
331- return findTransition (stateMachine .currState , POST_RUN_FAULT_NAME );
332+ return findTransition (stateMachine .currState , RUN_FAULT_NAME );
332333 }
333334
334335 if (!checkStoppedRMS ()){ // Still unchanged
335- return findTransition (stateMachine .currState , POST_RUN_FAULT_NAME );
336+ return findTransition (stateMachine .currState , RUN_FAULT_NAME );
336337 }
337338
338339 // FIXME FIX ALL TIME CHECKS!
339340 if (getuSTimestamp () - data -> timers -> startTime > MAX_RUN_TIME ){
340- return findTransition (stateMachine .currState , POST_RUN_FAULT_NAME );
341+ return findTransition (stateMachine .currState , RUN_FAULT_NAME );
341342 }
342343
343344 // CHECK TRANSITION CRITERIA
@@ -351,38 +352,44 @@ stateTransition_t * stoppedAction() {
351352}
352353
353354stateTransition_t * crawlAction () {
355+
356+ // Start crawl timer
357+ if (data -> timers -> crawlTimer == 0 ){
358+ data -> timers -> crawlTimer = getuSTimestamp ();
359+ }
354360 data -> state = 8 ;
355361 /* Check IMD status */
356362 if (!getIMDStatus ()) {
357- return findTransition (stateMachine .currState , POST_RUN_FAULT_NAME );
363+ return findTransition (stateMachine .currState , RUN_FAULT_NAME );
358364 }
359365
360366 /* Check HV Indicator light */
361367 if (!isHVIndicatorEnabled ()) {
362- return findTransition (stateMachine .currState , POST_RUN_FAULT_NAME );
368+ return findTransition (stateMachine .currState , RUN_FAULT_NAME );
363369 }
364370
365371
366372 if (!checkCrawlPostrunPressures ()){
367- return findTransition (stateMachine .currState , POST_RUN_FAULT_NAME );
373+ return findTransition (stateMachine .currState , RUN_FAULT_NAME );
368374 }
369375
370376 // TODO check LV Power
371377 // TODO check LV Temp
372378
373379 if (!checkCrawlBattery ()){
374- return findTransition (stateMachine .currState , POST_RUN_FAULT_NAME );
380+ return findTransition (stateMachine .currState , RUN_FAULT_NAME );
375381 }
376382
377383 if (!checkCrawlRMS ()){ // Still unchanged
378- return findTransition (stateMachine .currState , POST_RUN_FAULT_NAME );
379- }
380-
381- if (getuSTimestamp () - data -> timers -> startTime > MAX_RUN_TIME ){
382- return findTransition (stateMachine .currState , POST_RUN_FAULT_NAME );
384+ return findTransition (stateMachine .currState , RUN_FAULT_NAME );
383385 }
384386
385387 // CHECK TRANSITION CRITERIA
388+
389+ if (getuSTimestamp () - data -> timers -> crawlTimer > MAX_CRAWL_TIME ){
390+ return findTransition (stateMachine .currState , BRAKING_NAME );
391+ }
392+
386393 if (data -> flags -> shouldStop ){
387394 return findTransition (stateMachine .currState , BRAKING_NAME );
388395 }
0 commit comments