1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns="http://www.w3.org/1999/xhtml">
4 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5 <meta http-equiv="X-UA-Compatible" content="IE=9"/>
6 <title>UNICENS: Networking Management</title>
7 <link href="tabs.css" rel="stylesheet" type="text/css"/>
8 <link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
9 <script type="text/javascript" src="jquery.js"></script>
10 <script type="text/javascript" src="dynsections.js"></script>
11 <link href="navtree.css" rel="stylesheet" type="text/css"/>
12 <script type="text/javascript" src="resize.js"></script>
13 <script type="text/javascript" src="navtree.js"></script>
14 <script type="text/javascript">
15 $(document).ready(initResizable);
17 <link href="search/search.css" rel="stylesheet" type="text/css"/>
18 <script type="text/javascript" src="search/search.js"></script>
19 <script type="text/javascript">
20 $(document).ready(function() { searchBox.OnSelectItem(0); });
22 <link href="style_html.css" rel="stylesheet" type="text/css" />
23 <link href="inic.css" rel="stylesheet" type="text/css"/>
26 <div class="GlobalWrapper">
27 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
29 <table cellspacing="0" cellpadding="0">
32 <td><a href="index.html"><img alt="Logo" src="logo.png"/></a></td>
34 <div id="projectname">UNICENS <span id="projectnumber">V2.1.0-3491</span></div>
35 <div id="projectbrief">User Manual and API Reference</div>
36 <div id="searchbox"> <div id="MSearchBox" class="MSearchBoxInactive">
38 <img id="MSearchSelect" src="search/mag_sel.png"
39 onmouseover="return searchBox.OnSearchSelectShow()"
40 onmouseout="return searchBox.OnSearchSelectHide()"
42 <input type="text" id="MSearchField" value="Search" accesskey="S"
43 onfocus="searchBox.OnSearchFieldFocus(true)"
44 onblur="searchBox.OnSearchFieldFocus(false)"
45 onkeyup="searchBox.OnSearchFieldChange(event)"/>
46 </span><span class="right">
47 <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
56 <!-- end header part -->
57 <!-- Generated by Doxygen 1.8.2 -->
58 <script type="text/javascript">
59 var searchBox = new SearchBox("searchBox", "search",false,'Search');
62 <div id="side-nav" class="ui-resizable side-nav-resizable">
64 <div id="nav-tree-contents">
65 <div id="nav-sync" class="sync"></div>
68 <div id="splitbar" style="-moz-user-select:none;"
69 class="ui-resizable-handle">
72 <script type="text/javascript">
73 $(document).ready(function(){initNavTree('_p__u_m__s_t_a_r_t_e_d__n_e_t.html','');});
75 <div id="doc-content">
76 <!-- window showing the filter options -->
77 <div id="MSearchSelectWindow"
78 onmouseover="return searchBox.OnSearchSelectShow()"
79 onmouseout="return searchBox.OnSearchSelectHide()"
80 onkeydown="return searchBox.OnSearchSelectKey(event)">
81 <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark"> </span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark"> </span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark"> </span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark"> </span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark"> </span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark"> </span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark"> </span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark"> </span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark"> </span>Pages</a></div>
83 <!-- iframe showing the search results (closed by default) -->
84 <div id="MSearchResultsWindow">
85 <iframe src="javascript:void(0)" frameborder="0"
86 name="MSearchResults" id="MSearchResults">
91 <div class="headertitle">
92 <div class="title">Networking Management </div> </div>
94 <div class="contents">
95 <div class="textblock"><p>The UNICENS API provides functions that are used to startup and to shutdown the network. It also provides callback functions to observe MOST network parameters.</p>
96 <h1>Starting Up the Network</h1>
97 <p>For starting up the MOST network out of the off state, function <a class="el" href="group___g___u_c_s___n_e_t_ga83c2e74a4cc216aa10d7c6a1a517d459.html#ga83c2e74a4cc216aa10d7c6a1a517d459" title="Starts up the MOST Network.">Ucs_Network_Startup()</a> must be called. An optional callback function can be used, to monitor the result of the startup command. The callback must adhere to function signature <a class="el" href="group___g___u_c_s___i_n_i_t___a_n_d___s_r_v___t_y_p_e_s_gaa573fbe79f76f263a17e51d6de99036d.html#gaa573fbe79f76f263a17e51d6de99036d">Ucs_StdResultCb_t</a>. In the following example, the result callback is not used.</p>
98 <div class="fragment"><div class="line"><span class="keywordflow">if</span> (<a class="code" href="group___g___u_c_s___n_e_t_ga83c2e74a4cc216aa10d7c6a1a517d459.html#ga83c2e74a4cc216aa10d7c6a1a517d459" title="Starts up the MOST Network.">Ucs_Network_Startup</a>(ucs_inst_ptr, 52U, 0xFFFFU, NULL) != <a class="code" href="group___g___u_c_s___i_n_i_t___a_n_d___s_r_v___t_y_p_e_s_ga886138f5d13e84ffaa3df5769830e1cd.html#gga886138f5d13e84ffaa3df5769830e1cda3fb51656e17ee4802f23706f35e349bc" title="Operation successfully completed.">UCS_RET_SUCCESS</a>)</div>
99 <div class="line">{</div>
100 <div class="line"> <span class="comment">/* Handle synchronous error here... */</span></div>
101 <div class="line">}</div>
102 </div><!-- fragment --><h1>Shutting Down the Network</h1>
103 <p>For shutting down the MOST network, function <a class="el" href="group___g___u_c_s___n_e_t_ga1e49ce81a42f09bcecc2202edc2b93fc.html#ga1e49ce81a42f09bcecc2202edc2b93fc" title="Switches of the MOST Network.">Ucs_Network_Shutdown()</a> must be called. It also provides an optional callback function to monitor the result of the shutdown command. The callback must adhere to function signature <a class="el" href="group___g___u_c_s___i_n_i_t___a_n_d___s_r_v___t_y_p_e_s_gaa573fbe79f76f263a17e51d6de99036d.html#gaa573fbe79f76f263a17e51d6de99036d">Ucs_StdResultCb_t</a>. The following example uses <a class="el" href="group___g___u_c_s___n_e_t_ga1e49ce81a42f09bcecc2202edc2b93fc.html#ga1e49ce81a42f09bcecc2202edc2b93fc" title="Switches of the MOST Network.">Ucs_Network_Shutdown()</a> in combination with the optional result callback.</p>
104 <div class="fragment"><div class="line"><span class="keywordtype">void</span> foo(<span class="keywordtype">void</span>)</div>
105 <div class="line">{</div>
106 <div class="line"> ...</div>
107 <div class="line"></div>
108 <div class="line"> <span class="keywordflow">if</span>(<a class="code" href="group___g___u_c_s___n_e_t_ga1e49ce81a42f09bcecc2202edc2b93fc.html#ga1e49ce81a42f09bcecc2202edc2b93fc" title="Switches of the MOST Network.">Ucs_Network_Shutdown</a>(ucs_inst_ptr, &App_OnNwShutdownResult) != <a class="code" href="group___g___u_c_s___i_n_i_t___a_n_d___s_r_v___t_y_p_e_s_ga886138f5d13e84ffaa3df5769830e1cd.html#gga886138f5d13e84ffaa3df5769830e1cda3fb51656e17ee4802f23706f35e349bc" title="Operation successfully completed.">UCS_RET_SUCCESS</a>)</div>
109 <div class="line"> {</div>
110 <div class="line"> <span class="comment">/* Handle synchronous error here... */</span></div>
111 <div class="line"> }</div>
112 <div class="line"> </div>
113 <div class="line"> ...</div>
114 <div class="line">}</div>
115 <div class="line"></div>
116 <div class="line"><span class="keywordtype">void</span> App_OnNwShutdownResult(<a class="code" href="struct_ucs___std_result__t.html" title="Standard result structure which provides fields for detailed status and error information.">Ucs_StdResult_t</a> result, <span class="keywordtype">void</span> *user_ptr)</div>
117 <div class="line">{</div>
118 <div class="line"> <span class="keywordflow">if</span>(result.<a class="code" href="struct_ucs___std_result__t_a02d8eefc721a797ac87f5030774972ef.html#a02d8eefc721a797ac87f5030774972ef" title="Result/Error code.">code</a> != <a class="code" href="group___g___u_c_s___i_n_i_t___a_n_d___s_r_v___t_y_p_e_s_gac844b77cf41aef663782bc0b43d3540c.html#ggac844b77cf41aef663782bc0b43d3540cae19d5a51de78bbf903a108a4e36a0fdf" title="Operation successfully completed.">UCS_RES_SUCCESS</a>)</div>
119 <div class="line"> {</div>
120 <div class="line"> <span class="comment">/* Handle asynchronous error here... */</span></div>
121 <div class="line"> }</div>
122 <div class="line">}</div>
123 </div><!-- fragment --><h1>Observe Network Information</h1>
124 <p>The UNICENS API provides further information about the <em>Network Status</em>. For this purpose the application has the possibility to register the following callback function during initialization time.</p>
125 <h2>Network Status</h2>
126 <p>Callback function <code>net.cb_fptr()</code> reports information about the <em>Network Status</em>. The function must adhere to signature <a class="el" href="group___g___u_c_s___n_e_t_gaf195e8ae396bc1fc358666fe50bf3f51.html#gaf195e8ae396bc1fc358666fe50bf3f51">Ucs_Network_StatusCb_t</a>. The following parameters are reported.</p>
129 <li>Availability</li>
130 <li>Availability Information</li>
131 <li>Availability Transition Cause</li>
132 <li>Node Address</li>
133 <li>Node Position</li>
134 <li>Max Position</li>
135 <li>Packet Bandwidth</li>
137 <div class="fragment"><div class="line"><a class="code" href="struct_ucs___init_data__t.html" title="UNICENS initialization structure used by function Ucs_Init().">Ucs_InitData_t</a> init_data;</div>
138 <div class="line"></div>
139 <div class="line"><span class="comment">/* Register callback function for Network Status */</span></div>
140 <div class="line">init_data.<a class="code" href="struct_ucs___init_data__t_aa220785601aa16c0e0aff52f44380719.html#aa220785601aa16c0e0aff52f44380719" title="Network initialization data.">network</a>.<a class="code" href="struct_ucs___network___init_data__t_ae9d2b9f86bdd3a9667a348eb2b75da12.html#ae9d2b9f86bdd3a9667a348eb2b75da12" title="Network Status.">status</a>.<a class="code" href="struct_ucs___network___status__t_a08f6acd8566e419c7017fc1874720223.html#a08f6acd8566e419c7017fc1874720223" title="Network Status callback function. This function reports information on the whole network.">cb_fptr</a> = &App_OnUcsNetworkStatus;</div>
141 </div><!-- fragment --><p>If at least one of the <em>Network Status</em> parameters has been changed, this function is invoked. The first argument of the function is a bitmask. This mask indicates which parameters have been changed since the last function call. If a bit is set the corresponding parameter has been changed since the last update. A simple example implementation is shown below.</p>
142 <div class="fragment"><div class="line"><span class="keywordtype">void</span> App_OnUcsNetworkStatus(uint16_t change_mask,</div>
143 <div class="line"> uint16_t events,</div>
144 <div class="line"> <a class="code" href="group___g___u_c_s___n_e_t___t_y_p_e_s_ga6b0bec2ae9e4d0fb93eefd65752f0c74.html#ga6b0bec2ae9e4d0fb93eefd65752f0c74" title="MOST Network Availability.">Ucs_Network_Availability_t</a> availability,</div>
145 <div class="line"> <a class="code" href="group___g___u_c_s___n_e_t___t_y_p_e_s_gad5ed0387c3c156602826d50ce94c9df7.html#gad5ed0387c3c156602826d50ce94c9df7" title="MOST Network Availability Information.">Ucs_Network_AvailInfo_t</a> avail_info,</div>
146 <div class="line"> <a class="code" href="group___g___u_c_s___n_e_t___t_y_p_e_s_gab4ec40bf01de998abc4f2ae34c26ac46.html#gab4ec40bf01de998abc4f2ae34c26ac46" title="MOST Network Availability Transition Cause.">Ucs_Network_AvailTransCause_t</a> avail_trans_cause,</div>
147 <div class="line"> uint16_t node_address,</div>
148 <div class="line"> uint8_t node_position,</div>
149 <div class="line"> uint8_t max_position,</div>
150 <div class="line"> uint16_t packet_bw)</div>
151 <div class="line">{</div>
152 <div class="line"> <span class="comment">/* Check update of third parameter "availability" */</span></div>
153 <div class="line"> <span class="keywordflow">if</span>((change_mask & <a class="code" href="group___g___u_c_s___n_e_t___t_y_p_e_s_ga779e730fce488874146678e0971f52a8.html#gga779e730fce488874146678e0971f52a8a707f78e3b7a58f4ce21f31da38e00573" title="Flag for notification of availability changes.">UCS_NW_M_AVAIL</a>) != 0U)</div>
154 <div class="line"> {</div>
155 <div class="line"> <span class="keywordflow">switch</span>(availability)</div>
156 <div class="line"> {</div>
157 <div class="line"> <span class="keywordflow">case</span> <a class="code" href="group___g___u_c_s___n_e_t___t_y_p_e_s_ga6b0bec2ae9e4d0fb93eefd65752f0c74.html#gga6b0bec2ae9e4d0fb93eefd65752f0c74afb1201dc3a998b9d4f9c48d5978d9ffc" title="MOST network is not available.">UCS_NW_NOT_AVAILABLE</a>:</div>
158 <div class="line"> (void)printf(<span class="stringliteral">"\n\rNetwork Not Available\n\r"</span>);</div>
159 <div class="line"> <span class="keywordflow">break</span>;</div>
160 <div class="line"> <span class="keywordflow">case</span> <a class="code" href="group___g___u_c_s___n_e_t___t_y_p_e_s_ga6b0bec2ae9e4d0fb93eefd65752f0c74.html#gga6b0bec2ae9e4d0fb93eefd65752f0c74a37fb322b410de335478f6bed31cd33f1" title="MOST network is available.">UCS_NW_AVAILABLE</a>:</div>
161 <div class="line"> (void)printf(<span class="stringliteral">"\n\rNetwork Available\n\r"</span>);</div>
162 <div class="line"> <span class="keywordflow">break</span>;</div>
163 <div class="line"> <span class="keywordflow">default</span>:</div>
164 <div class="line"> <span class="keywordflow">break</span>;</div>
165 <div class="line"> }</div>
166 <div class="line"> }</div>
167 <div class="line"> </div>
168 <div class="line"> <span class="comment">/* Handle other Network Status parameters here! */</span></div>
169 <div class="line">}</div>
170 </div><!-- fragment --><h2>Notification Bitmasks</h2>
171 <p>Furthermore, it is possible to configure the notifications for <em>Network Status</em>. When initializing the corresponding callback function pointer, the user has the possibility to specify a <em>notification bitmask</em>. This mask indicates for which parameters the notification shall be enabled. If such a bit is set and the corresponding parameter has been changed the notification callback function is invoked.</p>
172 <p>This is an optional parameter. If the mask is not modified, notifications for all of the parameters are enabled.</p>
173 <p>The following example shows the usage of the notification bitmask.</p>
174 <div class="fragment"><div class="line"><a class="code" href="struct_ucs___init_data__t.html" title="UNICENS initialization structure used by function Ucs_Init().">Ucs_InitData_t</a> init_data;</div>
175 <div class="line"></div>
176 <div class="line"><span class="comment">/* Register callback function for Network Status */</span></div>
177 <div class="line">init_data.<a class="code" href="struct_ucs___init_data__t_aa220785601aa16c0e0aff52f44380719.html#aa220785601aa16c0e0aff52f44380719" title="Network initialization data.">network</a>.<a class="code" href="struct_ucs___network___init_data__t_ae9d2b9f86bdd3a9667a348eb2b75da12.html#ae9d2b9f86bdd3a9667a348eb2b75da12" title="Network Status.">status</a>.<a class="code" href="struct_ucs___network___status__t_a08f6acd8566e419c7017fc1874720223.html#a08f6acd8566e419c7017fc1874720223" title="Network Status callback function. This function reports information on the whole network.">cb_fptr</a> = &App_OnUcsNetworkStatus;</div>
178 <div class="line"><span class="comment">/* Notifications are enabled for parameters "availability" and "node_position" */</span></div>
179 <div class="line">init_data.<a class="code" href="struct_ucs___init_data__t_aa220785601aa16c0e0aff52f44380719.html#aa220785601aa16c0e0aff52f44380719" title="Network initialization data.">network</a>.<a class="code" href="struct_ucs___network___init_data__t_ae9d2b9f86bdd3a9667a348eb2b75da12.html#ae9d2b9f86bdd3a9667a348eb2b75da12" title="Network Status.">status</a>.<a class="code" href="struct_ucs___network___status__t_ae7a618bc7852c52001d0756913c545c8.html#ae7a618bc7852c52001d0756913c545c8" title="Notification mask (optional parameter; default value: 0xFFFF) Indicates for which parameters the noti...">notification_mask</a> = (<a class="code" href="group___g___u_c_s___n_e_t___t_y_p_e_s_ga779e730fce488874146678e0971f52a8.html#gga779e730fce488874146678e0971f52a8a707f78e3b7a58f4ce21f31da38e00573" title="Flag for notification of availability changes.">UCS_NW_M_AVAIL</a>) | (<a class="code" href="group___g___u_c_s___n_e_t___t_y_p_e_s_ga779e730fce488874146678e0971f52a8.html#gga779e730fce488874146678e0971f52a8a89bb7ec3c55087159a8a19b5e9cc7fa0" title="Flag for notification of node position changes.">UCS_NW_M_NODE_POS</a>);</div>
180 </div><!-- fragment --><table class="mns_ic_table">
182 <td id="mns_ic_api"> </td><td>See also <em>API Reference</em>, section <a class="el" href="struct_ucs___network___status__t.html" title="Structure holds parameters for the notification of the Network Status.">Ucs_Network_Status_t</a>. </td></tr>
184 </div></div><!-- contents -->
185 </div><!-- doc-content -->
186 <!-- start footer part -->
187 <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
189 <li class="footer">© 2017 Microchip Technology Inc. All rights reserved. <a href="http://www.microchip.com" target="_blank">www.microchip.com</a></li>
194 Generated on Mon Apr 3 2017 13:52:59 for UNICENS by
197 <script language="javascript">
199 $('#MSearchResults').wrap('<div style="position: absolute; margin-left: 444px;"></div>');