CANJaguar::Disable stops periodic setpoints

Calling CANJaguar::Disable() now makes NetComms stop periodic
setpoint messages, so the motor actually stops until EnableControl()
is called again.

Change-Id: Ib4eb4ad5f729be5c74e799f02ed000511de1e03d
This commit is contained in:
Thomas Clark
2014-07-29 11:09:37 -04:00
parent 6af242b556
commit d66bafb687
2 changed files with 25 additions and 39 deletions

View File

@@ -16,7 +16,6 @@
#include "LiveWindow/LiveWindow.h"
/* we are on ARM-LE now, not Freescale so no need to swap */
//TODO: is this defined in a PN way? or is this Jag-specific?
#define swap16(x) (x)
#define swap32(x) (x)
@@ -1322,24 +1321,19 @@ void CANJaguar::DisableControl()
uint8_t dataBuffer[8];
uint8_t dataSize = 0;
switch(m_controlMode)
{
case kPercentVbus:
sendMessage(LM_API_VOLT_DIS, dataBuffer, dataSize);
break;
case kSpeed:
sendMessage(LM_API_SPD_DIS, dataBuffer, dataSize);
break;
case kPosition:
sendMessage(LM_API_POS_DIS, dataBuffer, dataSize);
break;
case kCurrent:
sendMessage(LM_API_ICTRL_DIS, dataBuffer, dataSize);
break;
case kVoltage:
sendMessage(LM_API_VCOMP_DIS, dataBuffer, dataSize);
break;
}
// Disable all control
sendMessage(LM_API_VOLT_DIS, dataBuffer, dataSize);
sendMessage(LM_API_SPD_DIS, dataBuffer, dataSize);
sendMessage(LM_API_POS_DIS, dataBuffer, dataSize);
sendMessage(LM_API_ICTRL_DIS, dataBuffer, dataSize);
sendMessage(LM_API_VCOMP_DIS, dataBuffer, dataSize);
// Stop all periodic setpoints
sendMessage(LM_API_VOLT_T_SET, dataBuffer, dataSize, CAN_SEND_PERIOD_STOP_REPEATING);
sendMessage(LM_API_SPD_T_SET, dataBuffer, dataSize, CAN_SEND_PERIOD_STOP_REPEATING);
sendMessage(LM_API_POS_T_SET, dataBuffer, dataSize, CAN_SEND_PERIOD_STOP_REPEATING);
sendMessage(LM_API_ICTRL_T_SET, dataBuffer, dataSize, CAN_SEND_PERIOD_STOP_REPEATING);
sendMessage(LM_API_VCOMP_T_SET, dataBuffer, dataSize, CAN_SEND_PERIOD_STOP_REPEATING);
m_controlEnabled = false;
}

View File

@@ -1033,27 +1033,19 @@ public class CANJaguar implements MotorSafety, PIDOutput, SpeedController, LiveW
* Stop driving the output based on the feedback.
*/
public void disableControl() {
switch(m_controlMode) {
case PercentVbus:
sendMessage(CANJNI.LM_API_VOLT_DIS, new byte[0], 0);
break;
// Disable all control modes.
sendMessage(CANJNI.LM_API_VOLT_DIS, new byte[0], 0);
sendMessage(CANJNI.LM_API_SPD_DIS, new byte[0], 0);
sendMessage(CANJNI.LM_API_POS_DIS, new byte[0], 0);
sendMessage(CANJNI.LM_API_ICTRL_DIS, new byte[0], 0);
sendMessage(CANJNI.LM_API_VCOMP_DIS, new byte[0], 0);
case Speed:
sendMessage(CANJNI.LM_API_SPD_DIS, new byte[0], 0);
break;
case Position:
sendMessage(CANJNI.LM_API_POS_DIS, new byte[0], 0);
break;
case Current:
sendMessage(CANJNI.LM_API_ICTRL_DIS, new byte[0], 0);
break;
case Voltage:
sendMessage(CANJNI.LM_API_VCOMP_DIS, new byte[0], 0);
break;
}
// Stop all periodic setpoints
sendMessage(CANJNI.LM_API_VOLT_T_SET, new byte[0], 0, CANJNI.CAN_SEND_PERIOD_STOP_REPEATING);
sendMessage(CANJNI.LM_API_SPD_T_SET, new byte[0], 0, CANJNI.CAN_SEND_PERIOD_STOP_REPEATING);
sendMessage(CANJNI.LM_API_POS_T_SET, new byte[0], 0, CANJNI.CAN_SEND_PERIOD_STOP_REPEATING);
sendMessage(CANJNI.LM_API_ICTRL_T_SET, new byte[0], 0, CANJNI.CAN_SEND_PERIOD_STOP_REPEATING);
sendMessage(CANJNI.LM_API_VCOMP_T_SET, new byte[0], 0, CANJNI.CAN_SEND_PERIOD_STOP_REPEATING);
m_controlEnabled = false;
}