Project

General

Profile

Using Watchdog » watchdog.h

Jonathan Cormier, 10/14/2014 03:43 PM

 
1
#include <semaphore.h>
2

    
3
namespace MityDSP {
4

    
5
/**
6
 *  The tcWatchdog class provides a simple abstraction for the linux
7
 *  watchdog device management.  Typical use pattern:
8
 *
9
 *  @code {
10
 *      
11
 *  tcWatchdog* pW = new tcWatchdog();
12
 *  int handle = pW->RegisterCheckpoint();
13
 *  pW->StartWatchDog(10);
14
 *
15
 *  while (!done)
16
 *  {
17
 *     /// do stuff
18
 *     pW->Checkin(handle);
19
 *  }
20
 *
21
 *  delete pW;
22
 *  
23
 *  @code }
24
 */
25
class tcWatchdog
26
{
27
public:
28
	tcWatchdog(const char* apDevice = "/dev/watchdog");
29
	virtual ~tcWatchdog(void);
30

    
31
	int StartWatchDog(int TimeoutSecs);
32

    
33
	int RegisterCheckpoint(void);
34

    
35
	int UnRegisterCheckpoint(int handle);
36

    
37
	int Checkin(int Checkpoint);
38

    
39
protected:
40
	volatile int	mnMask;
41
	volatile int	mnSet;
42
	sem_t		mhSem;
43
	char*		mpFileName;
44
	int		mnFd;
45
};
46

    
47
}
(6-6/7) Go to top
Add picture from clipboard (Maximum size: 1 GB)