mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpilib] Fix Watchdog to always ack notifier (#8472)
This commit is contained in:
@@ -39,7 +39,7 @@ class Watchdog::Impl {
|
||||
DerefGreater<Watchdog*>>
|
||||
m_watchdogs;
|
||||
|
||||
void UpdateAlarm(bool acknowledge = false);
|
||||
void UpdateAlarm();
|
||||
|
||||
private:
|
||||
void Main();
|
||||
@@ -67,7 +67,7 @@ Watchdog::Impl::~Impl() {
|
||||
}
|
||||
}
|
||||
|
||||
void Watchdog::Impl::UpdateAlarm(bool acknowledge) {
|
||||
void Watchdog::Impl::UpdateAlarm() {
|
||||
int32_t status = 0;
|
||||
// Return if we are being destructed, or were not created successfully
|
||||
auto notifier = m_notifier.load();
|
||||
@@ -75,12 +75,12 @@ void Watchdog::Impl::UpdateAlarm(bool acknowledge) {
|
||||
return;
|
||||
}
|
||||
if (m_watchdogs.empty()) {
|
||||
HAL_CancelNotifierAlarm(notifier, acknowledge, &status);
|
||||
HAL_CancelNotifierAlarm(notifier, true, &status);
|
||||
} else {
|
||||
HAL_SetNotifierAlarm(notifier,
|
||||
static_cast<uint64_t>(
|
||||
m_watchdogs.top()->m_expirationTime.value() * 1e6),
|
||||
0, true, acknowledge, &status);
|
||||
0, true, true, &status);
|
||||
}
|
||||
WPILIB_CheckErrorStatus(status, "updating watchdog notifier alarm");
|
||||
}
|
||||
@@ -125,7 +125,7 @@ void Watchdog::Impl::Main() {
|
||||
watchdog->m_callback();
|
||||
lock.lock();
|
||||
|
||||
UpdateAlarm(true);
|
||||
UpdateAlarm();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ public class Watchdog implements Closeable, Comparable<Watchdog> {
|
||||
m_watchdogs.remove(this);
|
||||
m_expirationTime = m_startTime + m_timeout;
|
||||
m_watchdogs.add(this);
|
||||
updateAlarm(false);
|
||||
updateAlarm();
|
||||
} finally {
|
||||
m_queueMutex.unlock();
|
||||
}
|
||||
@@ -194,7 +194,7 @@ public class Watchdog implements Closeable, Comparable<Watchdog> {
|
||||
m_watchdogs.remove(this);
|
||||
m_expirationTime = m_startTime + m_timeout;
|
||||
m_watchdogs.add(this);
|
||||
updateAlarm(false);
|
||||
updateAlarm();
|
||||
} finally {
|
||||
m_queueMutex.unlock();
|
||||
}
|
||||
@@ -205,7 +205,7 @@ public class Watchdog implements Closeable, Comparable<Watchdog> {
|
||||
m_queueMutex.lock();
|
||||
try {
|
||||
m_watchdogs.remove(this);
|
||||
updateAlarm(false);
|
||||
updateAlarm();
|
||||
} finally {
|
||||
m_queueMutex.unlock();
|
||||
}
|
||||
@@ -223,12 +223,12 @@ public class Watchdog implements Closeable, Comparable<Watchdog> {
|
||||
}
|
||||
|
||||
@SuppressWarnings("resource")
|
||||
private static void updateAlarm(boolean acknowledge) {
|
||||
private static void updateAlarm() {
|
||||
if (m_watchdogs.isEmpty()) {
|
||||
NotifierJNI.cancelNotifierAlarm(m_notifier, acknowledge);
|
||||
NotifierJNI.cancelNotifierAlarm(m_notifier, true);
|
||||
} else {
|
||||
NotifierJNI.setNotifierAlarm(
|
||||
m_notifier, (long) (m_watchdogs.peek().m_expirationTime * 1e6), 0, true, acknowledge);
|
||||
m_notifier, (long) (m_watchdogs.peek().m_expirationTime * 1e6), 0, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,7 +277,7 @@ public class Watchdog implements Closeable, Comparable<Watchdog> {
|
||||
watchdog.m_callback.run();
|
||||
m_queueMutex.lock();
|
||||
|
||||
updateAlarm(true);
|
||||
updateAlarm();
|
||||
} finally {
|
||||
m_queueMutex.unlock();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user