a00156.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
  3. <title>uIP 1.0: Timer library</title>
  4. <link href="doxygen.css" rel="stylesheet" type="text/css">
  5. <link href="tabs.css" rel="stylesheet" type="text/css">
  6. </head><body>
  7. <!-- Generated by Doxygen 1.4.6 -->
  8. <div class="tabs">
  9. <ul>
  10. <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
  11. <li><a href="modules.html"><span>Modules</span></a></li>
  12. <li><a href="classes.html"><span>Data&nbsp;Structures</span></a></li>
  13. <li><a href="files.html"><span>Files</span></a></li>
  14. <li><a href="examples.html"><span>Examples</span></a></li>
  15. </ul></div>
  16. <h1>Timer library</h1><hr><a name="_details"></a><h2>Detailed Description</h2>
  17. The timer library provides functions for setting, resetting and restarting timers, and for checking if a timer has expired.
  18. <p>
  19. An application must "manually" check if its timers have expired; this is not done automatically.<p>
  20. A timer is declared as a <code>struct</code> <code>timer</code> and all access to the timer is made by a pointer to the declared timer.<p>
  21. <dl compact><dt><b>Note:</b></dt><dd>The timer library uses the <a class="el" href="a00157.html">Clock library</a> to measure time. Intervals should be specified in the format used by the clock library. </dd></dl>
  22. <p>
  23. <table border="0" cellpadding="0" cellspacing="0">
  24. <tr><td></td></tr>
  25. <tr><td colspan="2"><br><h2>Files</h2></td></tr>
  26. <tr><td class="memItemLeft" nowrap align="right" valign="top">file &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00130.html">timer.h</a></td></tr>
  27. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Timer library header file. <br></td></tr>
  28. <p>
  29. <tr><td class="memItemLeft" nowrap align="right" valign="top">file &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00129.html">timer.c</a></td></tr>
  30. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Timer library implementation. <br></td></tr>
  31. <p>
  32. <tr><td colspan="2"><br><h2>Data Structures</h2></td></tr>
  33. <tr><td class="memItemLeft" nowrap align="right" valign="top">struct &nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00087.html">timer</a></td></tr>
  34. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">A timer. <a href="a00087.html#_details">More...</a><br></td></tr>
  35. <tr><td colspan="2"><br><h2>Functions</h2></td></tr>
  36. <tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00156.html#g6614d96fdfcd95c95ec6e6f63071ff51">timer_set</a> (struct <a class="el" href="a00087.html">timer</a> *t, clock_time_t interval)</td></tr>
  37. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Set a timer. <a href="#g6614d96fdfcd95c95ec6e6f63071ff51"></a><br></td></tr>
  38. <tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00156.html#gedaf3e48c2b04229b85455fb948468d6">timer_reset</a> (struct <a class="el" href="a00087.html">timer</a> *t)</td></tr>
  39. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Reset the timer with the same interval. <a href="#gedaf3e48c2b04229b85455fb948468d6"></a><br></td></tr>
  40. <tr><td class="memItemLeft" nowrap align="right" valign="top">void&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00156.html#gcb807bd57e5489b386b876af5c1f163a">timer_restart</a> (struct <a class="el" href="a00087.html">timer</a> *t)</td></tr>
  41. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Restart the timer from the current point in time. <a href="#gcb807bd57e5489b386b876af5c1f163a"></a><br></td></tr>
  42. <tr><td class="memItemLeft" nowrap align="right" valign="top">int&nbsp;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00156.html#g6d71dececfce707c668e6257aad5906e">timer_expired</a> (struct <a class="el" href="a00087.html">timer</a> *t)</td></tr>
  43. <tr><td class="mdescLeft">&nbsp;</td><td class="mdescRight">Check if a timer has expired. <a href="#g6d71dececfce707c668e6257aad5906e"></a><br></td></tr>
  44. </table>
  45. <hr><h2>Function Documentation</h2>
  46. <a class="anchor" name="g6d71dececfce707c668e6257aad5906e"></a><!-- doxytag: member="timer.h::timer_expired" ref="g6d71dececfce707c668e6257aad5906e" args="(struct timer *t)" --><p>
  47. <table class="mdTable" cellpadding="2" cellspacing="0">
  48. <tr>
  49. <td class="mdRow">
  50. <table cellpadding="0" cellspacing="0" border="0">
  51. <tr>
  52. <td class="md" nowrap valign="top">int timer_expired </td>
  53. <td class="md" valign="top">(&nbsp;</td>
  54. <td class="md" nowrap valign="top">struct <a class="el" href="a00087.html">timer</a> *&nbsp;</td>
  55. <td class="mdname1" valign="top" nowrap> <em>t</em> </td>
  56. <td class="md" valign="top">&nbsp;)&nbsp;</td>
  57. <td class="md" nowrap></td>
  58. </tr>
  59. </table>
  60. </td>
  61. </tr>
  62. </table>
  63. <table cellspacing="5" cellpadding="0" border="0">
  64. <tr>
  65. <td>
  66. &nbsp;
  67. </td>
  68. <td>
  69. <p>
  70. Check if a timer has expired.
  71. <p>
  72. This function tests if a timer has expired and returns true or false depending on its status.<p>
  73. <dl compact><dt><b>Parameters:</b></dt><dd>
  74. <table border="0" cellspacing="2" cellpadding="0">
  75. <tr><td valign="top"></td><td valign="top"><em>t</em>&nbsp;</td><td>A pointer to the timer</td></tr>
  76. </table>
  77. </dl>
  78. <dl compact><dt><b>Returns:</b></dt><dd>Non-zero if the timer has expired, zero otherwise. </dd></dl>
  79. <dl compact><dt><b>Examples: </b></dt><dd>
  80. <a class="el" href="a00048.html#a26">dhcpc.c</a>, <a class="el" href="a00042.html#a77">example-mainloop-with-arp.c</a>, and <a class="el" href="a00043.html#a94">example-mainloop-without-arp.c</a>.</dl>
  81. <p>
  82. Definition at line <a class="el" href="a00195.html#l00121">121</a> of file <a class="el" href="a00195.html">timer.c</a>.
  83. <p>
  84. References <a class="el" href="a00157.html#ge5b7160f2e653725ba5e2024c3cb7bff">clock_time()</a>, <a class="el" href="a00196.html#l00076">interval</a>, and <a class="el" href="a00196.html#l00075">start</a>. </td>
  85. </tr>
  86. </table>
  87. <a class="anchor" name="gedaf3e48c2b04229b85455fb948468d6"></a><!-- doxytag: member="timer.h::timer_reset" ref="gedaf3e48c2b04229b85455fb948468d6" args="(struct timer *t)" --><p>
  88. <table class="mdTable" cellpadding="2" cellspacing="0">
  89. <tr>
  90. <td class="mdRow">
  91. <table cellpadding="0" cellspacing="0" border="0">
  92. <tr>
  93. <td class="md" nowrap valign="top">void timer_reset </td>
  94. <td class="md" valign="top">(&nbsp;</td>
  95. <td class="md" nowrap valign="top">struct <a class="el" href="a00087.html">timer</a> *&nbsp;</td>
  96. <td class="mdname1" valign="top" nowrap> <em>t</em> </td>
  97. <td class="md" valign="top">&nbsp;)&nbsp;</td>
  98. <td class="md" nowrap></td>
  99. </tr>
  100. </table>
  101. </td>
  102. </tr>
  103. </table>
  104. <table cellspacing="5" cellpadding="0" border="0">
  105. <tr>
  106. <td>
  107. &nbsp;
  108. </td>
  109. <td>
  110. <p>
  111. Reset the timer with the same interval.
  112. <p>
  113. This function resets the timer with the same interval that was given to the <a class="el" href="a00156.html#g6614d96fdfcd95c95ec6e6f63071ff51">timer_set()</a> function. The start point of the interval is the exact time that the timer last expired. Therefore, this function will cause the timer to be stable over time, unlike the timer_rester() function.<p>
  114. <dl compact><dt><b>Parameters:</b></dt><dd>
  115. <table border="0" cellspacing="2" cellpadding="0">
  116. <tr><td valign="top"></td><td valign="top"><em>t</em>&nbsp;</td><td>A pointer to the timer.</td></tr>
  117. </table>
  118. </dl>
  119. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="a00156.html#gcb807bd57e5489b386b876af5c1f163a">timer_restart()</a> </dd></dl>
  120. <dl compact><dt><b>Examples: </b></dt><dd>
  121. <a class="el" href="a00042.html#a78">example-mainloop-with-arp.c</a>, and <a class="el" href="a00043.html#a95">example-mainloop-without-arp.c</a>.</dl>
  122. <p>
  123. Definition at line <a class="el" href="a00195.html#l00084">84</a> of file <a class="el" href="a00195.html">timer.c</a>.
  124. <p>
  125. References <a class="el" href="a00196.html#l00076">interval</a>, and <a class="el" href="a00196.html#l00075">start</a>. </td>
  126. </tr>
  127. </table>
  128. <a class="anchor" name="gcb807bd57e5489b386b876af5c1f163a"></a><!-- doxytag: member="timer.h::timer_restart" ref="gcb807bd57e5489b386b876af5c1f163a" args="(struct timer *t)" --><p>
  129. <table class="mdTable" cellpadding="2" cellspacing="0">
  130. <tr>
  131. <td class="mdRow">
  132. <table cellpadding="0" cellspacing="0" border="0">
  133. <tr>
  134. <td class="md" nowrap valign="top">void timer_restart </td>
  135. <td class="md" valign="top">(&nbsp;</td>
  136. <td class="md" nowrap valign="top">struct <a class="el" href="a00087.html">timer</a> *&nbsp;</td>
  137. <td class="mdname1" valign="top" nowrap> <em>t</em> </td>
  138. <td class="md" valign="top">&nbsp;)&nbsp;</td>
  139. <td class="md" nowrap></td>
  140. </tr>
  141. </table>
  142. </td>
  143. </tr>
  144. </table>
  145. <table cellspacing="5" cellpadding="0" border="0">
  146. <tr>
  147. <td>
  148. &nbsp;
  149. </td>
  150. <td>
  151. <p>
  152. Restart the timer from the current point in time.
  153. <p>
  154. This function restarts a timer with the same interval that was given to the <a class="el" href="a00156.html#g6614d96fdfcd95c95ec6e6f63071ff51">timer_set()</a> function. The timer will start at the current time.<p>
  155. <dl compact><dt><b>Note:</b></dt><dd>A periodic timer will drift if this function is used to reset it. For preioric timers, use the <a class="el" href="a00156.html#gedaf3e48c2b04229b85455fb948468d6">timer_reset()</a> function instead.</dd></dl>
  156. <dl compact><dt><b>Parameters:</b></dt><dd>
  157. <table border="0" cellspacing="2" cellpadding="0">
  158. <tr><td valign="top"></td><td valign="top"><em>t</em>&nbsp;</td><td>A pointer to the timer.</td></tr>
  159. </table>
  160. </dl>
  161. <dl compact><dt><b>See also:</b></dt><dd><a class="el" href="a00156.html#gedaf3e48c2b04229b85455fb948468d6">timer_reset()</a> </dd></dl>
  162. <p>
  163. Definition at line <a class="el" href="a00195.html#l00104">104</a> of file <a class="el" href="a00195.html">timer.c</a>.
  164. <p>
  165. References <a class="el" href="a00157.html#ge5b7160f2e653725ba5e2024c3cb7bff">clock_time()</a>, and <a class="el" href="a00196.html#l00075">start</a>. </td>
  166. </tr>
  167. </table>
  168. <a class="anchor" name="g6614d96fdfcd95c95ec6e6f63071ff51"></a><!-- doxytag: member="timer.h::timer_set" ref="g6614d96fdfcd95c95ec6e6f63071ff51" args="(struct timer *t, clock_time_t interval)" --><p>
  169. <table class="mdTable" cellpadding="2" cellspacing="0">
  170. <tr>
  171. <td class="mdRow">
  172. <table cellpadding="0" cellspacing="0" border="0">
  173. <tr>
  174. <td class="md" nowrap valign="top">void timer_set </td>
  175. <td class="md" valign="top">(&nbsp;</td>
  176. <td class="md" nowrap valign="top">struct <a class="el" href="a00087.html">timer</a> *&nbsp;</td>
  177. <td class="mdname" nowrap> <em>t</em>, </td>
  178. </tr>
  179. <tr>
  180. <td class="md" nowrap align="right"></td>
  181. <td class="md"></td>
  182. <td class="md" nowrap>clock_time_t&nbsp;</td>
  183. <td class="mdname" nowrap> <em>interval</em></td>
  184. </tr>
  185. <tr>
  186. <td class="md"></td>
  187. <td class="md">)&nbsp;</td>
  188. <td class="md" colspan="2"></td>
  189. </tr>
  190. </table>
  191. </td>
  192. </tr>
  193. </table>
  194. <table cellspacing="5" cellpadding="0" border="0">
  195. <tr>
  196. <td>
  197. &nbsp;
  198. </td>
  199. <td>
  200. <p>
  201. Set a timer.
  202. <p>
  203. This function is used to set a timer for a time sometime in the future. The function <a class="el" href="a00156.html#g6d71dececfce707c668e6257aad5906e">timer_expired()</a> will evaluate to true after the timer has expired.<p>
  204. <dl compact><dt><b>Parameters:</b></dt><dd>
  205. <table border="0" cellspacing="2" cellpadding="0">
  206. <tr><td valign="top"></td><td valign="top"><em>t</em>&nbsp;</td><td>A pointer to the timer </td></tr>
  207. <tr><td valign="top"></td><td valign="top"><em>interval</em>&nbsp;</td><td>The interval before the timer expires. </td></tr>
  208. </table>
  209. </dl>
  210. <dl compact><dt><b>Examples: </b></dt><dd>
  211. <a class="el" href="a00048.html#a22">dhcpc.c</a>, <a class="el" href="a00042.html#a62">example-mainloop-with-arp.c</a>, and <a class="el" href="a00043.html#a86">example-mainloop-without-arp.c</a>.</dl>
  212. <p>
  213. Definition at line <a class="el" href="a00195.html#l00064">64</a> of file <a class="el" href="a00195.html">timer.c</a>.
  214. <p>
  215. References <a class="el" href="a00157.html#ge5b7160f2e653725ba5e2024c3cb7bff">clock_time()</a>, <a class="el" href="a00196.html#l00076">interval</a>, and <a class="el" href="a00196.html#l00075">start</a>. </td>
  216. </tr>
  217. </table>
  218. <hr size="1"><address style="align: right;"><small>Generated on Mon Jun 12 10:23:02 2006 for uIP 1.0 by&nbsp;
  219. <a href="http://www.doxygen.org/index.html">
  220. <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>
  221. </body>
  222. </html>