Skip to content

Commit

Permalink
Prevent all motor PWM/CAN port outputs once HILS has been activated u…
Browse files Browse the repository at this point in the history
…ntil system restart.
mpaperno committed Apr 30, 2016
1 parent ff9e02a commit 12bd8dc
Showing 5 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/buildnum.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define BUILDNUMBER 1922
#define BUILDNUMBER 1923
5 changes: 4 additions & 1 deletion src/motors.c
Original file line number Diff line number Diff line change
@@ -142,7 +142,7 @@ static void motorsCheckCanStatus(int motorId) {
void motorsSendValues(void) {
int i;

if (supervisorData.state & STATE_SIM_ENABLED)
if (motorsData.disableAllPorts)
return;

for (int j = 0; j < motorsData.numActive; ++j) {
@@ -340,6 +340,9 @@ int motorsArm(void) {
int tries = 1;
int i;

if (motorsData.disableAllPorts)
return tries;

// group arm
for (i = 0; i < motorsData.numGroups; i++)
canCommandArm(CAN_TT_GROUP, i+1);
1 change: 1 addition & 0 deletions src/motors.h
Original file line number Diff line number Diff line change
@@ -83,6 +83,7 @@ typedef struct {
uint8_t activeList[MOTORS_NUM];
uint8_t numActive;
uint8_t numGroups;
bool disableAllPorts;
#ifdef MOTORS_CAN_LOGGING
uint8_t logHandle;
uint16_t head;
8 changes: 8 additions & 0 deletions src/supervisor.c
Original file line number Diff line number Diff line change
@@ -507,6 +507,14 @@ void supervisorConfigRead(void) {
supervisorData.configRead = 1;
}

void supervisorToggleSimState(bool enable) {
if (enable) {
supervisorData.state |= STATE_SIM_ENABLED;
motorsData.disableAllPorts = true; // disable all motor port output until restart
} else
supervisorData.state &= ~STATE_SIM_ENABLED;
}

bool supervisorRequestConfigAction(uint8_t act) {
if (act >= SPVR_ACT_REQ_ENUM_END || supervisorData.configActionRequest > SPVR_ACT_REQ_NONE) {
AQ_NOTICE("Error: Unknown or currently pending action.");
1 change: 1 addition & 0 deletions src/supervisor.h
Original file line number Diff line number Diff line change
@@ -142,6 +142,7 @@ extern void supervisorSendDataStop(void);
extern void supervisorConfigRead(void);
extern void supervisorArm(void);
extern void supervisorDisarm(void);
extern void supervisorToggleSimState(bool enable);
extern bool supervisorRequestConfigAction(uint8_t act);

#endif

0 comments on commit 12bd8dc

Please sign in to comment.