⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c-trigger2.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<br><img border="0" alt="*" src="icons/note.gif"></td><td><hr><div class="CalloutCell"><a name="87395"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">NOTE:  </font></b></a>There is a major difference between the function used as a condition and the function used as a trigger action. The function used as a condition is executed, in line, during trigger evaluation, provided that the criteria for event, context, and object conditions have been satisfied. Unlike a trigger action function, a conditional function can not be deferred. You can check the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Safe</font></b> box for an action function to assure that it will not run within ISR or system context (see <a href="c-trigger2.html#84287"><i class="title">Specifying an Action</i></a>). There is no <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Safe</font></b> option for conditional functions, so you must write or call a function that can be safely executed within an ISR or system context.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout><dl class="margin"><dd><p class="Body"><a name="86200"> </a>For example, the following conditional function is invalid:</p><dl class="margin"><dd><pre class="Code2"><b><a name="86201">int condFunc (void)     {     if (vxTicks &gt;= (sysClkRateGet() * 60 * 60))         {         semTake (mySem);        /* semTake NOT ALLOWED in ISR context*/         printf ("The system has been up for more than an hour\n");                                   /* printf NOT ALLOWED in ISR context*/         return 1;         }     return 0;     }</a></b></pre></dl><dd><p class="Body"><a name="86202"> </a>This is because <b class="routine"><i class="routine">semTake</i></b><b>(&nbsp;)</b> must not be used in an ISR. In addition, due to the fact that trigger evaluation points are present throughout the VxWorks kernel, you can not use <b class="routine"><i class="routine">printf</i></b><b>(&nbsp;)</b> or <b class="routine"><i class="routine">logMsg</i></b><b>(&nbsp;)</b> in condition functions. (For information about which routines can safely be called from ISRs, see the <i class="title">VxWorks Programmer's Guide: Basic OS</i>.) This example could be corrected by making the <b class="routine"><i class="routine">printf</i></b><b>(&nbsp;)</b> into a trigger action function and making it <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Safe</font></b> to achieve the same result (see <a href="c-trigger3.html#85142">Example&nbsp;6-7</a>). </p></dl><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/note.gif"></td><td><hr><div class="CalloutCell"><a name="87416"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">NOTE:  </font></b></a>There is one exception to the rule that you can not use any function that may not be called from an ISR. If the combination of trigger qualifications set in the event, context, and object fields guarantees that they can only all be satisfied in task context (for example, by setting <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Context Matches</font></b> to <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Any Task</font></b> or <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Specific Task</font></b>). If this is the case, the condition function itself will only ever be executed in task context and can therefore contain anything you like.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84287">Specifying an Action </a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84289"> </a>The bottom section of the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Trigger Maintenance</font></b> dialog box allows you to specify what happens when your trigger fires. You can select <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">(no action)</font></b>, <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Start WV</font></b>, <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Stop WV</font></b>, or <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Call function</font></b>. If you select <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Call function</font></b>, the right two fields become active. Fill in the function name in the first field and an integer argument in the second field. </p><dd><p class="Body"><a name="85665"> </a>When selecting an action function for a trigger, the nature of the function to be called is important. It should be of the form:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85666">int actionFunc (int arg)     {     int returnValue;      /* function body */     return (returnValue);     }</a></b></pre></dl><dd><p class="Body"><a name="85667"> </a>The entry in the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Action</font></b> section of the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Trigger Maintenance</font></b> dialog box is of the form:<img class="figure" border="0" src="images/c-trigger5.gif"></p><dd><p class="Body"><a name="85669"> </a>where: </p></dl><dl class="margin"><dd><div class="Item"><a name="85670"> </a><b class="symbol_lc">&lt;function&gt;</b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent4"><a name="85671"> </a>is the name of the function to be called (<b class="routine"><i class="routine">actionFunc</i></b><b>(&nbsp;)</b> in the above example) </div><br></dl></dl></dl></dl><dd><div class="Item"><a name="85672"> </a><b class="symbol_lc">&lt;fn argument&gt;</b> </div><dl class="margin"><dl class="margin"><dl class="margin"><dl class="margin"><dd><div class="Indent4"><a name="85673"> </a>is an integer argument </div><br></dl></dl></dl></dl></dl><dl class="margin"><dd><p class="Body"><a name="85679"> </a>If the function contains calls to any function that is not permitted in ISR context, then the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Safe</font></b> box must be checked. (This is the default.) In this case, the function is not executed at the time when trigger evaluation is performed and found to be satisfied; instead it is added to a trigger work queue. Triggering automatically spawns a task called <b class="task">tActDef</b> whose responsibility it is to execute functions on the trigger work queue when the system is out of any critical region. If your application runs at a higher priority than <b class="task">tActDef</b>, you may have to adjust the priority if you want the trigger action to be executed.</p><dd><p class="Body"><a name="84290"> </a>The last item you can specify is what happens after the trigger fires. You may disable this trigger once it fires (the default), or allow it to remain active so that it will fire again if the conditions are met again. You can also chain another trigger to it, which is enabled when the first trigger fires. You must specify the second trigger by number, so you need to define it before you can select it from the drop-down menu. </p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84539">Saving a Trigger Configuration</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="86569"> </a>Once you have created a trigger configuration, you can save it to a file. This allows you to repeat a precise sequence and can be useful in troubleshooting. Click the (<img class="figure" border="0" src="images/c-trigger32.gif">) button and use the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">File Save</font></b> dialog box to choose a directory and file name for your configuration. </p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84542">Loading a Trigger Configuration File</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84297"> </a>A saved trigger configuration can be loaded using the <img class="figure" border="0" src="images/c-trigger21.gif"> button. Load the sample file <i class="textVariable">installDir</i><b class="file">/host/src/windview/samples/simpleCond.trg</b> by clicking the <img class="figure" border="0" src="images/c-triggera5.gif"> button and selecting it in the browse menu. Once this trigger has loaded, the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Triggering</font></b> window looks just like <a href="c-trigger2.html#86434">Figure&nbsp;6-1</a>; the window no longer says "None", but the trigger is not yet set. </p><dd><p class="Body"><a name="86575"> </a>Before you start triggering, you can review the trigger configuration you have loaded. Click on the <img class="figure" border="0" src="images/c-trigger7.gif"> button and select <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Trigger # 0</font></b> from the drop-down combo box. This displays the trigger specification and action that you loaded. (See <a href="c-trigger3.html#85707">Figure&nbsp;6-4</a>.) You can see that this sample trigger fires when variable <b class="symbol_lc">foo</b> takes the value 1. When that condition is met, <b class="routine"><i class="routine">printf</i></b><b>(&nbsp;)</b> is called with the value <b class="symbol_lc">helloString</b>. </p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84493">Starting Triggering</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84309"> </a>Once you have created your triggers, either by filling in the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Trigger Maintenance</font></b> dialog box or by loading a trigger configuration file, they must be compiled and downloaded to the target. Clicking the <img class="figure" border="0" src="images/c-trigger22.gif"> button compiles and downloads your trigger. The <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Target ID</font></b> changes from "not set" to a hexadecimal ID number and the status is "Armed." (See <a href="c-trigger2.html#84502">Figure&nbsp;6-3</a>). &nbsp;&nbsp;<div class="frame"><h4 class="EntityTitle"><a name="84502"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 6-3:&nbsp;&nbsp;Triggering Window With Active Triggers </font></a></h4><dl class="margin"><div class="Anchor"><a name="84507"> </a><img class="figure" border="0" src="images/c-trigger10.gif"></div></dl></div></p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84508">Stopping Triggering</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84529"> </a>Click the <img class="figure" border="0" src="images/c-trigger24.gif"> button to stop triggering. Your triggers still remain on the target but the code is not executed. </p></dl></dl><dl class="margin"><dd><p class="table" callout><table border="0" cellpadding="0" cellspacing="0"><tr valign="top"><td valign="top" width="40"><br><img border="0" alt="*" src="icons/note.gif"></td><td><hr><div class="CalloutCell"><a name="87436"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">NOTE:  </font></b></a>When you click <img class="figure" border="0" src="images/c-trigger25.gif"> to restart triggering, whatever configuration is currently in place on the host is downloaded and started. Even if it is the same configuration you loaded previously, all triggers are reset as they were initially. Execution does not continue from where it was when you stopped triggering.</div></td></tr><tr valign="top"><td></td><td><hr></td></tr><tr valign="middle"><td colspan="20"></td></tr></table></p callout></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H4"><i><a name="84528">Chaining Triggers</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84513"> </a>Chaining triggers provides a way to be sure of the order in which your triggers will fire. For instance, to use triggering to collect a WindView log you must define two triggers, one having the action to start WindView log collection and one with the action to stop WindView log collection. In most cases, these triggers are chained since the order of their firing is critical. </p><dd><p class="Body"><a name="84773"> </a>To chain triggers, define both triggers using the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Trigger Maintenance</font></b> dialog box. After defining both triggers, open the first one in the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Trigger Maintenance</font></b> dialog box and select the name of the second trigger in the last drop-down combo box.</p><dd><p class="Body"><a name="84692"> </a>Triggering provides a powerful mechanism for isolating the sequence that you wish WindView to capture for later analysis. If you can define two triggers to enclose the precise region of interest in your application, you can make the best use of both your system resources and your own time spent in analysis.</p></dl></dl><a name="foot"><hr></a><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="c-trigger.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-trigger.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-trigger1.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-trigger3.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p></body></html><!---by WRS Documentation (), Wind River Systems, Inc.    conversion tool:  Quadralay WebWorks Publisher 4.0.11    template:         CSS Template, Jan 1998 - Jefro --->

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -