c-trigger3.html
来自「vxworks相关论文」· HTML 代码 · 共 529 行 · 第 1/2 页
HTML
529 行
<div class="Anchor"><a name="88665"> </a><img class="figure" border="0" src="images/c-triggera28.gif"></div></dl></div></p><dd><p class="Body"><a name="87645"> </a>Specifying the conditional as <b class="symbol_lc">foo2</b> has a less obvious result than <a href="c-trigger3.html#88687">Example 6-3</a>. As in that example, the left-hand side evaluates to the current value of <b class="symbol_lc">foo1</b>,which is 30 decimal. Since the "foo1" is not numeric, the system performs a symbol table lookup every time the conditional clause is evaluated to find the identifier <b class="symbol_lc">foo1</b> and resolve it to an address. </p><dd><p class="Body"><a name="85841"> </a>The symbol table is searched for <b class="symbol_lc">foo2</b> and 0x0a001004 is obtained. Because <b class="symbol_lc"><operand 2></b> is interpreted as a numeric constant, not the address of a variable, the value 0x0a001004 is used for the comparison. </p><dd><p class="Body"><a name="85842"> </a>The comparison therefore resolves to 30 >= 0x0a001004 which is clearly not satisfied at this time. Thus, if you were expecting the expression to be evaluated as 30 >= 20, your trigger would not fire when expected.<div class="frame"><h4 class="EntityTitle"><a name="88634"><font face="Helvetica, sans-serif" size="-1" class="sans">Example 6-5: Evaluating a Conditional Using a Pointer to a String</font></a></h4><dl class="margin"><div class="Anchor"><a name="88636"> </a><img class="figure" border="0" src="images/c-trigger27.gif"></div></dl></div></p><dd><p class="Body"><a name="87655"> </a>Specifying the conditional as shown is similar to <a href="c-trigger3.html#88663">Example 6-4</a>, except that we treat the identifier <b class="symbol_lc">pFoo</b> a pointer. As before a symbol table lookup is performed for both sides of the operator. <b class="symbol_lc">pFoo</b> yields address 0x0a001008 and is de-referenced to value 0x0a001000. <b class="symbol_lc">foo1</b> yields 0x0a001000, which is treated as an integer constant. The comparison therefore resolves to 0x0a001000 == 0x0a001000 and the condition is satisfied. If you expected the expression to be evaluated as 0x0a001000 == 30, your trigger would have fired unexpectedly.</p></dl><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="86875">Using <b class="routine"><i class="routine">trgEvent</i></b><b>( )</b> to Start and Stop Logging</a></i></h5></font><dl class="margin"><dd><p class="Body"><a name="86880"> </a><a href="c-trigger3.html#85806">Example 6-6</a> shows a highly simplified situation which allows you to experiment with starting and stopping WindView using the triggering facility. </p></dl></dl><h4 class="EntityTitle"><a name="85806"><font face="Helvetica, sans-serif" size="-1" class="sans">Example 6-6: Controlling WindView Logging with Triggers</font></a></h4><dl class="margin"><dl class="margin"><p><ol class="List"><li value="1."><a name="84387"> </a>Click <img class="figure" border="0" src="images/c-trigger15.gif"> to start triggering and then <img class="figure" border="0" src="images/c-trigger16.gif"> to open the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Trigger Maintenance</font></b> dialog box. </li></ol></p><p><ol class="List"><li value="2."><a name="84388"> </a>Create a trigger #0 which is initially enabled, with event matches equal to <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">User Event</font></b>, event ID equal to 40010, and action equal to <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">StartWV</font></b>.</li></ol></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="87537"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">NOTE: </font></b></a>The event ID must be in the range 40000-65535.</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"><p><ol class="List"><li value="3."><a name="84389"> </a>Create a trigger #1 which is initially disabled (uncheck the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Enabled</font></b> box), with event matches equal to <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">User Event</font></b>, event ID equal to 40020, and action equal to <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">StopWV</font></b>.</li></ol></p><p><ol class="List"><li value="4."><a name="84390"> </a>Double-click on trigger #0 in the Triggering list to reopen the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Trigger Maintenance</font></b> dialog box and chain trigger #1 to trigger #0. </li></ol></p><p><ol class="List"><li value="5."><a name="84394"> </a>Click <img class="figure" border="0" src="images/c-trigger17.gif"> to download your triggers.</li></ol></p><p><ol class="List"><li value="6."><a name="84395"> </a>Open a WindSh and create a user event:</li></ol></p><dl class="margin"><dl class="margin"><dd><pre class="Code3"><b><a name="84396">% trgEvent(40010)</a></b></pre></dl></dl><dl class="margin"><dd><div class="Indent"><a name="84397"> </a>The <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Control</font></b> window will show that WindView logging has started. If necessary, click <img class="figure" border="0" src="images/c-trigger37.gif"> to update the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Control</font></b> window.</div><br></dl><p><ol class="List"><li value="7."><a name="84398"> </a>Create another user event:</li></ol></p><dl class="margin"><dl class="margin"><dd><pre class="Code3"><b><a name="84399">% trgEvent(40020)</a></b></pre></dl></dl><dl class="margin"><dd><div class="Indent"><a name="84400"> </a>You will see that WindView logging stops.</div><br></dl><p><ol class="List"><li value="8."><a name="84407"> </a>Click <img class="figure" border="0" src="images/c-trigger18.gif"> to stop triggering and (if you are using deferred upload mode) <img class="figure" border="0" src="images/c-trigger19.gif"> to upload your logfile data. </li></ol></p></dl></dl><dl class="margin"><dd><font face="Helvetica, sans-serif" size="-1" class="sans"><h5 class="HU"><i><a name="86289">Specifying Trigger Actions</a></i></h5></font><dl class="margin"><dd><p class="Body"><a name="86290"> </a><a href="c-trigger3.html#85142">Example 6-7</a> shows how to write an action function for your trigger.</p></dl></dl><h4 class="EntityTitle"><a name="85142"><font face="Helvetica, sans-serif" size="-1" class="sans">Example 6-7: Specifying an Action with a Trigger</font></a></h4><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85209"> </a><a href="c-trigger3.html#85867">Example 6-1</a> showed an example of a very simple action resulting from a conditional trigger. The same result could have been obtained by writing an action function. While this would not be an efficient solution in this simple case, the function would allow you to specify additional processing if it were needed at this point. A simple action function could be written as follows: </p><dl class="margin"><dd><pre class="Code2"><b><a name="85627">int myActionFunc (int parm) { printf ("Trigger fired\n"); /* any other code you desire */ return 1; /* return value is ignored */ }</a></b></pre></dl><dd><p class="Body"><a name="85218"> </a>Compile and download the code onto the target. 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> window, enter: <img class="figure" border="0" src="images/c-triggera15.gif"></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="87556"><b class="symbol_UC"><font face="Helvetica, sans-serif" size="-1" class="sans">NOTE: </font></b></a>The <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Safe</font></b> box must be checked since a call to <b class="routine"><i class="routine">printf</i></b><b>( )</b> is made within <b class="routine"><i class="routine">myActionFunc</i></b><b>( )</b>.</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="84408">Other Uses of Triggering</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="84409"> </a>Triggering is a flexible diagnostic tool in its own right. It has applications that extend beyond starting and stopping WindView logging. The methods described in previous sections can serve as building blocks for more complex actions by specifying a function call as the trigger action. </p></dl><dl class="margin"><p class="listspace"><ul class="Bullet" type="disc"><li><a name="86637"> </a>You can call a user-defined function that collects appropriate diagnostic information at the time the trigger fires. One way to do this would be to use <b class="routine"><i class="routine">wvEvent</i></b><b>( )</b> (see <a href="c-datacol4.html#84858"><i class="title">The wvEvent( ) Routine</i></a>).</li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="84414"> </a>You can specify <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">(no action)</font></b> when you need to fire the first in a sequence of chained triggers, where the first trigger has no other purpose than to enable another trigger. </li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="86634"> </a>You can use a trigger as a counting mechanism. If <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">(no action) </font></b>is set and the trigger is not disabled after firing, you can update the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Triggering</font></b> window using <img class="figure" border="0" src="images/c-trigger34.gif"> or <img class="figure" border="0" src="images/c-trigger35.gif"> and see a count of the number of times the trigger has fired under <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Status</font></b>. <div class="frame"><h4 class="EntityTitle"><a name="86676"><font face="Helvetica, sans-serif" size="-1" class="sans">Figure 5: Trigger Used to Count semGives</font></a></h4><dl class="margin"><div class="Anchor"><a name="86678"> </a><img class="figure" border="0" src="images/c-trigger36.gif"></div></dl></div></li></ul></p><p class="listspace"><ul class="Bullet" type="disc"><li><a name="86658"> </a>You can determine that a specific event has occurred and the associated trigger fired by using <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">(no action)</font></b>, disabling the trigger after it fires, and examining the <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Triggering</font></b> window to see when it has fired.</li></ul></p></dl><dl class="margin"><dd><p class="Body"><a name="85088"> </a></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-trigger2.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-datacol.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 + =
减小字号Ctrl + -
显示快捷键?