diff --git a/hal/include/HAL/Compressor.hpp b/hal/include/HAL/Compressor.hpp index 15c2e907d3..5c222ebc63 100644 --- a/hal/include/HAL/Compressor.hpp +++ b/hal/include/HAL/Compressor.hpp @@ -23,6 +23,14 @@ extern "C" { bool getPressureSwitch(void *pcm_pointer, int32_t *status); float getCompressorCurrent(void *pcm_pointer, int32_t *status); + + bool getCompressorCurrentTooHighFault(void *pcm_pointer, int32_t *status); + bool getCompressorCurrentTooHighStickyFault(void *pcm_pointer, int32_t *status); + bool getCompressorShortedStickyFault(void *pcm_pointer, int32_t *status); + bool getCompressorShortedFault(void *pcm_pointer, int32_t *status); + bool getCompressorNotConnectedStickyFault(void *pcm_pointer, int32_t *status); + bool getCompressorNotConnectedFault(void *pcm_pointer, int32_t *status); + void clearAllPCMStickyFaults(void *pcm_pointer, int32_t *status); } #endif diff --git a/hal/include/HAL/Solenoid.hpp b/hal/include/HAL/Solenoid.hpp index 90cde27aad..06114e36b8 100644 --- a/hal/include/HAL/Solenoid.hpp +++ b/hal/include/HAL/Solenoid.hpp @@ -13,4 +13,9 @@ extern "C" bool getSolenoid(void* solenoid_port_pointer, int32_t *status); void setSolenoid(void* solenoid_port_pointer, bool value, int32_t *status); + + int getPCMSolenoidBlackList(void* solenoid_port_pointer, int32_t *status); + bool getPCMSolenoidVoltageStickyFault(void* solenoid_port_pointer, int32_t *status); + bool getPCMSolenoidVoltageFault(void* solenoid_port_pointer, int32_t *status); + void clearAllPCMStickyFaults_sol(void *solenoid_port_pointer, int32_t *status); } diff --git a/hal/lib/Athena/Compressor.cpp b/hal/lib/Athena/Compressor.cpp index d9ecf7ac86..9305097886 100644 --- a/hal/lib/Athena/Compressor.cpp +++ b/hal/lib/Athena/Compressor.cpp @@ -61,4 +61,56 @@ float getCompressorCurrent(void *pcm_pointer, int32_t *status) { return value; } - +bool getCompressorCurrentTooHighFault(void *pcm_pointer, int32_t *status) { + PCM *module = (PCM *)pcm_pointer; + bool value; + + *status = module->GetCompressorCurrentTooHighFault(value); + + return value; +} +bool getCompressorCurrentTooHighStickyFault(void *pcm_pointer, int32_t *status) { + PCM *module = (PCM *)pcm_pointer; + bool value; + + *status = module->GetCompressorCurrentTooHighStickyFault(value); + + return value; +} +bool getCompressorShortedStickyFault(void *pcm_pointer, int32_t *status) { + PCM *module = (PCM *)pcm_pointer; + bool value; + + *status = module->GetCompressorShortedStickyFault(value); + + return value; +} +bool getCompressorShortedFault(void *pcm_pointer, int32_t *status) { + PCM *module = (PCM *)pcm_pointer; + bool value; + + *status = module->GetCompressorShortedFault(value); + + return value; +} +bool getCompressorNotConnectedStickyFault(void *pcm_pointer, int32_t *status) { + PCM *module = (PCM *)pcm_pointer; + bool value; + + *status = module->GetCompressorNotConnectedStickyFault(value); + + return value; +} +bool getCompressorNotConnectedFault(void *pcm_pointer, int32_t *status) { + PCM *module = (PCM *)pcm_pointer; + bool value; + + *status = module->GetCompressorNotConnectedFault(value); + + return value; +} +void clearAllPCMStickyFaults(void *pcm_pointer, int32_t *status) { + PCM *module = (PCM *)pcm_pointer; + + *status = module->ClearStickyFaults(); +} diff --git a/hal/lib/Athena/Solenoid.cpp b/hal/lib/Athena/Solenoid.cpp index 0ae2f57ba1..c545106bb7 100644 --- a/hal/lib/Athena/Solenoid.cpp +++ b/hal/lib/Athena/Solenoid.cpp @@ -52,3 +52,33 @@ void setSolenoid(void* solenoid_port_pointer, bool value, int32_t *status) { port->module->SetSolenoid(port->pin, value); } + +int getPCMSolenoidBlackList(void* solenoid_port_pointer, int32_t *status){ + solenoid_port_t* port = (solenoid_port_t*) solenoid_port_pointer; + UINT8 value; + + *status = port->module->GetSolenoidBlackList(value); + + return value; +} +bool getPCMSolenoidVoltageStickyFault(void* solenoid_port_pointer, int32_t *status){ + solenoid_port_t* port = (solenoid_port_t*) solenoid_port_pointer; + bool value; + + *status = port->module->GetSolenoidStickyFault(value); + + return value; +} +bool getPCMSolenoidVoltageFault(void* solenoid_port_pointer, int32_t *status){ + solenoid_port_t* port = (solenoid_port_t*) solenoid_port_pointer; + bool value; + + *status = port->module->GetSolenoidFault(value); + + return value; +} +void clearAllPCMStickyFaults_sol(void *solenoid_port_pointer, int32_t *status){ + solenoid_port_t* port = (solenoid_port_t*) solenoid_port_pointer; + + *status = port->module->ClearStickyFaults(); +} diff --git a/wpilibc/wpilibC++Devices/include/Compressor.h b/wpilibc/wpilibC++Devices/include/Compressor.h index 6e6cc7e3e7..73478b1c9f 100644 --- a/wpilibc/wpilibC++Devices/include/Compressor.h +++ b/wpilibc/wpilibC++Devices/include/Compressor.h @@ -32,6 +32,14 @@ public: void SetClosedLoopControl(bool on); bool GetClosedLoopControl(); + bool GetCompressorCurrentTooHighFault(); + bool GetCompressorCurrentTooHighStickyFault(); + bool GetCompressorShortedStickyFault(); + bool GetCompressorShortedFault(); + bool GetCompressorNotConnectedStickyFault(); + bool GetCompressorNotConnectedFault(); + void ClearAllPCMStickyFaults(); + void UpdateTable(); void StartLiveWindowMode(); void StopLiveWindowMode(); diff --git a/wpilibc/wpilibC++Devices/include/DoubleSolenoid.h b/wpilibc/wpilibC++Devices/include/DoubleSolenoid.h index ebda229240..b8749911a6 100644 --- a/wpilibc/wpilibC++Devices/include/DoubleSolenoid.h +++ b/wpilibc/wpilibC++Devices/include/DoubleSolenoid.h @@ -31,6 +31,8 @@ public: virtual ~DoubleSolenoid(); virtual void Set(Value value); virtual Value Get(); + bool IsFwdSolenoidBlackListed(); + bool IsRevSolenoidBlackListed(); void ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew); void UpdateTable(); diff --git a/wpilibc/wpilibC++Devices/include/Solenoid.h b/wpilibc/wpilibC++Devices/include/Solenoid.h index e141c32df4..374fc459b5 100644 --- a/wpilibc/wpilibC++Devices/include/Solenoid.h +++ b/wpilibc/wpilibC++Devices/include/Solenoid.h @@ -23,6 +23,7 @@ public: virtual ~Solenoid(); virtual void Set(bool on); virtual bool Get(); + bool IsBlackListed(); void ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew); void UpdateTable(); diff --git a/wpilibc/wpilibC++Devices/include/SolenoidBase.h b/wpilibc/wpilibC++Devices/include/SolenoidBase.h index 78bb67d37f..d70823f0b3 100644 --- a/wpilibc/wpilibC++Devices/include/SolenoidBase.h +++ b/wpilibc/wpilibC++Devices/include/SolenoidBase.h @@ -20,6 +20,10 @@ public: virtual ~SolenoidBase(); uint8_t GetAll(); + uint8_t GetPCMSolenoidBlackList(); + bool GetPCMSolenoidVoltageStickyFault(); + bool GetPCMSolenoidVoltageFault(); + void ClearAllPCMStickyFaults(); protected: explicit SolenoidBase(uint8_t pcmID); void Set(uint8_t value, uint8_t mask); diff --git a/wpilibc/wpilibC++Devices/src/Compressor.cpp b/wpilibc/wpilibC++Devices/src/Compressor.cpp index 2717120eb7..3a7a09212a 100644 --- a/wpilibc/wpilibC++Devices/src/Compressor.cpp +++ b/wpilibc/wpilibC++Devices/src/Compressor.cpp @@ -129,6 +129,123 @@ bool Compressor::GetClosedLoopControl() { return value; } +/** + * @return true if PCM is in fault state : Compressor Drive is + * disabled due to compressor current being too high. + */ +bool Compressor::GetCompressorCurrentTooHighFault() { + int32_t status = 0; + bool value; + + value = getCompressorCurrentTooHighFault(m_pcm_pointer, &status); + + if(status) { + wpi_setWPIError(Timeout); + } + + return value; +} +/** + * @return true if PCM sticky fault is set : Compressor Drive is + * disabled due to compressor current being too high. + */ +bool Compressor::GetCompressorCurrentTooHighStickyFault() { + int32_t status = 0; + bool value; + + value = getCompressorCurrentTooHighStickyFault(m_pcm_pointer, &status); + + if(status) { + wpi_setWPIError(Timeout); + } + + return value; +} +/** + * @return true if PCM sticky fault is set : Compressor output + * appears to be shorted. + */ +bool Compressor::GetCompressorShortedStickyFault() { + int32_t status = 0; + bool value; + + value = getCompressorShortedStickyFault(m_pcm_pointer, &status); + + if(status) { + wpi_setWPIError(Timeout); + } + + return value; +} +/** + * @return true if PCM is in fault state : Compressor output + * appears to be shorted. + */ +bool Compressor::GetCompressorShortedFault() { + int32_t status = 0; + bool value; + + value = getCompressorShortedFault(m_pcm_pointer, &status); + + if(status) { + wpi_setWPIError(Timeout); + } + + return value; +} +/** + * @return true if PCM sticky fault is set : Compressor does not + * appear to be wired, i.e. compressor is + * not drawing enough current. + */ +bool Compressor::GetCompressorNotConnectedStickyFault() { + int32_t status = 0; + bool value; + + value = getCompressorNotConnectedStickyFault(m_pcm_pointer, &status); + + if(status) { + wpi_setWPIError(Timeout); + } + + return value; +} +/** + * @return true if PCM is in fault state : Compressor does not + * appear to be wired, i.e. compressor is + * not drawing enough current. + */ +bool Compressor::GetCompressorNotConnectedFault() { + int32_t status = 0; + bool value; + + value = getCompressorNotConnectedFault(m_pcm_pointer, &status); + + if(status) { + wpi_setWPIError(Timeout); + } + + return value; +} +/** + * Clear ALL sticky faults inside PCM that Compressor is wired to. + * + * If a sticky fault is set, then it will be persistently cleared. Compressor drive + * maybe momentarily disable while flags are being cleared. Care should be + * taken to not call this too frequently, otherwise normal compressor + * functionality may be prevented. + * + * If no sticky faults are set then this call will have no effect. + */ +void Compressor::ClearAllPCMStickyFaults() { + int32_t status = 0; + + clearAllPCMStickyFaults(m_pcm_pointer, &status); + + if(status) { + wpi_setWPIError(Timeout); + } +} void Compressor::UpdateTable() { if(m_table) { m_table->PutBoolean("Enabled", Enabled()); diff --git a/wpilibc/wpilibC++Devices/src/DoubleSolenoid.cpp b/wpilibc/wpilibC++Devices/src/DoubleSolenoid.cpp index e2587e305d..b69c32c598 100644 --- a/wpilibc/wpilibC++Devices/src/DoubleSolenoid.cpp +++ b/wpilibc/wpilibC++Devices/src/DoubleSolenoid.cpp @@ -138,6 +138,32 @@ DoubleSolenoid::Value DoubleSolenoid::Get() if (value & m_reverseMask) return kReverse; return kOff; } +/** + * Check if the forward solenoid is blacklisted. + * If a solenoid is shorted, it is added to the blacklist and + * disabled until power cycle, or until faults are cleared. + * @see ClearAllPCMStickyFaults() + * + * @return If solenoid is disabled due to short. + */ +bool DoubleSolenoid::IsFwdSolenoidBlackListed() +{ + int blackList = GetPCMSolenoidBlackList(); + return (blackList & m_forwardMask) ? 1 : 0; +} +/** + * Check if the reverse solenoid is blacklisted. + * If a solenoid is shorted, it is added to the blacklist and + * disabled until power cycle, or until faults are cleared. + * @see ClearAllPCMStickyFaults() + * + * @return If solenoid is disabled due to short. + */ +bool DoubleSolenoid::IsRevSolenoidBlackListed() +{ + int blackList = GetPCMSolenoidBlackList(); + return (blackList & m_reverseMask) ? 1 : 0; +} void DoubleSolenoid::ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew) { Value lvalue = kOff; diff --git a/wpilibc/wpilibC++Devices/src/Solenoid.cpp b/wpilibc/wpilibC++Devices/src/Solenoid.cpp index d7003927f8..377d85b19d 100644 --- a/wpilibc/wpilibC++Devices/src/Solenoid.cpp +++ b/wpilibc/wpilibC++Devices/src/Solenoid.cpp @@ -102,7 +102,19 @@ bool Solenoid::Get() uint8_t value = GetAll() & ( 1 << m_channel); return (value != 0); } - +/** + * Check if solenoid is blacklisted. + * If a solenoid is shorted, it is added to the blacklist and + * disabled until power cycle, or until faults are cleared. + * @see ClearAllPCMStickyFaults() + * + * @return If solenoid is disabled due to short. + */ +bool Solenoid::IsBlackListed() +{ + int value = GetPCMSolenoidBlackList() & ( 1 << m_channel); + return (value != 0); +} void Solenoid::ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew) { Set(value.b); diff --git a/wpilibc/wpilibC++Devices/src/SolenoidBase.cpp b/wpilibc/wpilibC++Devices/src/SolenoidBase.cpp index 08dd650d33..eacacef5c6 100644 --- a/wpilibc/wpilibC++Devices/src/SolenoidBase.cpp +++ b/wpilibc/wpilibC++Devices/src/SolenoidBase.cpp @@ -64,3 +64,52 @@ uint8_t SolenoidBase::GetAll() } return value; } +/** + * Reads complete solenoid blacklist for all 8 solenoids as a single byte. + * + * If a solenoid is shorted, it is added to the blacklist and + * disabled until power cycle, or until faults are cleared. + * @see ClearAllPCMStickyFaults() + * + * @return The solenoid blacklist of all 8 solenoids on the module. + */ +uint8_t SolenoidBase::GetPCMSolenoidBlackList() +{ + int32_t status = 0; + return getPCMSolenoidBlackList(m_ports[0], &status); +} +/** + * @return true if PCM sticky fault is set : The common + * highside solenoid voltage rail is too low, + * most likely a solenoid channel is shorted. + */ +bool SolenoidBase::GetPCMSolenoidVoltageStickyFault() +{ + int32_t status = 0; + return getPCMSolenoidVoltageStickyFault(m_ports[0], &status); +} +/** + * @return true if PCM is in fault state : The common + * highside solenoid voltage rail is too low, + * most likely a solenoid channel is shorted. + */ +bool SolenoidBase::GetPCMSolenoidVoltageFault() +{ + int32_t status = 0; + return getPCMSolenoidVoltageFault(m_ports[0], &status); +} +/** + * Clear ALL sticky faults inside PCM that Compressor is wired to. + * + * If a sticky fault is set, then it will be persistently cleared. Compressor drive + * maybe momentarily disable while flags are being cleared. Care should be + * taken to not call this too frequently, otherwise normal compressor + * functionality may be prevented. + * + * If no sticky faults are set then this call will have no effect. + */ +void SolenoidBase::ClearAllPCMStickyFaults() +{ + int32_t status = 0; + return clearAllPCMStickyFaults_sol(m_ports[0], &status); +} diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Compressor.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Compressor.java index a240ec9c27..6b3342ea4e 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Compressor.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Compressor.java @@ -139,6 +139,103 @@ public class Compressor extends SensorBase implements LiveWindowSendable { return on; } + /** + * @return true if PCM is in fault state : Compressor Drive is + * disabled due to compressor current being too high. + */ + public boolean getCompressorCurrentTooHighFault() { + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + + boolean retval = CompressorJNI.getCompressorCurrentTooHighFault(m_pcm, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); + + return retval; + } + /** + * @return true if PCM sticky fault is set : Compressor Drive is + * disabled due to compressor current being too high. + */ + public boolean getCompressorCurrentTooHighStickyFault() { + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + + boolean retval = CompressorJNI.getCompressorCurrentTooHighStickyFault(m_pcm, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); + + return retval; + } + /** + * @return true if PCM sticky fault is set : Compressor output + * appears to be shorted. + */ + public boolean getCompressorShortedStickyFault() { + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + + boolean retval = CompressorJNI.getCompressorShortedStickyFault(m_pcm, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); + + return retval; + } + /** + * @return true if PCM is in fault state : Compressor output + * appears to be shorted. + */ + public boolean getCompressorShortedFault() { + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + + boolean retval = CompressorJNI.getCompressorShortedFault(m_pcm, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); + + return retval; + } + /** + * @return true if PCM sticky fault is set : Compressor does not + * appear to be wired, i.e. compressor is + * not drawing enough current. + */ + public boolean getCompressorNotConnectedStickyFault() { + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + + boolean retval = CompressorJNI.getCompressorNotConnectedStickyFault(m_pcm, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); + + return retval; + } + /** + * @return true if PCM is in fault state : Compressor does not + * appear to be wired, i.e. compressor is + * not drawing enough current. + */ + public boolean getCompressorNotConnectedFault() { + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + + boolean retval = CompressorJNI.getCompressorNotConnectedFault(m_pcm, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); + + return retval; + } + /** + * Clear ALL sticky faults inside PCM that Compressor is wired to. + * + * If a sticky fault is set, then it will be persistently cleared. Compressor drive + * maybe momentarily disable while flags are being cleared. Care should be + * taken to not call this too frequently, otherwise normal compressor + * functionality may be prevented. + * + * If no sticky faults are set then this call will have no effect. + */ + public void clearAllPCMStickyFaults() { + ByteBuffer status = ByteBuffer.allocateDirect(4); + status.order(ByteOrder.LITTLE_ENDIAN); + + CompressorJNI.clearAllPCMStickyFaults(m_pcm, status.asIntBuffer()); + HALUtil.checkStatus(status.asIntBuffer()); + } @Override public void startLiveWindowMode() { } diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java index 330fd18992..fdfaefda6b 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/DoubleSolenoid.java @@ -143,6 +143,30 @@ public class DoubleSolenoid extends SolenoidBase implements LiveWindowSendable { if ((value & m_reverseMask) != 0) return Value.kReverse; return Value.kOff; } + /** + * Check if the forward solenoid is blacklisted. + * If a solenoid is shorted, it is added to the blacklist and + * disabled until power cycle, or until faults are cleared. + * @see clearAllPCMStickyFaults() + * + * @return If solenoid is disabled due to short. + */ + public boolean isFwdSolenoidBlackListed() { + int blackList = getPCMSolenoidBlackList(); + return ((blackList & m_forwardMask) != 0); + } + /** + * Check if the reverse solenoid is blacklisted. + * If a solenoid is shorted, it is added to the blacklist and + * disabled until power cycle, or until faults are cleared. + * @see clearAllPCMStickyFaults() + * + * @return If solenoid is disabled due to short. + */ + public boolean isRevSolenoidBlackListed() { + int blackList = getPCMSolenoidBlackList(); + return ((blackList & m_reverseMask) != 0); + } /* * Live Window code, only does anything if live window is activated. diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Solenoid.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Solenoid.java index ddd6199d56..4f19cd330a 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Solenoid.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/Solenoid.java @@ -101,7 +101,18 @@ public class Solenoid extends SolenoidBase implements LiveWindowSendable { int value = getAll() & ( 1 << m_channel); return (value != 0); } - + /** + * Check if solenoid is blacklisted. + * If a solenoid is shorted, it is added to the blacklist and + * disabled until power cycle, or until faults are cleared. + * @see clearAllPCMStickyFaults() + * + * @return If solenoid is disabled due to short. + */ + public boolean isBlackListed() { + int value = getPCMSolenoidBlackList() & ( 1 << m_channel); + return (value != 0); + } /* * Live Window code, only does anything if live window is activated. */ diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/SolenoidBase.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/SolenoidBase.java index 177b0ae2f6..be499c3610 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/SolenoidBase.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/SolenoidBase.java @@ -69,4 +69,63 @@ public abstract class SolenoidBase extends SensorBase { HALUtil.checkStatus(status); return value; } + /** + * Reads complete solenoid blacklist for all 8 solenoids as a single byte. + * + * If a solenoid is shorted, it is added to the blacklist and + * disabled until power cycle, or until faults are cleared. + * @see clearAllPCMStickyFaults() + * + * @return The solenoid blacklist of all 8 solenoids on the module. + */ + public byte getPCMSolenoidBlackList() { + IntBuffer status = ByteBuffer.allocateDirect(4).asIntBuffer(); + + byte retval = SolenoidJNI.getPCMSolenoidBlackList(m_ports[0], status); + HALUtil.checkStatus(status); + + return retval; + } + /** + * @return true if PCM sticky fault is set : The common + * highside solenoid voltage rail is too low, + * most likely a solenoid channel is shorted. + */ + public boolean getPCMSolenoidVoltageStickyFault() { + IntBuffer status = ByteBuffer.allocateDirect(4).asIntBuffer(); + + boolean retval = SolenoidJNI.getPCMSolenoidVoltageStickyFault(m_ports[0], status); + HALUtil.checkStatus(status); + + return retval; + } + /** + * @return true if PCM is in fault state : The common + * highside solenoid voltage rail is too low, + * most likely a solenoid channel is shorted. + */ + public boolean getPCMSolenoidVoltageFault() { + IntBuffer status = ByteBuffer.allocateDirect(4).asIntBuffer(); + + boolean retval = SolenoidJNI.getPCMSolenoidVoltageFault(m_ports[0], status); + HALUtil.checkStatus(status); + + return retval; + } + /** + * Clear ALL sticky faults inside PCM that Compressor is wired to. + * + * If a sticky fault is set, then it will be persistently cleared. Compressor drive + * maybe momentarily disable while flags are being cleared. Care should be + * taken to not call this too frequently, otherwise normal compressor + * functionality may be prevented. + * + * If no sticky faults are set then this call will have no effect. + */ + public void clearAllPCMStickyFaults() { + IntBuffer status = ByteBuffer.allocateDirect(4).asIntBuffer(); + + SolenoidJNI.clearAllPCMStickyFaults(m_ports[0], status); + HALUtil.checkStatus(status); + } } diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/hal/CompressorJNI.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/hal/CompressorJNI.java index 7dc65f1ab1..2838ca3baf 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/hal/CompressorJNI.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/hal/CompressorJNI.java @@ -14,4 +14,12 @@ public class CompressorJNI extends JNIWrapper { public static native boolean getPressureSwitch(ByteBuffer pcm_pointer, IntBuffer status); public static native float getCompressorCurrent(ByteBuffer pcm_pointer, IntBuffer status); + + public static native boolean getCompressorCurrentTooHighFault(ByteBuffer pcm_pointer, IntBuffer status); + public static native boolean getCompressorCurrentTooHighStickyFault(ByteBuffer pcm_pointer, IntBuffer status); + public static native boolean getCompressorShortedStickyFault(ByteBuffer pcm_pointer, IntBuffer status); + public static native boolean getCompressorShortedFault(ByteBuffer pcm_pointer, IntBuffer status); + public static native boolean getCompressorNotConnectedStickyFault(ByteBuffer pcm_pointer, IntBuffer status); + public static native boolean getCompressorNotConnectedFault(ByteBuffer pcm_pointer, IntBuffer status); + public static native void clearAllPCMStickyFaults(ByteBuffer pcm_pointer, IntBuffer status); } diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/hal/SolenoidJNI.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/hal/SolenoidJNI.java index d45fff3154..15b1f1db62 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/hal/SolenoidJNI.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/hal/SolenoidJNI.java @@ -7,4 +7,9 @@ public class SolenoidJNI extends JNIWrapper { public static native ByteBuffer getPortWithModule(byte module, byte channel); public static native void setSolenoid(ByteBuffer port, byte on, IntBuffer status); public static native byte getSolenoid(ByteBuffer port, IntBuffer status); + + public static native byte getPCMSolenoidBlackList(ByteBuffer pcm_pointer, IntBuffer status); + public static native boolean getPCMSolenoidVoltageStickyFault(ByteBuffer pcm_pointer, IntBuffer status); + public static native boolean getPCMSolenoidVoltageFault(ByteBuffer pcm_pointer, IntBuffer status); + public static native void clearAllPCMStickyFaults(ByteBuffer pcm_pointer, IntBuffer status); } diff --git a/wpilibj/wpilibJavaJNI/lib/CompressorJNI.cpp b/wpilibj/wpilibJavaJNI/lib/CompressorJNI.cpp index a04cf01384..c670cabe27 100644 --- a/wpilibj/wpilibJavaJNI/lib/CompressorJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/CompressorJNI.cpp @@ -100,3 +100,99 @@ JNIEXPORT jfloat JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompres return getCompressorCurrent(*pcm_pointer, status_pointer); } +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: getCompressorCurrentTooHighFault + * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Z + */ +JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrentTooHighFault + (JNIEnv *env, jclass, jobject pcm_pointer_object, jobject status) +{ + VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); + jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + + return getCompressorCurrentTooHighFault(*pcm_pointer, status_pointer); +} + +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: getCompressorCurrentTooHighStickyFault + * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Z + */ +JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorCurrentTooHighStickyFault + (JNIEnv *env, jclass, jobject pcm_pointer_object, jobject status) +{ + VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); + jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + + return getCompressorCurrentTooHighStickyFault(*pcm_pointer, status_pointer); +} + +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: getCompressorShortedStickyFault + * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Z + */ +JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorShortedStickyFault + (JNIEnv *env, jclass, jobject pcm_pointer_object, jobject status) +{ + VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); + jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + + return getCompressorShortedStickyFault(*pcm_pointer, status_pointer); +} + +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: getCompressorShortedFault + * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Z + */ +JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorShortedFault + (JNIEnv *env, jclass, jobject pcm_pointer_object, jobject status) +{ + VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); + jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + + return getCompressorShortedFault(*pcm_pointer, status_pointer); +} + +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: getCompressorNotConnectedStickyFault + * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Z + */ +JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorNotConnectedStickyFault + (JNIEnv *env, jclass, jobject pcm_pointer_object, jobject status) +{ + VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); + jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + + return getCompressorNotConnectedStickyFault(*pcm_pointer, status_pointer); +} + +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: getCompressorNotConnectedFault + * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Z + */ +JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_getCompressorNotConnectedFault + (JNIEnv *env, jclass, jobject pcm_pointer_object, jobject status) +{ + VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); + jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + + return getCompressorNotConnectedFault(*pcm_pointer, status_pointer); +} +/* + * Class: edu_wpi_first_wpilibj_hal_CompressorJNI + * Method: clearAllPCMStickyFaults + * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V + */ +JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_CompressorJNI_clearAllPCMStickyFaults + (JNIEnv *env, jclass, jobject pcm_pointer_object, jobject status) +{ + VoidPointer *pcm_pointer = (VoidPointer *)env->GetDirectBufferAddress(pcm_pointer_object); + jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + + clearAllPCMStickyFaults(*pcm_pointer, status_pointer); +} diff --git a/wpilibj/wpilibJavaJNI/lib/SolenoidJNI.cpp b/wpilibj/wpilibJavaJNI/lib/SolenoidJNI.cpp index 1b16cd8a3a..8712dbc0b5 100644 --- a/wpilibj/wpilibJavaJNI/lib/SolenoidJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/SolenoidJNI.cpp @@ -89,3 +89,57 @@ JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getSolenoid return getSolenoid(*solenoid_port_pointer, status_pointer); } + +/* + * Class: edu_wpi_first_wpilibj_hal_SolenoidJNI + * Method: getPCMSolenoidBlackList + * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)B + */ +JNIEXPORT jbyte JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidBlackList + (JNIEnv *env, jclass, jobject solenoid_port, jobject status) +{ + + VoidPointer *solenoid_port_pointer = (VoidPointer *)env->GetDirectBufferAddress(solenoid_port); + jint *status_pointer = (jint*)env->GetDirectBufferAddress(status); + + return getPCMSolenoidBlackList(*solenoid_port_pointer, status_pointer); +} +/* + * Class: edu_wpi_first_wpilibj_hal_SolenoidJNI + * Method: getPCMSolenoidVoltageStickyFault + * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Z + */ +JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidVoltageStickyFault + (JNIEnv *env, jclass, jobject solenoid_port, jobject status) +{ + VoidPointer *solenoid_port_pointer = (VoidPointer *)env->GetDirectBufferAddress(solenoid_port); + jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + + return getPCMSolenoidVoltageStickyFault(*solenoid_port_pointer, status_pointer); +} +/* + * Class: edu_wpi_first_wpilibj_hal_SolenoidJNI + * Method: getPCMSolenoidVoltageFault + * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)Z + */ +JNIEXPORT jboolean JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_getPCMSolenoidVoltageFault + (JNIEnv *env, jclass, jobject solenoid_port, jobject status) +{ + VoidPointer *solenoid_port_pointer = (VoidPointer *)env->GetDirectBufferAddress(solenoid_port); + jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + + return getPCMSolenoidVoltageFault(*solenoid_port_pointer, status_pointer); +} +/* + * Class: edu_wpi_first_wpilibj_hal_SolenoidJNI + * Method: clearAllPCMStickyFaults + * Signature: (Ljava/nio/ByteBuffer;Ljava/nio/IntBuffer;)V + */ +JNIEXPORT void JNICALL Java_edu_wpi_first_wpilibj_hal_SolenoidJNI_clearAllPCMStickyFaults + (JNIEnv *env, jclass, jobject solenoid_port, jobject status) +{ + VoidPointer *solenoid_port_pointer = (VoidPointer *)env->GetDirectBufferAddress(solenoid_port); + jint *status_pointer = (jint *)env->GetDirectBufferAddress(status); + + clearAllPCMStickyFaults_sol(*solenoid_port_pointer, status_pointer); +}