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

📄 c-wtx5.html

📁 vxworks相关论文
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"><html><head><link rel="STYLESHEET" type="text/css" href="wrs.css"><title>    The WTX Protocol   </title></head><body bgcolor="FFFFFF"><p class="navbar" align="right"><a href="index.html"><img border="0" alt="[Contents]" src="icons/contents.gif"></a><a href="c-wtx.html"><img border="0" alt="[Index]" src="icons/index.gif"></a><a href="c-wtx.html"><img border="0" alt="[Top]" src="icons/top.gif"></a><a href="c-wtx4.html"><img border="0" alt="[Prev]" src="icons/prev.gif"></a><a href="c-wtx6.html"><img border="0" alt="[Next]" src="icons/next.gif"></a></p><font face="Helvetica, sans-serif" class="sans"><h3 class="H2"><i><a name="85723">4.5  &nbsp;&nbsp;WTX C API</a></i></h3></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85725"> </a>This section introduces the WTX C API and provides an extensive code example. To experiment interactively with the WTX protocol, you may wish to work through the examples given in the <a href="c-wtx4.html#85250"><i class="title">4.4&nbsp;WTX Tcl API</i></a>. All WTX primitives are available to both APIs; thus a single detailed explanation of many items that are common to both the Tcl and C APIs is included in that section.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="85729">4.5.1  &nbsp;&nbsp;Description</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85731"> </a>The WTX C API is a binding of the WTX protocol to the ANSI C language. This allows C applications to call target server services. Every WTX protocol request is accessible through the WTX C interface.</p><dd><p class="Body"><a name="85732"> </a>There is a WTX C routine for each WTX protocol request. For example, the C function<b class="symbol_UC"> </b><b class="routine"><i class="routine">wtxMemRead</i></b><b>(&nbsp;)</b> corresponds to <b class="symbol_UC">WTX_MEM_READ</b>. The names of all WTX C routines are derived from the protocol request names according to the <i class="title">VxWorks Programmer's Guide: Coding Conventions</i>; in other words, underscores are removed and all words but the first are capitalized. </p><dd><p class="Body"><a name="85733"> </a>Each WTX C interface has an online reference entry under <b class="guiLabel"><font face="Helvetica, sans-serif" size="-1" class="sans">Tornado API Guide&gt;WTX C Library</font></b>. For information on the online reference material, see the <i class="title">Tornado User's Guide: Documentation Guide</i> and <i class="title">Tornado Getting Started</i>. All WTX C routines provide access to error status through <b class="routine"><i class="routine">wtxErrorGet</i></b><b>(&nbsp;)</b>. Throughout the remainder of this section, please refer to the reference entries for more information on the WTX C API.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="85735">4.5.2  &nbsp;&nbsp;WTX C API Archive</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85737"> </a>The WTX C API is archived in <i class="textVariable">installDir</i><b class="symbol_UC">/</b><b class="file">host/</b><i class="textVariable">hostType</i><b class="file">/lib/</b><b class="library">libwtxapi</b>. For a complete description of the use of this library to build a Tornado application see <a href="c-adding.html#84379"><i class="title">6.&nbsp;Adding Tools to Tornado</i></a>.</p></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="85741">4.5.3  &nbsp;&nbsp;Initializing a Session</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="89843"> </a>Before connecting an application to a particular target server you must initialize a session by calling <b class="routine"><i class="routine">wtxInitialize</i></b><b>(&nbsp;)</b>. The following code example initializes the specified session handle <b class="symbol_lc">wtxh</b>:</p><dl class="margin"><dd><pre class="Code2"><b><a name="89852">include "wtx.h" ... { HWTX                wtxh; ... /* initialize session */  if (wtxInitialize (&amp;wtxh) != OK)     return (ERROR);</a></b></pre></dl></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="85751">4.5.4  &nbsp;&nbsp;Obtaining Target Server Information</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85753"> </a>The Tornado registry maintains information about executing target servers. To find the list of registered target servers, you can call <b class="routine"><i class="routine">wtxInfoQ</i></b><b>(&nbsp;)</b>. To find information on a particular target server, you can call <b class="routine"><i class="routine">wtxInfo</i></b><b>(&nbsp;)</b>.</p><dl class="margin"><dd><pre class="Code2"><b><a name="89856">#include "wtx.h" ... WTX_DESC * pWtxDesc; /* target server information */ ... /* get information about a target server using the Tornado registry*/  if ((pWtxTsInfo = wtxInfo (wtxh, "tJohn")) == NULL)     return (ERROR); ...</a></b></pre></dl></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="85765">4.5.5  &nbsp;&nbsp;Attaching to a Target Server</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85767"> </a>An application must bind an initialized handle to an executing target server before the majority of the WTX C interface routines can be called. This can be accomplished calling <b class="routine"><i class="routine">wtxToolAttach</i></b><b>(&nbsp;)</b>, which takes an initialized <b class="symbol_UC">HWTX</b> handle, a regular expression, and a tool name. The regular expression must uniquely match a registered server for the binding to succeed. The tool name is the application name. The target server records it and reports this name to any tool that requests a list of attached tools with <b class="routine"><i class="routine">wtxTsInfoGet</i></b><b>(&nbsp;)</b>.</p><dl class="margin"><dd><pre class="Code2"><b><a name="89860">#include "wtx.h" ... /* attach to a target server */  if (wtxToolAttach (wtxh, "tJohn.*", "newapp") != OK)     {     wtxTerminate (wtxh); /* terminate session */     return (ERROR);     } ...</a></b></pre></dl></dl></dl><font face="Helvetica, sans-serif" class="sans"><h4 class="H3"><i><a name="85780">4.5.6  &nbsp;&nbsp;Application Example</a></i></h4></font><dl class="margin"><dl class="margin"><dd><p class="Body"><a name="85782"> </a>The following code examples demonstrate a complete application of the WTX C API. This application attaches to the specified target server and allocates and de-allocates target memory in an endless cycle. Note that the number of blocks to allocate is specified in a separate header file to conform to the Wind River coding conventions. For more information about compiling this example see <a href="c-adding.html#84379"><i class="title">6.&nbsp;Adding Tools to Tornado</i></a>.</p><dd><p class="Body"><a name="85786"> </a>To observe this application, start the target browser as well as the application:</p><dl class="margin"><dd><pre class="Code2"><b><a name="85787"></b><tt class="output">%</tt><b> wtxapp <i class="textVariable">targetServerName</i> &amp; </b><tt class="output">%</tt><b> browser <i class="textVariable">targetServerName</i> &amp;</a></b></pre></dl><dd><p class="Body"><a name="85789"> </a>If you place the browser in auto-update mode, the memory usage charts demonstrate the functionality of this simple application. On UNIX, if the Tornado launcher is running and your target server is selected, you can observe <b class="command">wtxapp</b> in the list of attached tools.</p></dl></dl><h4 class="EntityTitle"><a name="85790"><font face="Helvetica, sans-serif" size="-1" class="sans">Example 4-2:&nbsp;&nbsp;WTX C API Application </font></a></h4><dl class="margin"><dl class="margin"><dd><pre class="Code"><b><a name="89913">/* wtxapp.h - Simple WTX C API application header */  /* Copyright 1995-99 Wind River Systems, Inc. */  /* modification history -------------------- 01a,08apr95-99,p_m  written */  /* defines */  #define NUM_BLOCKS 26           /* number of memory blocks to allocate */</a></b></pre></dl><dl class="margin"><dd><hr class="Line"></dl><dl class="margin"><dd><pre class="Code"><b><a name="90790">/* wtxapp.c - Simple WTX C API application */  /* Copyright 1995-99 Wind River Systems, Inc. */  /* modification history -------------------- 01c,05jan99,fle doc : made it documentable 01b,11jul95,p_m  implemented better error reporting and added comments                                  added signals handling  01a,08apr95,p_m  written */  #include &lt;signal.h&gt; #include &lt;stdio.h&gt; #include "host.h" #include "wtx.h" #include "wtxapp.h"  /*  DESCRIPTION  This is a simple program demonstrating the use of the WTX C API.  It  attaches to a target server and allocates and free memory from the target memory pool managed by the target server.  SEE ALSO tgtsvr, wtxtcl, wtx, WTX */  /* defines */  /* globals */  HWTX            &nbsp;wtxh;                   /* WTX API handle */ TGT_ADDR_T      &nbsp;blockTab[NUM_BLOCKS];   /* allocated blocks table */  /* forward declarations */  LOCAL STATUS    &nbsp;&nbsp;&nbsp;&nbsp;wtxAppSigInit (void);  #ifdef WIN32     BOOL WINAPI &nbsp;&nbsp;&nbsp;&nbsp;wtxAppSigHandler (DWORD dwCtrlType); #else     LOCAL void &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wtxAppSigHandler (int signal, int code); #endif LOCAL void &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;wtxAppTerminate (void);  /*********************************************************************** * * wtxapp - Simple WTX application example * * This is a simple WTX tool example showing the WTX C API.  It * allocates blocks of memory from the target-server-managed target memory * pool then frees them.  The effects of this program can be easily * viewed by using a Tornado browser attached to the same target server. 

⌨️ 快捷键说明

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