diff --git a/hal/src/main/java/org/wpilib/hardware/hal/NotifierJNI.java b/hal/src/main/java/org/wpilib/hardware/hal/NotifierJNI.java
index a8c444f2f5..fe825fc749 100644
--- a/hal/src/main/java/org/wpilib/hardware/hal/NotifierJNI.java
+++ b/hal/src/main/java/org/wpilib/hardware/hal/NotifierJNI.java
@@ -74,40 +74,31 @@ public class NotifierJNI extends JNIWrapper {
* @param alarmTime the first alarm time (in microseconds)
* @param intervalTime the periodic interval time (in microseconds)
* @param absolute true if the alarm time is absolute
+ * @param ack true to acknowledge any prior alarm
* @see "HAL_SetNotifierAlarm"
*/
public static native void setNotifierAlarm(
- int notifierHandle, long alarmTime, long intervalTime, boolean absolute);
+ int notifierHandle, long alarmTime, long intervalTime, boolean absolute, boolean ack);
/**
* Cancels all future notifier alarms for a notifier.
*
* @param notifierHandle the notifier handle
+ * @param ack true to acknowledge any prior alarm
* @see "HAL_CancelNotifierAlarm"
*/
- public static native void cancelNotifierAlarm(int notifierHandle);
+ public static native void cancelNotifierAlarm(int notifierHandle, boolean ack);
/**
- * Indicates the notifier alarm has been serviced and optionally sets a new alarm time. This must
- * be called before waiting for the next alarm.
+ * Indicates the notifier alarm has been serviced. Makes no change to future alarms.
*
- *
The alarmTime is an absolute time (using the WPI now() time base) if absolute is true, or
- * relative to the current time if absolute is false.
- *
- *
If intervalTime is non-zero, the notifier will alarm periodically following alarmTime at the
- * given interval.
- *
- *
If an absolute alarmTime is in the past, the notifier will alarm immediately.
+ *
One of setNotifierAlarm (with ack=true), cancelNotifierAlarm (with ack=true), or this
+ * function must be called before waiting for the next alarm.
*
* @param notifierHandle the notifier handle
- * @param setAlarm true to set a new alarm time, false to leave the alarm unchanged
- * @param alarmTime the first alarm time (in microseconds)
- * @param intervalTime the periodic interval time (in microseconds)
- * @param absolute true if the alarm time is absolute
* @see "HAL_AcknowledgeNotifierAlarm"
*/
- public static native void acknowledgeNotifierAlarm(
- int notifierHandle, boolean setAlarm, long alarmTime, long intervalTime, boolean absolute);
+ public static native void acknowledgeNotifierAlarm(int notifierHandle);
/**
* Gets the overrun count for a notifier.
diff --git a/hal/src/main/native/cpp/jni/NotifierJNI.cpp b/hal/src/main/native/cpp/jni/NotifierJNI.cpp
index 6d052980cb..68c7a9b773 100644
--- a/hal/src/main/native/cpp/jni/NotifierJNI.cpp
+++ b/hal/src/main/native/cpp/jni/NotifierJNI.cpp
@@ -82,49 +82,45 @@ Java_org_wpilib_hardware_hal_NotifierJNI_destroyNotifier
/*
* Class: org_wpilib_hardware_hal_NotifierJNI
* Method: setNotifierAlarm
- * Signature: (IJJZ)V
+ * Signature: (IJJZZ)V
*/
JNIEXPORT void JNICALL
Java_org_wpilib_hardware_hal_NotifierJNI_setNotifierAlarm
(JNIEnv* env, jclass cls, jint notifierHandle, jlong alarmTime,
- jlong intervalTime, jboolean absolute)
+ jlong intervalTime, jboolean absolute, jboolean ack)
{
int32_t status = 0;
- HAL_SetNotifierAlarm((HAL_NotifierHandle)notifierHandle,
- static_cast(alarmTime),
- static_cast(intervalTime), absolute, &status);
+ HAL_SetNotifierAlarm(
+ (HAL_NotifierHandle)notifierHandle, static_cast(alarmTime),
+ static_cast(intervalTime), absolute, ack, &status);
CheckStatus(env, status);
}
/*
* Class: org_wpilib_hardware_hal_NotifierJNI
* Method: cancelNotifierAlarm
- * Signature: (I)V
+ * Signature: (IZ)V
*/
JNIEXPORT void JNICALL
Java_org_wpilib_hardware_hal_NotifierJNI_cancelNotifierAlarm
- (JNIEnv* env, jclass cls, jint notifierHandle)
+ (JNIEnv* env, jclass cls, jint notifierHandle, jboolean ack)
{
int32_t status = 0;
- HAL_CancelNotifierAlarm((HAL_NotifierHandle)notifierHandle, &status);
+ HAL_CancelNotifierAlarm((HAL_NotifierHandle)notifierHandle, ack, &status);
CheckStatus(env, status);
}
/*
* Class: org_wpilib_hardware_hal_NotifierJNI
* Method: acknowledgeNotifierAlarm
- * Signature: (IZJJZ)V
+ * Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_org_wpilib_hardware_hal_NotifierJNI_acknowledgeNotifierAlarm
- (JNIEnv* env, jclass cls, jint notifierHandle, jboolean setAlarm,
- jlong alarmTime, jlong intervalTime, jboolean absolute)
+ (JNIEnv* env, jclass cls, jint notifierHandle)
{
int32_t status = 0;
- HAL_AcknowledgeNotifierAlarm((HAL_NotifierHandle)notifierHandle, setAlarm,
- static_cast(alarmTime),
- static_cast(intervalTime), absolute,
- &status);
+ HAL_AcknowledgeNotifierAlarm((HAL_NotifierHandle)notifierHandle, &status);
CheckStatus(env, status);
}
diff --git a/hal/src/main/native/include/wpi/hal/Notifier.h b/hal/src/main/native/include/wpi/hal/Notifier.h
index 048e4cfe0c..85658215fd 100644
--- a/hal/src/main/native/include/wpi/hal/Notifier.h
+++ b/hal/src/main/native/include/wpi/hal/Notifier.h
@@ -87,44 +87,34 @@ void HAL_DestroyNotifier(HAL_NotifierHandle notifierHandle);
* @param[in] alarmTime the first alarm time (in microseconds)
* @param[in] intervalTime the periodic interval time (in microseconds)
* @param[in] absolute true if the alarm time is absolute
+ * @param[in] ack true to acknowledge any prior alarm
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetNotifierAlarm(HAL_NotifierHandle notifierHandle, uint64_t alarmTime,
uint64_t intervalTime, HAL_Bool absolute,
- int32_t* status);
+ HAL_Bool ack, int32_t* status);
/**
* Cancels all future notifier alarms for a notifier.
*
* @param[in] notifierHandle the notifier handle
+ * @param[in] ack true to acknowledge any prior alarm
* @param[out] status Error status variable. 0 on success.
*/
-void HAL_CancelNotifierAlarm(HAL_NotifierHandle notifierHandle,
+void HAL_CancelNotifierAlarm(HAL_NotifierHandle notifierHandle, HAL_Bool ack,
int32_t* status);
/**
- * Indicates the notifier alarm has been serviced and optionally sets a new
- * alarm time. This must be called before waiting for the next alarm.
+ * Indicates the notifier alarm has been serviced. Makes no change to future
+ * alarms.
*
- * The alarmTime is an absolute time (using the WPI_Now() time base) if
- * absolute is true, or relative to the current time if absolute is false.
- *
- * If intervalTime is non-zero, the notifier will alarm periodically following
- * alarmTime at the given interval.
- *
- * If an absolute alarmTime is in the past, the notifier will alarm immediately.
+ * One of HAL_SetNotifierAlarm (with ack=true), HAL_CancelNotifierAlarm (with
+ * ack=true), or this function must be called before waiting for the next alarm.
*
* @param[in] notifierHandle the notifier handle
- * @param[in] setAlarm true to set a new alarm time, false to leave the
- * alarm unchanged
- * @param[in] alarmTime the first alarm time (in microseconds)
- * @param[in] intervalTime the periodic interval time (in microseconds)
- * @param[in] absolute true if the alarm time is absolute
* @param[out] status Error status variable. 0 on success.
*/
void HAL_AcknowledgeNotifierAlarm(HAL_NotifierHandle notifierHandle,
- HAL_Bool setAlarm, uint64_t alarmTime,
- uint64_t intervalTime, HAL_Bool absolute,
int32_t* status);
/**
diff --git a/hal/src/main/native/sim/Notifier.cpp b/hal/src/main/native/sim/Notifier.cpp
index 0f0d83b081..d00c33d112 100644
--- a/hal/src/main/native/sim/Notifier.cpp
+++ b/hal/src/main/native/sim/Notifier.cpp
@@ -46,10 +46,6 @@ class NotifierThread : public wpi::util::SafeThread {
public:
void Main() override;
- void SetAlarm(HAL_NotifierHandle notifierHandle,
- std::shared_ptr& notifier, uint64_t alarmTime,
- uint64_t intervalTime, bool absolute, int32_t* status);
-
void ProcessAlarms(wpi::util::SmallVectorImpl* signaled);
bool m_paused = false;
@@ -115,30 +111,6 @@ void NotifierThread::Main() {
}
}
-void NotifierThread::SetAlarm(HAL_NotifierHandle notifierHandle,
- std::shared_ptr& notifier,
- uint64_t alarmTime, uint64_t intervalTime,
- bool absolute, int32_t* status) {
- if (!absolute) {
- alarmTime += HAL_GetFPGATime(status);
- }
-
- uint64_t prevWakeup = UINT64_MAX;
- if (!m_alarmQueue.empty()) {
- prevWakeup = m_alarmQueue.top().notifier->alarmTime;
- m_alarmQueue.remove({notifierHandle, notifier});
- }
- notifier->alarmTime = alarmTime;
- notifier->intervalTime = intervalTime;
- notifier->overrunCount = 0;
- m_alarmQueue.push({notifierHandle, notifier});
-
- // wake up notifier thread if needed
- if (alarmTime < prevWakeup) {
- m_cond.notify_all();
- }
-}
-
void NotifierThread::ProcessAlarms(
wpi::util::SmallVectorImpl* signaled) {
int32_t status = 0;
@@ -278,17 +250,38 @@ void HAL_DestroyNotifier(HAL_NotifierHandle notifierHandle) {
void HAL_SetNotifierAlarm(HAL_NotifierHandle notifierHandle, uint64_t alarmTime,
uint64_t intervalTime, HAL_Bool absolute,
- int32_t* status) {
+ HAL_Bool ack, int32_t* status) {
auto thr = notifierInstance->owner.GetThread();
auto notifier = thr->m_handles.Get(notifierHandle);
if (!notifier) {
return;
}
- thr->SetAlarm(notifierHandle, notifier, alarmTime, intervalTime, absolute,
- status);
+
+ if (ack) {
+ notifier->handlerSignaled.clear();
+ }
+
+ if (!absolute) {
+ alarmTime += HAL_GetFPGATime(status);
+ }
+
+ uint64_t prevWakeup = UINT64_MAX;
+ if (!thr->m_alarmQueue.empty()) {
+ prevWakeup = thr->m_alarmQueue.top().notifier->alarmTime;
+ thr->m_alarmQueue.remove({notifierHandle, notifier});
+ }
+ notifier->alarmTime = alarmTime;
+ notifier->intervalTime = intervalTime;
+ notifier->overrunCount = 0;
+ thr->m_alarmQueue.push({notifierHandle, notifier});
+
+ // wake up notifier thread if needed
+ if (alarmTime < prevWakeup) {
+ thr->m_cond.notify_all();
+ }
}
-void HAL_CancelNotifierAlarm(HAL_NotifierHandle notifierHandle,
+void HAL_CancelNotifierAlarm(HAL_NotifierHandle notifierHandle, HAL_Bool ack,
int32_t* status) {
auto thr = notifierInstance->owner.GetThread();
auto notifier = thr->m_handles.Get(notifierHandle);
@@ -296,14 +289,15 @@ void HAL_CancelNotifierAlarm(HAL_NotifierHandle notifierHandle,
return;
}
+ if (ack) {
+ notifier->handlerSignaled.clear();
+ }
+
thr->m_alarmQueue.remove({notifierHandle, notifier});
notifier->alarmTime = UINT64_MAX;
- notifier->handlerSignaled.clear();
}
void HAL_AcknowledgeNotifierAlarm(HAL_NotifierHandle notifierHandle,
- HAL_Bool setAlarm, uint64_t alarmTime,
- uint64_t intervalTime, HAL_Bool absolute,
int32_t* status) {
auto thr = notifierInstance->owner.GetThread();
auto notifier = thr->m_handles.Get(notifierHandle);
@@ -311,10 +305,6 @@ void HAL_AcknowledgeNotifierAlarm(HAL_NotifierHandle notifierHandle,
return;
}
notifier->handlerSignaled.clear();
- if (setAlarm) {
- thr->SetAlarm(notifierHandle, notifier, alarmTime, intervalTime, absolute,
- status);
- }
}
int32_t HAL_GetNotifierOverrun(HAL_NotifierHandle notifierHandle,
diff --git a/hal/src/main/native/systemcore/Notifier.cpp b/hal/src/main/native/systemcore/Notifier.cpp
index f5501a3a64..6e50d785e6 100644
--- a/hal/src/main/native/systemcore/Notifier.cpp
+++ b/hal/src/main/native/systemcore/Notifier.cpp
@@ -39,10 +39,6 @@ class NotifierThread : public wpi::util::SafeThread {
public:
void Main() override;
- void SetAlarm(HAL_NotifierHandle notifierHandle,
- std::shared_ptr& notifier, uint64_t alarmTime,
- uint64_t intervalTime, bool absolute, int32_t* status);
-
void ProcessAlarms();
UnlimitedHandleResource& notifier,
- uint64_t alarmTime, uint64_t intervalTime,
- bool absolute, int32_t* status) {
- if (!absolute) {
- alarmTime += HAL_GetFPGATime(status);
- }
-
- uint64_t prevWakeup = UINT64_MAX;
- if (!m_alarmQueue.empty()) {
- prevWakeup = m_alarmQueue.top().notifier->alarmTime;
- m_alarmQueue.remove({notifierHandle, notifier});
- }
- notifier->alarmTime = alarmTime;
- notifier->intervalTime = intervalTime;
- notifier->overrunCount = 0;
- m_alarmQueue.push({notifierHandle, notifier});
-
- // wake up notifier thread if needed
- if (alarmTime < prevWakeup) {
- m_cond.notify_all();
- }
-}
-
void NotifierThread::ProcessAlarms() {
int32_t status = 0;
uint64_t curTime = HAL_GetFPGATime(&status);
@@ -204,17 +176,38 @@ void HAL_DestroyNotifier(HAL_NotifierHandle notifierHandle) {
void HAL_SetNotifierAlarm(HAL_NotifierHandle notifierHandle, uint64_t alarmTime,
uint64_t intervalTime, HAL_Bool absolute,
- int32_t* status) {
+ HAL_Bool ack, int32_t* status) {
auto thr = notifierInstance->owner.GetThread();
auto notifier = thr->m_handles.Get(notifierHandle);
if (!notifier) {
return;
}
- thr->SetAlarm(notifierHandle, notifier, alarmTime, intervalTime, absolute,
- status);
+
+ if (ack) {
+ notifier->handlerSignaled.clear();
+ }
+
+ if (!absolute) {
+ alarmTime += HAL_GetFPGATime(status);
+ }
+
+ uint64_t prevWakeup = UINT64_MAX;
+ if (!thr->m_alarmQueue.empty()) {
+ prevWakeup = thr->m_alarmQueue.top().notifier->alarmTime;
+ thr->m_alarmQueue.remove({notifierHandle, notifier});
+ }
+ notifier->alarmTime = alarmTime;
+ notifier->intervalTime = intervalTime;
+ notifier->overrunCount = 0;
+ thr->m_alarmQueue.push({notifierHandle, notifier});
+
+ // wake up notifier thread if needed
+ if (alarmTime < prevWakeup) {
+ thr->m_cond.notify_all();
+ }
}
-void HAL_CancelNotifierAlarm(HAL_NotifierHandle notifierHandle,
+void HAL_CancelNotifierAlarm(HAL_NotifierHandle notifierHandle, HAL_Bool ack,
int32_t* status) {
auto thr = notifierInstance->owner.GetThread();
auto notifier = thr->m_handles.Get(notifierHandle);
@@ -222,14 +215,15 @@ void HAL_CancelNotifierAlarm(HAL_NotifierHandle notifierHandle,
return;
}
+ if (ack) {
+ notifier->handlerSignaled.clear();
+ }
+
thr->m_alarmQueue.remove({notifierHandle, notifier});
notifier->alarmTime = UINT64_MAX;
- notifier->handlerSignaled.clear();
}
void HAL_AcknowledgeNotifierAlarm(HAL_NotifierHandle notifierHandle,
- HAL_Bool setAlarm, uint64_t alarmTime,
- uint64_t intervalTime, HAL_Bool absolute,
int32_t* status) {
auto thr = notifierInstance->owner.GetThread();
auto notifier = thr->m_handles.Get(notifierHandle);
@@ -237,10 +231,6 @@ void HAL_AcknowledgeNotifierAlarm(HAL_NotifierHandle notifierHandle,
return;
}
notifier->handlerSignaled.clear();
- if (setAlarm) {
- thr->SetAlarm(notifierHandle, notifier, alarmTime, intervalTime, absolute,
- status);
- }
}
int32_t HAL_GetNotifierOverrun(HAL_NotifierHandle notifierHandle,
diff --git a/wpilibc/src/main/native/cpp/framework/TimedRobot.cpp b/wpilibc/src/main/native/cpp/framework/TimedRobot.cpp
index 81f758a23c..bc4429f89e 100644
--- a/wpilibc/src/main/native/cpp/framework/TimedRobot.cpp
+++ b/wpilibc/src/main/native/cpp/framework/TimedRobot.cpp
@@ -25,8 +25,6 @@ void TimedRobot::StartCompetition() {
std::puts("\n********** Robot program startup complete **********");
HAL_ObserveUserProgramStarting();
- bool first = true;
-
// Loop forever, calling the appropriate mode-dependent function
while (true) {
// We don't have to check there's an element in the queue first because
@@ -35,16 +33,9 @@ void TimedRobot::StartCompetition() {
auto callback = m_callbacks.pop();
int32_t status = 0;
- if (first) {
- first = false;
- HAL_SetNotifierAlarm(m_notifier, callback.expirationTime.count(), 0, true,
- &status);
- WPILIB_CheckErrorStatus(status, "SetNotifierAlarm");
- } else {
- HAL_AcknowledgeNotifierAlarm(
- m_notifier, true, callback.expirationTime.count(), 0, true, &status);
- WPILIB_CheckErrorStatus(status, "AcknowledgeNotifierAlarm");
- }
+ HAL_SetNotifierAlarm(m_notifier, callback.expirationTime.count(), 0, true,
+ true, &status);
+ WPILIB_CheckErrorStatus(status, "SetNotifierAlarm");
if (WPI_WaitForObject(m_notifier) == 0) {
break;
diff --git a/wpilibc/src/main/native/cpp/system/Notifier.cpp b/wpilibc/src/main/native/cpp/system/Notifier.cpp
index b7914f22bc..f2592f78a6 100644
--- a/wpilibc/src/main/native/cpp/system/Notifier.cpp
+++ b/wpilibc/src/main/native/cpp/system/Notifier.cpp
@@ -46,7 +46,7 @@ Notifier::Notifier(std::function callback) {
}
// Ack notifier
- HAL_AcknowledgeNotifierAlarm(notifier, false, 0, 0, false, &status);
+ HAL_AcknowledgeNotifierAlarm(notifier, &status);
WPILIB_CheckErrorStatus(status, "AcknowledgeNotifier");
}
});
@@ -99,7 +99,7 @@ Notifier::Notifier(int priority, std::function callback) {
}
// Ack notifier
- HAL_AcknowledgeNotifierAlarm(notifier, false, 0, 0, false, &status);
+ HAL_AcknowledgeNotifierAlarm(notifier, &status);
WPILIB_CheckErrorStatus(status, "AcknowledgeNotifier");
}
});
@@ -144,13 +144,14 @@ void Notifier::SetCallback(std::function callback) {
void Notifier::StartSingle(wpi::units::second_t delay) {
int32_t status = 0;
HAL_SetNotifierAlarm(m_notifier, static_cast(delay * 1e6), 0, false,
- &status);
+ false, &status);
}
void Notifier::StartPeriodic(wpi::units::second_t period) {
int32_t status = 0;
HAL_SetNotifierAlarm(m_notifier, static_cast(period * 1e6),
- static_cast(period * 1e6), false, &status);
+ static_cast(period * 1e6), false, false,
+ &status);
}
void Notifier::StartPeriodic(wpi::units::hertz_t frequency) {
@@ -159,7 +160,7 @@ void Notifier::StartPeriodic(wpi::units::hertz_t frequency) {
void Notifier::Stop() {
int32_t status = 0;
- HAL_CancelNotifierAlarm(m_notifier, &status);
+ HAL_CancelNotifierAlarm(m_notifier, false, &status);
WPILIB_CheckErrorStatus(status, "CancelNotifierAlarm");
}
diff --git a/wpilibc/src/main/native/cpp/system/Watchdog.cpp b/wpilibc/src/main/native/cpp/system/Watchdog.cpp
index 0c2d7228f7..97ac70901f 100644
--- a/wpilibc/src/main/native/cpp/system/Watchdog.cpp
+++ b/wpilibc/src/main/native/cpp/system/Watchdog.cpp
@@ -75,18 +75,12 @@ void Watchdog::Impl::UpdateAlarm(bool acknowledge) {
return;
}
if (m_watchdogs.empty()) {
- HAL_CancelNotifierAlarm(notifier, &status);
- } else if (acknowledge) {
- HAL_AcknowledgeNotifierAlarm(
- notifier, true,
- static_cast(m_watchdogs.top()->m_expirationTime.value() *
- 1e6),
- 0, true, &status);
+ HAL_CancelNotifierAlarm(notifier, acknowledge, &status);
} else {
HAL_SetNotifierAlarm(notifier,
static_cast(
m_watchdogs.top()->m_expirationTime.value() * 1e6),
- 0, true, &status);
+ 0, true, acknowledge, &status);
}
WPILIB_CheckErrorStatus(status, "updating watchdog notifier alarm");
}
diff --git a/wpilibc/src/main/python/wpilib/src/rpy/Notifier.cpp b/wpilibc/src/main/python/wpilib/src/rpy/Notifier.cpp
index 5cb87dceb4..7f208b8219 100644
--- a/wpilibc/src/main/python/wpilib/src/rpy/Notifier.cpp
+++ b/wpilibc/src/main/python/wpilib/src/rpy/Notifier.cpp
@@ -71,7 +71,7 @@ PyNotifier::PyNotifier(std::function handler) {
}
// Ack notifier
- HAL_AcknowledgeNotifierAlarm(notifier, false, 0, 0, false, &status);
+ HAL_AcknowledgeNotifierAlarm(notifier, &status);
WPILIB_CheckErrorStatus(status, "AcknowledgeNotifier");
}
} catch (...) {
@@ -120,6 +120,7 @@ PyNotifier &PyNotifier::operator=(PyNotifier &&rhs) {
void PyNotifier::SetName(std::string_view name) {
int32_t status = 0;
HAL_SetNotifierName(m_notifier, name, &status);
+ WPILIB_CheckErrorStatus(status, "SetNotifierName");
}
void PyNotifier::SetCallback(std::function handler) {
@@ -130,18 +131,21 @@ void PyNotifier::SetCallback(std::function handler) {
void PyNotifier::StartSingle(wpi::units::second_t delay) {
int32_t status = 0;
HAL_SetNotifierAlarm(m_notifier, static_cast(delay * 1e6), 0, false,
- &status);
+ false, &status);
+ WPILIB_CheckErrorStatus(status, "SetNotifierAlarm");
}
void PyNotifier::StartPeriodic(wpi::units::second_t period) {
int32_t status = 0;
HAL_SetNotifierAlarm(m_notifier, static_cast(period * 1e6),
- static_cast(period * 1e6), false, &status);
+ static_cast(period * 1e6), false, false,
+ &status);
+ WPILIB_CheckErrorStatus(status, "SetNotifierAlarm");
}
void PyNotifier::Stop() {
int32_t status = 0;
- HAL_CancelNotifierAlarm(m_notifier, &status);
+ HAL_CancelNotifierAlarm(m_notifier, false, &status);
WPILIB_CheckErrorStatus(status, "CancelNotifierAlarm");
}
diff --git a/wpilibj/src/main/java/org/wpilib/framework/TimedRobot.java b/wpilibj/src/main/java/org/wpilib/framework/TimedRobot.java
index e971c818c8..dc6a75c3ab 100644
--- a/wpilibj/src/main/java/org/wpilib/framework/TimedRobot.java
+++ b/wpilibj/src/main/java/org/wpilib/framework/TimedRobot.java
@@ -130,8 +130,6 @@ public class TimedRobot extends IterativeRobotBase {
System.out.println("********** Robot program startup complete **********");
DriverStationJNI.observeUserProgramStarting();
- boolean first = true;
-
// Loop forever, calling the appropriate mode-dependent function
while (true) {
// We don't have to check there's an element in the queue first because
@@ -139,12 +137,7 @@ public class TimedRobot extends IterativeRobotBase {
// at the end of the loop.
var callback = m_callbacks.poll();
- if (first) {
- first = false;
- NotifierJNI.setNotifierAlarm(m_notifier, callback.expirationTime, 0, true);
- } else {
- NotifierJNI.acknowledgeNotifierAlarm(m_notifier, true, callback.expirationTime, 0, true);
- }
+ NotifierJNI.setNotifierAlarm(m_notifier, callback.expirationTime, 0, true, true);
try {
WPIUtilJNI.waitForObject(m_notifier);
diff --git a/wpilibj/src/main/java/org/wpilib/system/Notifier.java b/wpilibj/src/main/java/org/wpilib/system/Notifier.java
index b7fae63858..8b661030dd 100644
--- a/wpilibj/src/main/java/org/wpilib/system/Notifier.java
+++ b/wpilibj/src/main/java/org/wpilib/system/Notifier.java
@@ -95,7 +95,7 @@ public class Notifier implements AutoCloseable {
}
// Acknowledge the alarm
- NotifierJNI.acknowledgeNotifierAlarm(notifier, false, 0, 0, false);
+ NotifierJNI.acknowledgeNotifierAlarm(notifier);
}
});
m_thread.setName("Notifier");
@@ -148,7 +148,7 @@ public class Notifier implements AutoCloseable {
* @param delay Time in seconds to wait before the callback is called.
*/
public void startSingle(double delay) {
- NotifierJNI.setNotifierAlarm(m_notifier.get(), (long) (delay * 1e6), 0, false);
+ NotifierJNI.setNotifierAlarm(m_notifier.get(), (long) (delay * 1e6), 0, false, false);
}
/**
@@ -171,7 +171,7 @@ public class Notifier implements AutoCloseable {
*/
public void startPeriodic(double period) {
long periodMicroS = (long) (period * 1e6);
- NotifierJNI.setNotifierAlarm(m_notifier.get(), periodMicroS, periodMicroS, false);
+ NotifierJNI.setNotifierAlarm(m_notifier.get(), periodMicroS, periodMicroS, false, false);
}
/**
@@ -205,12 +205,9 @@ public class Notifier implements AutoCloseable {
*
* No further periodic callbacks will occur. Single invocations will also be cancelled if they
* haven't yet occurred.
- *
- *
If a callback invocation is in progress, this function will block until the callback is
- * complete.
*/
public void stop() {
- NotifierJNI.cancelNotifierAlarm(m_notifier.get());
+ NotifierJNI.cancelNotifierAlarm(m_notifier.get(), false);
}
/**
diff --git a/wpilibj/src/main/java/org/wpilib/system/Watchdog.java b/wpilibj/src/main/java/org/wpilib/system/Watchdog.java
index 949a15d4ed..5fc31d853c 100644
--- a/wpilibj/src/main/java/org/wpilib/system/Watchdog.java
+++ b/wpilibj/src/main/java/org/wpilib/system/Watchdog.java
@@ -225,13 +225,10 @@ public class Watchdog implements Closeable, Comparable {
@SuppressWarnings("resource")
private static void updateAlarm(boolean acknowledge) {
if (m_watchdogs.isEmpty()) {
- NotifierJNI.cancelNotifierAlarm(m_notifier);
- } else if (acknowledge) {
- NotifierJNI.acknowledgeNotifierAlarm(
- m_notifier, true, (long) (m_watchdogs.peek().m_expirationTime * 1e6), 0, true);
+ NotifierJNI.cancelNotifierAlarm(m_notifier, acknowledge);
} else {
NotifierJNI.setNotifierAlarm(
- m_notifier, (long) (m_watchdogs.peek().m_expirationTime * 1e6), 0, true);
+ m_notifier, (long) (m_watchdogs.peek().m_expirationTime * 1e6), 0, true, acknowledge);
}
}