pub struct Watchdog { /* private fields */ }Expand description
A deadman timer: it expires unless fed often enough, catching a stalled controller or link.
Autonomy assumes a stream of fresh commands. If that stream stops, because the controller hung
or the radio dropped, the last command must not run forever. A watchdog counts the time since it
was last fed and reports expiry once that exceeds its timeout; the caller feeds it each time a
fresh command arrives. It accumulates a supplied dt rather than reading a clock, so it works
the same on a microcontroller with no wall time.
§Examples
use pamoja_kit::Watchdog;
let mut dog = Watchdog::new(0.5); // expire after 0.5 s of silence
dog.feed();
assert!(!dog.update(0.3)); // 0.3 s since feeding: still alive
assert!(dog.update(0.3)); // 0.6 s total: expired
dog.feed(); // a fresh command revives it
assert!(!dog.is_expired());Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Watchdog
impl RefUnwindSafe for Watchdog
impl Send for Watchdog
impl Sync for Watchdog
impl Unpin for Watchdog
impl UnsafeUnpin for Watchdog
impl UnwindSafe for Watchdog
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more