📄 wdlib.html
字号:
<html><head><!-- /vobs/wpwr/docs/vxworks/ref/wdLib.html - generated by refgen from wdLib.c --> <title> wdLib </title></head><body bgcolor="#FFFFFF"> <hr><a name="top"></a><p align=right><a href="libIndex.html"><i>VxWorks Reference Manual : Libraries</i></a></p></blockquote><h1>wdLib</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong>wdLib</strong> - watchdog timer library </p></blockquote><h4>ROUTINES</h4><blockquote><p><p><b><i><a href="./wdLib.html#wdCreate">wdCreate</a></i>( )</b> - create a watchdog timer<br><b><i><a href="./wdLib.html#wdDelete">wdDelete</a></i>( )</b> - delete a watchdog timer<br><b><i><a href="./wdLib.html#wdStart">wdStart</a></i>( )</b> - start a watchdog timer<br><b><i><a href="./wdLib.html#wdCancel">wdCancel</a></i>( )</b> - cancel a currently counting watchdog<br><p></blockquote><h4>DESCRIPTION</h4><blockquote><p>This library provides a general watchdog timer facility. Any task maycreate a watchdog timer and use it to run a specified routine inthe context of the system-clock ISR, after a specified delay.<p>Once a timer has been created with <b><i><a href="./wdLib.html#wdCreate">wdCreate</a></i>( )</b>, it can be started with<b><i><a href="./wdLib.html#wdStart">wdStart</a></i>( )</b>. The <b><i><a href="./wdLib.html#wdStart">wdStart</a></i>( )</b> routine specifies what routine to run, aparameter for that routine, and the amount of time (in ticks) beforethe routine is to be called. (The timeout value is in ticks asdetermined by the system clock; see <b><i><a href="./sysLib.html#sysClkRateSet">sysClkRateSet</a></i>( )</b> for moreinformation.) After the specified delay ticks have elapsed (unless<b><i><a href="./wdLib.html#wdCancel">wdCancel</a></i>( )</b> is called first to cancel the timer) the timeout routine isinvoked with the parameter specified in the <b><i><a href="./wdLib.html#wdStart">wdStart</a></i>( )</b> call. Thetimeout routine is invoked whether the task which started the watchdogis running, suspended, or deleted.<p>The timeout routine executes only once per <b><i><a href="./wdLib.html#wdStart">wdStart</a></i>( )</b> invocation; thereis no need to cancel a timer with <b><i><a href="./wdLib.html#wdCancel">wdCancel</a></i>( )</b> after it has expired, orin the expiration callback itself.<p>Note that the timeout routine is invoked at interrupt level, rather thanin the context of the task. Thus, there are restrictions on what theroutine may do. Watchdog routines are constrained to the same rulesas interrupt service routines. For example, they may not take semaphores,issue other calls that may block, or use I/O system routines like <b><i><a href="./fioLib.html#printf">printf</a></i>( )</b>.<p></blockquote><h4>EXAMPLE</h4><blockquote><p>In the fragment below, if <b><i>maybeSlowRoutine</i>( )</b> takes more than 60 ticks,<b><i><a href="./logLib.html#logMsg">logMsg</a></i>( )</b> will be called with the string as a parameter, causing the message tobe printed on the console. Normally, of course, more significant correctiveaction would be taken.<pre> WDOG_ID wid = wdCreate (); wdStart (wid, 60, logMsg, "Help, I've timed out!"); maybeSlowRoutine (); /* user-supplied routine */ wdCancel (wid);</pre></blockquote><h4>INCLUDE FILES</h4><blockquote><p><b>wdLib.h</b><p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./wdLib.html#top">wdLib</a></b>, <b><a href="./logLib.html#top">logLib</a></b>, <i>VxWorks Programmer's Guide: Basic OS</i><hr><a name="wdCreate"></a><p align=right><a href="rtnIndex.html"><i>Libraries : Routines</i></a></p></blockquote><h1><i>wdCreate</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>wdCreate</i>( )</strong> - create a watchdog timer</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>WDOG_ID wdCreate (void)</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine creates a watchdog timer by allocating a WDOG structure inmemory.<p></blockquote><h4>RETURNS</h4><blockquote><p>The ID for the watchdog created, or NULL if memory is insufficient.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./wdLib.html#top">wdLib</a></b>, <b><i><a href="./wdLib.html#wdDelete">wdDelete</a></i>( )</b><hr><a name="wdDelete"></a><p align=right><a href="rtnIndex.html"><i>Libraries : Routines</i></a></p></blockquote><h1><i>wdDelete</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>wdDelete</i>( )</strong> - delete a watchdog timer</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS wdDelete ( WDOG_ID wdId /* ID of watchdog to delete */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine de-allocates a watchdog timer. The watchdog will be removedfrom the timer queue if it has been started. This routine complements<b><i><a href="./wdLib.html#wdCreate">wdCreate</a></i>( )</b>.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if the watchdog timer cannot be de-allocated.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./wdLib.html#top">wdLib</a></b>, <b><i><a href="./wdLib.html#wdCreate">wdCreate</a></i>( )</b><hr><a name="wdStart"></a><p align=right><a href="rtnIndex.html"><i>Libraries : Routines</i></a></p></blockquote><h1><i>wdStart</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>wdStart</i>( )</strong> - start a watchdog timer</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS wdStart ( WDOG_ID wdId, /* watchdog ID */ int delay, /* delay count, in ticks */ FUNCPTR pRoutine, /* routine to call on time-out */ int parameter /* parameter with which to call routine */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine adds a watchdog timer to the system tick queue. Thespecified watchdog routine will be called from interrupt level afterthe specified number of ticks has elapsed. Watchdog timers may bestarted from interrupt level. <p>To replace either the timeout <i>delay</i> or the routine to be executed,call <b><i><a href="./wdLib.html#wdStart">wdStart</a></i>( )</b> again with the same <i>wdId</i>; only the most recent<b><i><a href="./wdLib.html#wdStart">wdStart</a></i>( )</b> on a given watchdog ID has any effect. (If yourapplication requires multiple watchdog routines, use <b><i><a href="./wdLib.html#wdCreate">wdCreate</a></i>( )</b> togenerate separate a watchdog ID for each.) To cancel a watchdogtimer before the specified tick count is reached, call <b><i><a href="./wdLib.html#wdCancel">wdCancel</a></i>( )</b>.<p>Watchdog timers execute only once, but some applications requireperiodically executing timers. To achieve this effect, the timerroutine itself must call <b><i><a href="./wdLib.html#wdStart">wdStart</a></i>( )</b> to restart the timer on eachinvocation.<p></blockquote><h4>WARNING</h4><blockquote><p>The watchdog routine runs in the context of thesystem-clock ISR; thus, it is subject to all ISR restrictions.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if the watchdog timer cannot be started.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./wdLib.html#top">wdLib</a></b>, <b><i><a href="./wdLib.html#wdCancel">wdCancel</a></i>( )</b><hr><a name="wdCancel"></a><p align=right><a href="rtnIndex.html"><i>Libraries : Routines</i></a></p></blockquote><h1><i>wdCancel</i>( )</h1> <blockquote></a></blockquote><h4>NAME</h4><blockquote> <p><strong><i>wdCancel</i>( )</strong> - cancel a currently counting watchdog</p></blockquote><h4>SYNOPSIS</h4><blockquote><p><pre>STATUS wdCancel ( WDOG_ID wdId /* ID of watchdog to cancel */ )</pre></blockquote><h4>DESCRIPTION</h4><blockquote><p>This routine cancels a currently running watchdog timer byzeroing its delay count. Watchdog timers may be canceled from interruptlevel.<p></blockquote><h4>RETURNS</h4><blockquote><p>OK, or ERROR if the watchdog timer cannot be canceled.<p></blockquote><h4>SEE ALSO</h4><blockquote><p><b><a href="./wdLib.html#top">wdLib</a></b>, <b><i><a href="./wdLib.html#wdStart">wdStart</a></i>( )</b></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -