Skip to content

The WatchDogTimer Library written to be fully compatible with C++11 and as header-only to use easily.

License

Notifications You must be signed in to change notification settings

prodeveloper0/WatchDogTimer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

WatchDogTimer

The WatchDogTimer Library written to be fully compatible with C++11 and as header-only to use easily.

How to use

0. Including wdt.hpp header file on top of your cpp file.

#include <wdt.hpp>
// Or
#include "wdt.hpp"

1. Subtyping your dog with WatchdogTimer class and implementing on_timeout() to bark to you.

class MyWatchdogTimer : public WatchdogTimer
{
public:
  virtual void on_timeout()
  {
    // To do when your dog is bark.
    ...
  }
};

2. Creating your dog with subtyped WatchdogTimer class.

MyWatchdogTimer wdt;

3. Kicking your dog by calling kick().

// wdt is scheduled to call on_timeout() after 100ms once.
wdt.kick(100);

As well as, you can also kick your dog to watch forever by calling kick() with loop flag true.

// wdt is scheduled to call on_timeout() after 100ms forever.
wdt.kick(100, true);

4. Feeding your dog repeatedly to be silence by calling clear() repeatedly.

while (true)
{
  // To do somethings
  ...
  
  if (there_is_no_problem)
    wdt.clear();
}

5. Finally, Stopping your dog to watch by calling stop().

wdt.stop();

About

The WatchDogTimer Library written to be fully compatible with C++11 and as header-only to use easily.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages