summaryrefslogtreecommitdiffstats
path: root/ucs2-lib/doc/html/_p__u_m__s_t_a_r_t_e_d__n_e_t.html
blob: ce6a62f7b0454c1038682cc5c89c9edba6813358 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>UNICENS: Networking Management</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico">
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="style_html.css" rel="stylesheet" type="text/css" />
<link href="inic.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="GlobalWrapper">
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr>
  <td><a href="index.html"><img alt="Logo" src="logo.png"/></a></td>
  <td>
   <div id="projectname">UNICENS&#160;<span id="projectnumber">V2.1.0-3491</span></div>
   <div id="projectbrief">User Manual and API Reference</div>
    <div id="searchbox">        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.2 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('_p__u_m__s_t_a_r_t_e_d__n_e_t.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Networking Management </div>  </div>
</div><!--header-->
<div class="contents">
<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>
<h1>Starting Up the Network</h1>
<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>
<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>
<div class="line">{</div>
<div class="line">    <span class="comment">/* Handle synchronous error here... */</span></div>
<div class="line">}</div>
</div><!-- fragment --><h1>Shutting Down the Network</h1>
<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>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> foo(<span class="keywordtype">void</span>)</div>
<div class="line">{</div>
<div class="line">    ...</div>
<div class="line"></div>
<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, &amp;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>
<div class="line">    {</div>
<div class="line">        <span class="comment">/* Handle synchronous error here... */</span></div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    ...</div>
<div class="line">}</div>
<div class="line"></div>
<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>
<div class="line">{</div>
<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>
<div class="line">    {</div>
<div class="line">        <span class="comment">/* Handle asynchronous error here... */</span></div>
<div class="line">    }</div>
<div class="line">}</div>
</div><!-- fragment --><h1>Observe Network Information</h1>
<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>
<h2>Network Status</h2>
<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>
<ul>
<li>Events</li>
<li>Availability</li>
<li>Availability Information</li>
<li>Availability Transition Cause</li>
<li>Node Address</li>
<li>Node Position</li>
<li>Max Position</li>
<li>Packet Bandwidth</li>
</ul>
<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>
<div class="line"></div>
<div class="line"><span class="comment">/* Register callback function for Network Status */</span></div>
<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> = &amp;App_OnUcsNetworkStatus;</div>
</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>
<div class="fragment"><div class="line"><span class="keywordtype">void</span> App_OnUcsNetworkStatus(uint16_t change_mask,</div>
<div class="line">                            uint16_t events,</div>
<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>
<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>
<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>
<div class="line">                            uint16_t node_address,</div>
<div class="line">                            uint8_t node_position,</div>
<div class="line">                            uint8_t max_position,</div>
<div class="line">                            uint16_t packet_bw)</div>
<div class="line">{</div>
<div class="line">    <span class="comment">/* Check update of third parameter &quot;availability&quot; */</span></div>
<div class="line">    <span class="keywordflow">if</span>((change_mask &amp; <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>
<div class="line">    {</div>
<div class="line">        <span class="keywordflow">switch</span>(availability)</div>
<div class="line">        {</div>
<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>
<div class="line">                (void)printf(<span class="stringliteral">&quot;\n\rNetwork Not Available\n\r&quot;</span>);</div>
<div class="line">                <span class="keywordflow">break</span>;</div>
<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>
<div class="line">                (void)printf(<span class="stringliteral">&quot;\n\rNetwork Available\n\r&quot;</span>);</div>
<div class="line">                <span class="keywordflow">break</span>;</div>
<div class="line">            <span class="keywordflow">default</span>:</div>
<div class="line">                <span class="keywordflow">break</span>;</div>
<div class="line">        }</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">/* Handle other Network Status parameters here! */</span></div>
<div class="line">}</div>
</div><!-- fragment --><h2>Notification Bitmasks</h2>
<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>
<p>This is an optional parameter. If the mask is not modified, notifications for all of the parameters are enabled.</p>
<p>The following example shows the usage of the notification bitmask.</p>
<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>
<div class="line"></div>
<div class="line"><span class="comment">/* Register callback function for Network Status */</span></div>
<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> = &amp;App_OnUcsNetworkStatus;</div>
<div class="line"><span class="comment">/* Notifications are enabled for parameters &quot;availability&quot; and &quot;node_position&quot; */</span></div>
<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>
</div><!-- fragment --><table  class="mns_ic_table">
<tr>
<td id="mns_ic_api">&#160;</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>
</table>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">&copy; 2017 Microchip Technology Inc. All rights reserved. <a href="http://www.microchip.com" target="_blank">www.microchip.com</a></li>
  </ul>
</div>
</body>
<!--
Generated on Mon Apr 3 2017 13:52:59 for UNICENS by
Doxygen 1.8.2
-->
<script language="javascript">
<!--
$('#MSearchResults').wrap('<div style="position: absolute; margin-left: 444px;"></div>');
-->
</script>
</html>