diff --git a/hal/src/main/java/edu/wpi/first/hal/HAL.java b/hal/src/main/java/edu/wpi/first/hal/HAL.java index 68e6ec8493..2420214913 100644 --- a/hal/src/main/java/edu/wpi/first/hal/HAL.java +++ b/hal/src/main/java/edu/wpi/first/hal/HAL.java @@ -117,6 +117,8 @@ public final class HAL extends JNIWrapper { public static native boolean getSystemActive(); + public static native boolean getRSLState(); + public static native int getPortWithModule(byte module, byte channel); public static native int getPort(byte channel); diff --git a/hal/src/main/native/athena/HAL.cpp b/hal/src/main/native/athena/HAL.cpp index 1b6ef41598..8d3075e026 100644 --- a/hal/src/main/native/athena/HAL.cpp +++ b/hal/src/main/native/athena/HAL.cpp @@ -423,6 +423,15 @@ HAL_Bool HAL_GetBrownedOut(int32_t* status) { return !(watchdog->readStatus_PowerAlive(status)); } +HAL_Bool HAL_GetRSLState(int32_t* status) { + hal::init::CheckInit(); + if (!global) { + *status = NiFpga_Status_ResourceNotInitialized; + return false; + } + return global->readLEDs_RSL(status); +} + static bool killExistingProgram(int timeout, int mode) { // Kill any previous robot programs std::fstream fs; diff --git a/hal/src/main/native/cpp/jni/HAL.cpp b/hal/src/main/native/cpp/jni/HAL.cpp index b603a76cb3..63cb7fa354 100644 --- a/hal/src/main/native/cpp/jni/HAL.cpp +++ b/hal/src/main/native/cpp/jni/HAL.cpp @@ -136,6 +136,21 @@ Java_edu_wpi_first_hal_HAL_getBrownedOut return val; } +/* + * Class: edu_wpi_first_hal_HAL + * Method: getRSLState + * Signature: ()Z + */ +JNIEXPORT jboolean JNICALL +Java_edu_wpi_first_hal_HAL_getRSLState + (JNIEnv* env, jclass) +{ + int32_t status = 0; + bool val = HAL_GetRSLState(&status); + CheckStatus(env, status); + return val; +} + /* * Class: edu_wpi_first_hal_HAL * Method: getPortWithModule diff --git a/hal/src/main/native/include/hal/HALBase.h b/hal/src/main/native/include/hal/HALBase.h index 1fe6b3ab4e..aa32841f59 100644 --- a/hal/src/main/native/include/hal/HALBase.h +++ b/hal/src/main/native/include/hal/HALBase.h @@ -172,6 +172,13 @@ uint64_t HAL_GetFPGATime(int32_t* status); */ uint64_t HAL_ExpandFPGATime(uint32_t unexpandedLower, int32_t* status); +/** + * Gets the current state of the Robot Signal Light (RSL) + * @param[out] status the error code, or 0 for success + * @return The current state of the RSL- true if on, false if off + */ +HAL_Bool HAL_GetRSLState(int32_t* status); + /** * Call this to start up HAL. This is required for robot programs. * diff --git a/hal/src/main/native/sim/HAL.cpp b/hal/src/main/native/sim/HAL.cpp index 82dd8c4ec1..9e1df574c7 100644 --- a/hal/src/main/native/sim/HAL.cpp +++ b/hal/src/main/native/sim/HAL.cpp @@ -328,6 +328,10 @@ HAL_Bool HAL_GetBrownedOut(int32_t* status) { return false; // Figure out if we need to detect a brownout condition } +HAL_Bool HAL_GetRSLState(int32_t* status) { + return false; +} + HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) { static std::atomic_bool initialized{false}; static wpi::mutex initializeMutex; diff --git a/wpilibc/src/main/native/cpp/RobotController.cpp b/wpilibc/src/main/native/cpp/RobotController.cpp index da6e364131..035493f2a5 100644 --- a/wpilibc/src/main/native/cpp/RobotController.cpp +++ b/wpilibc/src/main/native/cpp/RobotController.cpp @@ -76,6 +76,13 @@ bool RobotController::IsBrownedOut() { return retVal; } +bool RobotController::GetRSLState() { + int32_t status = 0; + bool retVal = HAL_GetRSLState(&status); + FRC_CheckErrorStatus(status, "GetRSLState"); + return retVal; +} + double RobotController::GetInputVoltage() { int32_t status = 0; double retVal = HAL_GetVinVoltage(&status); diff --git a/wpilibc/src/main/native/include/frc/RobotController.h b/wpilibc/src/main/native/include/frc/RobotController.h index c020d34653..a4cafd6f6f 100644 --- a/wpilibc/src/main/native/include/frc/RobotController.h +++ b/wpilibc/src/main/native/include/frc/RobotController.h @@ -101,6 +101,12 @@ class RobotController { */ static bool IsBrownedOut(); + /** + * Gets the current state of the Robot Signal Light (RSL) + * @return The current state of the RSL- true if on, false if off + */ + static bool GetRSLState(); + /** * Get the input voltage to the robot controller. * diff --git a/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotController.java b/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotController.java index 8bf9268254..f49308dee3 100644 --- a/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotController.java +++ b/wpilibj/src/main/java/edu/wpi/first/wpilibj/RobotController.java @@ -103,6 +103,15 @@ public final class RobotController { return HAL.getBrownedOut(); } + /** + * Gets the current state of the Robot Signal Light (RSL). + * + * @return The current state of the RSL- true if on, false if off + */ + public static boolean getRSLState() { + return HAL.getRSLState(); + } + /** * Get the input voltage to the robot controller. *