From a649d3b553a4143981d4658aa8674e4c5f8a9d0e Mon Sep 17 00:00:00 2001 From: Joe Ross Date: Sun, 14 Dec 2014 14:24:15 -0800 Subject: [PATCH] Fix ControllerPower 5v faults and add javadocs. Fixes artf3918. 5V faults was returning count of 3.3V faults. Copied javadocs from C++. Change-Id: I95b5c6ed1213ed235ecde11ef7e28ad05aabca6e --- .../wpi/first/wpilibj/ControllerPower.java | 63 ++++++++++++++++++- wpilibj/wpilibJavaJNI/lib/PowerJNI.cpp | 2 +- 2 files changed, 62 insertions(+), 3 deletions(-) diff --git a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/ControllerPower.java b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/ControllerPower.java index ef826edf1b..771061c14a 100644 --- a/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/ControllerPower.java +++ b/wpilibj/wpilibJavaDevices/src/main/java/edu/wpi/first/wpilibj/ControllerPower.java @@ -16,6 +16,10 @@ import edu.wpi.first.wpilibj.hal.PowerJNI; public class ControllerPower { + /** + * Get the input voltage to the robot controller + * @return The controller input voltage value + */ public static double getInputVoltage() { ByteBuffer status = ByteBuffer.allocateDirect(4); @@ -24,7 +28,11 @@ public class ControllerPower HALUtil.checkStatus(status.asIntBuffer()); return retVal; } - + + /** + * Get the input current to the robot controller + * @return The controller input current value + */ public static double getInputCurrent() { ByteBuffer status = ByteBuffer.allocateDirect(4); @@ -34,6 +42,10 @@ public class ControllerPower return retVal; } + /** + * Get the voltage of the 3.3V rail + * @return The controller 3.3V rail voltage value + */ public static double getVoltage3V3() { ByteBuffer status = ByteBuffer.allocateDirect(4); @@ -43,6 +55,10 @@ public class ControllerPower return retVal; } + /** + * Get the current output of the 3.3V rail + * @return The controller 3.3V rail output current value + */ public static double getCurrent3V3() { ByteBuffer status = ByteBuffer.allocateDirect(4); @@ -52,6 +68,11 @@ public class ControllerPower return retVal; } + /** + * Get the enabled state of the 3.3V rail. The rail may be disabled due to a controller + * brownout, a short circuit on the rail, or controller over-voltage + * @return The controller 3.3V rail enabled value + */ public static boolean getEnabled3V3() { ByteBuffer status = ByteBuffer.allocateDirect(4); @@ -61,6 +82,10 @@ public class ControllerPower return retVal; } + /** + * Get the count of the total current faults on the 3.3V rail since the controller has booted + * @return The number of faults + */ public static int getFaultCount3V3() { ByteBuffer status = ByteBuffer.allocateDirect(4); @@ -70,6 +95,10 @@ public class ControllerPower return retVal; } + /** + * Get the voltage of the 5V rail + * @return The controller 5V rail voltage value + */ public static double getVoltage5V() { ByteBuffer status = ByteBuffer.allocateDirect(4); @@ -79,6 +108,10 @@ public class ControllerPower return retVal; } + /** + * Get the current output of the 5V rail + * @return The controller 5V rail output current value + */ public static double getCurrent5V() { ByteBuffer status = ByteBuffer.allocateDirect(4); @@ -88,6 +121,11 @@ public class ControllerPower return retVal; } + /** + * Get the enabled state of the 5V rail. The rail may be disabled due to a controller + * brownout, a short circuit on the rail, or controller over-voltage + * @return The controller 5V rail enabled value + */ public static boolean getEnabled5V() { ByteBuffer status = ByteBuffer.allocateDirect(4); @@ -97,6 +135,10 @@ public class ControllerPower return retVal; } + /** + * Get the count of the total current faults on the 5V rail since the controller has booted + * @return The number of faults + */ public static int getFaultCount5V() { ByteBuffer status = ByteBuffer.allocateDirect(4); @@ -106,6 +148,10 @@ public class ControllerPower return retVal; } + /** + * Get the voltage of the 6V rail + * @return The controller 6V rail voltage value + */ public static double getVoltage6V() { ByteBuffer status = ByteBuffer.allocateDirect(4); @@ -115,6 +161,10 @@ public class ControllerPower return retVal; } + /** + * Get the current output of the 6V rail + * @return The controller 6V rail output current value + */ public static double getCurrent6V() { ByteBuffer status = ByteBuffer.allocateDirect(4); @@ -124,6 +174,11 @@ public class ControllerPower return retVal; } + /** + * Get the enabled state of the 6V rail. The rail may be disabled due to a controller + * brownout, a short circuit on the rail, or controller over-voltage + * @return The controller 6V rail enabled value + */ public static boolean getEnabled6V() { ByteBuffer status = ByteBuffer.allocateDirect(4); @@ -132,7 +187,11 @@ public class ControllerPower HALUtil.checkStatus(status.asIntBuffer()); return retVal; } - + + /** + * Get the count of the total current faults on the 6V rail since the controller has booted + * @return The number of faults + */ public static int getFaultCount6V() { ByteBuffer status = ByteBuffer.allocateDirect(4); diff --git a/wpilibj/wpilibJavaJNI/lib/PowerJNI.cpp b/wpilibj/wpilibJavaJNI/lib/PowerJNI.cpp index 4a247aee45..dedf6c92fb 100644 --- a/wpilibj/wpilibJavaJNI/lib/PowerJNI.cpp +++ b/wpilibj/wpilibJavaJNI/lib/PowerJNI.cpp @@ -119,7 +119,7 @@ JNIEXPORT jint JNICALL Java_edu_wpi_first_wpilibj_hal_PowerJNI_getUserCurrentFau (JNIEnv * env, jclass, jobject status) { jint * statusPtr = (jint*)env->GetDirectBufferAddress(status); - return getUserCurrentFaults3V3(statusPtr); + return getUserCurrentFaults5V(statusPtr); } /*