Class HAL
java.lang.Object
org.wpilib.hardware.hal.JNIWrapper
org.wpilib.hardware.hal.HAL
JNI Wrapper for Hardware Abstraction Layer (HAL).
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classA callback to be run by IterativeRobotBase after the user's simulationPeriodic code.static final classA callback to be run by IterativeRobotBase prior to the user's simulationPeriodic code.Nested classes/interfaces inherited from class JNIWrapper
JNIWrapper.Helper -
Method Summary
Modifier and TypeMethodDescriptionstatic voidexitMain()Causes HAL_RunMain() to exit.static booleanGets if the system is in a browned out state.static intGets the number of times the system has been disabled due to communication errors with the Driver Station.static booleanGets the current state of the Robot Signal Light (RSL).static booleanGets if the system outputs are currently active.static booleanGets if the system time is valid.static booleanhasMain()Returns true if HAL_SetMain() has been called.static booleanCall this to start up HAL.static intpublishCanVersion(int busId, int deviceId, String name, String version) Publishes a version for a device on a CAN bus.static intpublishVersion(String name, String version) Publishes a version without a bus or device identifier.static intpublishWpilibVersion(String version) Publishes the WPILib version.static HAL.SimPeriodicAfterCallbackRegisters a callback to be run by IterativeRobotBase after the user's simulationPeriodic code.Registers a callback to be run by IterativeRobotBase prior to the user's simulationPeriodic code.static voidreportUsage(String resource, int instanceNumber, String data) Reports usage of a resource of interest.static voidreportUsage(String resource, String data) Reports usage of a resource of interest.static voidrunMain()Runs the main function provided to HAL_SetMain().static voidshutdown()Call this to shut down HAL.static voidRuns SimPeriodicAfter callbacks.static voidRuns SimPeriodicBefore callbacks.static voidTerminates the executable (at the native level).Methods inherited from class JNIWrapper
forceLoad, suppressUnused
-
Method Details
-
initialize
public static boolean initialize()Call this to start up HAL. This is required for robot programs.This must be called before any other HAL functions. Failure to do so will result in undefined behavior, and likely segmentation faults. This means that any statically initialized variables in a program MUST call this function in their constructors if they want to use other HAL calls.
- Returns:
- true if initialization was successful, otherwise false.
- See Also:
-
shutdown
public static void shutdown()Call this to shut down HAL.This must be called at termination of the robot program to avoid potential segmentation faults with simulation extensions at exit.
- See Also:
-
hasMain
public static boolean hasMain()Returns true if HAL_SetMain() has been called.- Returns:
- True if HAL_SetMain() has been called, false otherwise.
- See Also:
-
runMain
public static void runMain()Runs the main function provided to HAL_SetMain().If HAL_SetMain() has not been called, simply sleeps until exitMain() is called.
- See Also:
-
exitMain
public static void exitMain()Causes HAL_RunMain() to exit.If HAL_SetMain() has been called, this calls the exit function provided to that function.
- See Also:
-
terminate
public static void terminate()Terminates the executable (at the native level). Does nothing in simulation. -
registerSimPeriodicBeforeCallback
Registers a callback to be run by IterativeRobotBase prior to the user's simulationPeriodic code.- Parameters:
r- runnable- Returns:
- Callback object (must be retained for callback to stay active).
-
simPeriodicBefore
public static void simPeriodicBefore()Runs SimPeriodicBefore callbacks. IterativeRobotBase calls this prior to the user's simulationPeriodic code. -
registerSimPeriodicAfterCallback
Registers a callback to be run by IterativeRobotBase after the user's simulationPeriodic code.- Parameters:
r- runnable- Returns:
- Callback object (must be retained for callback to stay active).
-
simPeriodicAfter
public static void simPeriodicAfter()Runs SimPeriodicAfter callbacks. IterativeRobotBase calls this after the user's simulationPeriodic code. -
getBrownedOut
public static boolean getBrownedOut()Gets if the system is in a browned out state.- Returns:
- true if the system is in a low voltage brown out, false otherwise
- See Also:
-
getSystemActive
public static boolean getSystemActive()Gets if the system outputs are currently active.- Returns:
- true if the system outputs are active, false if disabled
- See Also:
-
getRSLState
public static boolean getRSLState()Gets the current state of the Robot Signal Light (RSL).- Returns:
- The current state of the RSL- true if on, false if off
- See Also:
-
getCommsDisableCount
public static int getCommsDisableCount()Gets the number of times the system has been disabled due to communication errors with the Driver Station.- Returns:
- number of disables due to communication errors.
-
getSystemTimeValid
public static boolean getSystemTimeValid()Gets if the system time is valid.- Returns:
- True if the system time is valid, false otherwise
- See Also:
-
reportUsage
-
reportUsage
Reports usage of a resource of interest. Repeated calls for the same resource name replace the previous report.- Parameters:
resource- the used resource nameinstanceNumber- an index that identifies the resource instancedata- arbitrary associated data string
-
publishCanVersion
-
publishVersion
-
publishWpilibVersion
Publishes the WPILib version.- Parameters:
version- WPILib version string- Returns:
- status of the operation
-