VxWorks Reference Manual : Wind Foundation Classes

VXWWd

NAME

VXWWd - watchdog timer class

METHODS

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

DESCRIPTION

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( ).

EXAMPLE

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;

INCLUDE FILES

vxwWdLib.h

SEE ALSO

VXWWd, wdLib, logLib, VxWorks Programmer's Guide: Basic OS, VxWorks Programmer's Guide: C++ Development


Wind Foundation Classes : Methods

VXWWd::VXWWd( )

NAME

VXWWd::VXWWd( ) - construct a watchdog timer

SYNOPSIS

    VXWWd ()

DESCRIPTION

This routine creates a watchdog timer.

RETURNS

N/A

SEE ALSO

VXWWd::~VXWWd( )


Wind Foundation Classes : Methods

VXWWd::VXWWd( )

NAME

VXWWd::VXWWd( ) - construct a watchdog timer

SYNOPSIS

VXWWd
    (
    WDOG_ID aWdId
    )

DESCRIPTION

This routine creates a watchdog timer from an existing WDOG_ID.

RETURNS

N/A

SEE ALSO

VXWWd::~VXWWd( )


Wind Foundation Classes : Methods

VXWWd::~VXWWd( )

NAME

VXWWd::~VXWWd( ) - destroy a watchdog timer

SYNOPSIS

    ~VXWWd ()

DESCRIPTION

This routine destroys a watchdog timer. The watchdog will be removed from the timer queue if it has been started.

RETURNS

N/A

SEE ALSO

VXWWd::VXWWd( )


Wind Foundation Classes : Methods

VXWWd::cancel( )

NAME

VXWWd::cancel( ) - cancel a currently counting watchdog

SYNOPSIS

    STATUS cancel ()

DESCRIPTION

This routine cancels a currently running watchdog timer by zeroing its delay count. Watchdog timers may be canceled from interrupt level.

RETURNS

OK, or ERROR if the watchdog timer cannot be canceled.

SEE ALSO

VXWWd::start( )


Wind Foundation Classes : Methods

VXWWd::start( )

NAME

VXWWd::start( ) - start a watchdog timer

SYNOPSIS

STATUS start
    (
    int     delay,
    FUNCPTR pRoutine,
    int     parameter
    )

DESCRIPTION

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.

WARNING

The watchdog routine runs in the context of the system-clock ISR; thus, it is subject to all ISR restrictions.

RETURNS

OK, or ERROR if the watchdog timer cannot be started.

SEE ALSO

VXWWd::cancel( )