Skip to content

Commit 6a110ae

Browse files
author
Ezra Boley
committed
Merge branch 'crawl-timer' of https://github.com/badgerloop-software/pod into embedded-statemachine-dev
2 parents 6abf522 + 9eada91 commit 6a110ae

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

embedded/app/include/states.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
#define MIN_DISTANCE_TO_END 30 /*in m //FIXME Confirm how far from the end of the tube we need to stop */
142142

143143
#define MAX_RUN_TIME 30000000 /* in microseconds, TODO get the real number */
144+
#define MAX_CRAWL_TIME 30000000 /* in microseconds, TODO get the real number */
144145

145146

146147

embedded/app/src/init.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,6 @@ int initTimerData() {
156156
data->timers->startTime = 0;
157157
data->timers->lastRetro = 0;
158158
for (i = 0; i < NUM_RETROS; i++) data->timers->lastRetros[i] = 0;
159+
data->timers->crawlTimer = 0;
159160
return 0;
160161
}

embedded/app/src/states.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,11 @@ stateTransition_t * stoppedAction() {
352352
}
353353

354354
stateTransition_t * crawlAction() {
355+
356+
// Start crawl timer
357+
if(data->timers->crawlTimer == 0){
358+
data->timers->crawlTimer = getuSTimestamp();
359+
}
355360
data->state = 8;
356361
/* Check IMD status */
357362
if (!getIMDStatus()) {
@@ -379,11 +384,12 @@ stateTransition_t * crawlAction() {
379384
return findTransition(stateMachine.currState, RUN_FAULT_NAME);
380385
}
381386

382-
if (getuSTimestamp() - data->timers->startTime > MAX_RUN_TIME){
383-
return findTransition(stateMachine.currState, RUN_FAULT_NAME);
384-
}
385-
386387
// CHECK TRANSITION CRITERIA
388+
389+
if (getuSTimestamp() - data->timers->crawlTimer > MAX_CRAWL_TIME){
390+
return findTransition(stateMachine.currState, BRAKING_NAME);
391+
}
392+
387393
if(data->flags->shouldStop){
388394
return findTransition(stateMachine.currState, BRAKING_NAME);
389395
}

embedded/data/include/data.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ typedef struct timers_t {
7676
uint64_t oldRetro;
7777
uint64_t lastRetro;
7878
uint64_t lastRetros[NUM_RETROS];
79+
uint64_t crawlTimer;
7980
} timers_t;
8081

8182

0 commit comments

Comments
 (0)