Skip to content

Commit 713e7ef

Browse files
committed
Add eBrake Function
1 parent 2abe65e commit 713e7ef

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

embedded/app/include/state_machine.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ typedef struct stateMachine_t stateMachine_t;
3737

3838
state_t *getCurrState(void);
3939

40+
state_t *setCurrState(state_t *state);
4041
state_t *findState(char *name);
4142
/*
4243
* The state machine is a directed graph. Each edge is a transition

embedded/app/src/state_machine.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ state_t *getCurrState(void) {
250250
return stateMachine.currState;
251251
}
252252

253+
state_t *setCurrState(state_t *state) {
254+
stateMachine.currState = state;
255+
}
256+
253257
/***
254258
* runStateMachine -
255259
* Executes the current states action. A mini control loop

middleware/src/HVTCPSocket.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ extern "C"
1515
#include "data.h"
1616
#include "state_machine.h"
1717
#include "hv_iox.h"
18+
#include "braking.h"
1819
}
1920

2021

@@ -129,7 +130,9 @@ void *TCPLoop(void *arg)
129130

130131
if (!strncmp(buffer, "emergencyBrake", MAX_COMMAND_SIZE))
131132
{
132-
data->flags->emergencyBrake = 1;
133+
brake();
134+
setCurrSate(getCurrState() -> fault);
135+
133136
}
134137

135138
if (!strncmp(buffer, "hvEnable", MAX_COMMAND_SIZE))

0 commit comments

Comments
 (0)