Makes the CANJaguar error status messages more useful (#165)

The previous version would just return the class name for the
DigitalOutput port. Now it actually gets the dio port value for better
readability.
This commit is contained in:
Thad House
2016-07-12 21:53:51 -07:00
committed by Peter Johnson
parent edf5ecd4a0
commit ea1a1e6bc3
4 changed files with 26 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ class DigitalOutput : public DigitalSource,
explicit DigitalOutput(uint32_t channel);
virtual ~DigitalOutput();
void Set(bool value);
bool Get();
uint32_t GetChannel() const override;
void Pulse(float length);
bool IsPulsing() const;

View File

@@ -72,6 +72,20 @@ void DigitalOutput::Set(bool value) {
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
}
/**
* Gets the value being output from the Digital Output.
*
* @return the state of the digital output.
*/
bool DigitalOutput::Get() {
if (StatusIsFatal()) return false;
int32_t status = 0;
bool val = HAL_GetDIO(m_handle, &status);
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
return val;
}
/**
* @return The GPIO channel number that this object represents.
*/

View File

@@ -64,6 +64,15 @@ public class DigitalOutput extends DigitalSource implements LiveWindowSendable {
DIOJNI.setDIO(m_handle, (short) (value ? 1 : 0));
}
/**
* Gets the value being output from the Digital Output.
*
* @return the state of the digital output.
*/
public boolean get() {
return DIOJNI.getDIO(m_handle);
}
/**
* @return The GPIO channel number that this object represents.
*/

View File

@@ -161,12 +161,12 @@ public abstract class CANMotorEncoderFixture extends MotorEncoderFixture<CANJagu
status.append("\t" + "CANJaguar Motor = null" + "\n");
}
if (m_forwardLimit != null) {
status.append("\tForward Limit Output = " + m_forwardLimit + "\n");
status.append("\tForward Limit Output = " + m_forwardLimit.get() + "\n");
} else {
status.append("\tForward Limit Output = null" + "\n");
}
if (m_reverseLimit != null) {
status.append("\tReverse Limit Output = " + m_reverseLimit + "\n");
status.append("\tReverse Limit Output = " + m_reverseLimit.get() + "\n");
} else {
status.append("\tReverse Limit Output = null" + "\n");
}