Class NotifierJNI


public class NotifierJNI
extends JNIWrapper
The NotifierJNI class directly wraps the C++ HAL Notifier.

This class is not meant for direct use by teams. Instead, the edu.wpi.first.wpilibj.Notifier class, which corresponds to the C++ Notifier class, should be used.

See Also:
  • Method Details

    • initializeNotifier

      public static int initializeNotifier()
      Initializes a notifier.

      A notifier is an FPGA controller timer that triggers at requested intervals based on the FPGA time. This can be used to make precise control loops.

      the created notifier
      See Also:
    • setHALThreadPriority

      public static boolean setHALThreadPriority​(boolean realTime, int priority)
      Sets the HAL notifier thread priority.

      The HAL notifier thread is responsible for managing the FPGA's notifier interrupt and waking up user's Notifiers when it's their time to run. Giving the HAL notifier thread real-time priority helps ensure the user's real-time Notifiers, if any, are notified to run in a timely manner.

      realTime - Set to true to set a real-time priority, false for standard priority.
      priority - Priority to set the thread to. For real-time, this is 1-99 with 99 being highest. For non-real-time, this is forced to 0. See "man 7 sched" for more details.
      True on success.
      See Also:
    • setNotifierName

      public static void setNotifierName​(int notifierHandle, String name)
      Sets the name of the notifier.
      notifierHandle - Notifier handle.
      name - Notifier name.
      See Also:
    • stopNotifier

      public static void stopNotifier​(int notifierHandle)
      Stops a notifier from running.

      This will cause any call into waitForNotifierAlarm to return with time = 0.

      notifierHandle - the notifier handle
      See Also:
    • cleanNotifier

      public static void cleanNotifier​(int notifierHandle)
      Cleans a notifier.

      Note this also stops a notifier if it is already running.

      notifierHandle - the notifier handle
      See Also:
    • updateNotifierAlarm

      public static void updateNotifierAlarm​(int notifierHandle, long triggerTime)
      Updates the trigger time for a notifier.

      Note that this time is an absolute time relative to getFPGATime()

      notifierHandle - the notifier handle
      triggerTime - the updated trigger time
      See Also:
    • cancelNotifierAlarm

      public static void cancelNotifierAlarm​(int notifierHandle)
      Cancels the next notifier alarm.

      This does not cause waitForNotifierAlarm to return.

      notifierHandle - the notifier handle
      See Also:
    • waitForNotifierAlarm

      public static long waitForNotifierAlarm​(int notifierHandle)
      Waits for the next alarm for the specific notifier.

      This is a blocking call until either the time elapses or stopNotifier gets called. If the latter occurs, this function will return zero and any loops using this function should exit. Failing to do so can lead to use-after-frees.

      notifierHandle - the notifier handle
      the FPGA time the notifier returned