VxWorks Reference Manual : Wind Foundation Classes
VXWWd - watchdog timer class
VXWWd::VXWWd( ) - construct a watchdog timer
VXWWd::VXWWd( ) - construct a watchdog timer
VXWWd::~VXWWd( ) - destroy a watchdog timer
VXWWd::cancel( ) - cancel a currently counting watchdog
VXWWd::start( ) - start a watchdog timer
This library provides a general watchdog timer facility. Any task may create a watchdog timer and use it to run a specified routine in the context of the system-clock ISR, after a specified delay.
Once a timer has been created, it can be started with VXWWd::start( ). The VXWWd::start( ) routine specifies what routine to run, a parameter for that routine, and the amount of time (in ticks) before the routine is to be called. (The timeout value is in ticks as determined by the system clock; see sysClkRateSet( ) for more information.) After the specified delay ticks have elapsed (unless VXWWd::cancel( ) is called first to cancel the timer) the timeout routine is invoked with the parameter specified in the VXWWd::start( ) call. The timeout routine is invoked whether the task which started the watchdog is running, suspended, or deleted.
The timeout routine executes only once per VXWWd::start( ) invocation; there is no need to cancel a timer with VXWWd::cancel( ) after it has expired, or in the expiration callback itself.
Note that the timeout routine is invoked at interrupt level, rather than in the context of the task. Thus, there are restrictions on what the routine may do. Watchdog routines are constrained to the same rules as interrupt service routines. For example, they may not take semaphores, issue other calls that may block, or use I/O system routines like printf( ).
In the fragment below, if maybeSlowRoutine( ) takes more than 60 ticks, logMsg( ) will be called with the string as a parameter, causing the message to be printed on the console. Normally, of course, more significant corrective action would be taken.
VXWWd *pWd = new VXWWd; pWd->start (60, logMsg, "Help, I've timed out!"); maybeSlowRoutine (); /* user-supplied routine */ delete pWd;
vxwWdLib.h
VXWWd, wdLib, logLib, VxWorks Programmer's Guide: Basic OS, VxWorks Programmer's Guide: C++ Development
VXWWd::VXWWd( ) - construct a watchdog timer
VXWWd ()
This routine creates a watchdog timer.
N/A
VXWWd::VXWWd( ) - construct a watchdog timer
VXWWd ( WDOG_ID aWdId )
This routine creates a watchdog timer from an existing WDOG_ID.
N/A
VXWWd::~VXWWd( ) - destroy a watchdog timer
~VXWWd ()
This routine destroys a watchdog timer. The watchdog will be removed from the timer queue if it has been started.
N/A
VXWWd::VXWWd( )
VXWWd::cancel( ) - cancel a currently counting watchdog
STATUS cancel ()
This routine cancels a currently running watchdog timer by zeroing its delay count. Watchdog timers may be canceled from interrupt level.
OK, or ERROR if the watchdog timer cannot be canceled.
VXWWd::start( )
VXWWd::start( ) - start a watchdog timer
STATUS start ( int delay, FUNCPTR pRoutine, int parameter )
This routine adds a watchdog timer to the system tick queue. The specified watchdog routine will be called from interrupt level after the specified number of ticks has elapsed. Watchdog timers may be started from interrupt level.
To replace either the timeout delay or the routine to be executed, call VXWWd::start( ) again; only the most recent VXWWd::start( ) on a given watchdog ID has any effect. (If your application requires multiple watchdog routines, use VXWWd::VXWWd( ) to generate separate a watchdog for each.) To cancel a watchdog timer before the specified tick count is reached, call VXWWd::cancel( ).
Watchdog timers execute only once, but some applications require periodically executing timers. To achieve this effect, the timer routine itself must call VXWWd::start( ) to restart the timer on each invocation.
The watchdog routine runs in the context of the system-clock ISR; thus, it is subject to all ISR restrictions.
OK, or ERROR if the watchdog timer cannot be started.