cml__can_8h-source.html
来自「美国COPLEY驱动器,程序开发工具之一.」· HTML 代码 · 共 270 行 · 第 1/3 页
HTML
270 行
<a name="l00172"></a>00172 <span class="comment"></span><a name="l00173"></a>00173 <span class="comment"> /**</span><a name="l00174"></a>00174 <span class="comment"> Set the CAN interface baud rate</span><a name="l00175"></a>00175 <span class="comment"> @param baud In bits / second</span><a name="l00176"></a>00176 <span class="comment"> @return A valid CAN error object</span><a name="l00177"></a>00177 <span class="comment"> */</span><a name="l00178"></a><a class="code" href="classCanInterface.html#a6">00178</a> <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classCanInterface.html#a6">SetBaud</a>( <a class="code" href="CML__Utils_8h.html#a9">int32</a> baud ){ <span class="keywordflow">return</span> 0; }<a name="l00179"></a>00179 <a name="l00180"></a>00180 <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classCanInterface.html#a7">Recv</a>( <a class="code" href="structCanFrame.html">CanFrame</a> &frame, <a class="code" href="CML__Utils_8h.html#a9">int32</a> timeout=-1 );<a name="l00181"></a>00181 <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classCanInterface.html#a8">Xmit</a>( <a class="code" href="structCanFrame.html">CanFrame</a> &frame, <a class="code" href="CML__Utils_8h.html#a9">int32</a> timeout=0 );<a name="l00182"></a>00182 <a name="l00183"></a>00183 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00184"></a>00184 <span class="comment"> /**</span><a name="l00185"></a>00185 <span class="comment"> Check an ID to make sure it's valid. To be valid, a message ID</span><a name="l00186"></a>00186 <span class="comment"> must either be an 11 bit standard ID, or a 28-bit extended ID. By</span><a name="l00187"></a>00187 <span class="comment"> convention, all extended ID's must have bit 29 set to identify them</span><a name="l00188"></a>00188 <span class="comment"> as such.</span><a name="l00189"></a>00189 <span class="comment"> @param id The ID to be checked</span><a name="l00190"></a>00190 <span class="comment"> @return A pointer to an error object, or NULL on success.</span><a name="l00191"></a>00191 <span class="comment"> */</span><a name="l00192"></a>00192 <span class="comment">/***************************************************************************/</span><a name="l00193"></a><a class="code" href="classCanInterface.html#e0">00193</a> <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classCanInterface.html#e0">ChkID</a>( <a class="code" href="CML__Utils_8h.html#a9">int32</a> <span class="keywordtype">id</span> )<a name="l00194"></a>00194 {<a name="l00195"></a>00195 <span class="keywordflow">if</span>( !(<span class="keywordtype">id</span>&0xFFFFF800) )<a name="l00196"></a>00196 <span class="keywordflow">return</span> 0;<a name="l00197"></a>00197 <a name="l00198"></a>00198 <span class="keywordflow">if</span>( (<span class="keywordtype">id</span> & 0xE0000000) != 0x20000000 )<a name="l00199"></a>00199 <span class="keywordflow">return</span> &<a class="code" href="classCanError.html#s9">CanError::InvalidID</a>;<a name="l00200"></a>00200 <a name="l00201"></a>00201 <span class="keywordflow">return</span> 0;<a name="l00202"></a>00202 }<a name="l00203"></a>00203 <a name="l00204"></a>00204 <span class="keyword">protected</span>:<span class="comment"></span><a name="l00205"></a>00205 <span class="comment"> /// This string is initialized by the default constructor.</span><a name="l00206"></a>00206 <span class="comment"> /// It may be used to identify which CAN port to open, etc.</span><a name="l00207"></a><a class="code" href="classCanInterface.html#p0">00207</a> <span class="comment"></span> <span class="keyword">const</span> <span class="keywordtype">char</span> *<a class="code" href="classCanInterface.html#p0">portName</a>;<a name="l00208"></a>00208 <a name="l00209"></a>00209 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00210"></a>00210 <span class="comment"> /**</span><a name="l00211"></a>00211 <span class="comment"> Receive the next CAN frame. This is called by the public Recv function, and</span><a name="l00212"></a>00212 <span class="comment"> must be implemented by the actual CanInterace class. It handles the hardware</span><a name="l00213"></a>00213 <span class="comment"> specific details of reading a message from the network.</span><a name="l00214"></a>00214 <span class="comment"></span><a name="l00215"></a>00215 <span class="comment"> @param frame A reference to the frame object that will be filled by the read.</span><a name="l00216"></a>00216 <span class="comment"> @param timeout The timeout (ms) to wait for the frame. A timeout of 0 will</span><a name="l00217"></a>00217 <span class="comment"> return immediately if no data is available. A timeout of < 0 will </span><a name="l00218"></a>00218 <span class="comment"> wait forever.</span><a name="l00219"></a>00219 <span class="comment"> @return A pointer to an error object, or NULL on success.</span><a name="l00220"></a>00220 <span class="comment"> */</span><a name="l00221"></a>00221 <span class="comment">/***************************************************************************/</span><a name="l00222"></a>00222 <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classCanInterface.html#b0">RecvFrame</a>( <a class="code" href="structCanFrame.html">CanFrame</a> &frame, <a class="code" href="CML__Utils_8h.html#a9">int32</a> timeout );<a name="l00223"></a>00223 <a name="l00224"></a>00224 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00225"></a>00225 <span class="comment"> /**</span><a name="l00226"></a>00226 <span class="comment"> Write a CAN frame to the CAN network. This is called by the public Xmit </span><a name="l00227"></a>00227 <span class="comment"> function, and must be implemented by the actual CanInterface class. It</span><a name="l00228"></a>00228 <span class="comment"> handles the hardware specific details of writing a message to the network.</span><a name="l00229"></a>00229 <span class="comment"></span><a name="l00230"></a>00230 <span class="comment"> @param frame A reference to the frame to write.</span><a name="l00231"></a>00231 <span class="comment"> @param timeout The time to wait for the frame to be successfully sent.</span><a name="l00232"></a>00232 <span class="comment"> If the timeout is 0, the frame is written to the output queue and</span><a name="l00233"></a>00233 <span class="comment"> the function returns without waiting for it to be sent. If the </span><a name="l00234"></a>00234 <span class="comment"> timeout is <0 then the function will delay forever.</span><a name="l00235"></a>00235 <span class="comment"> @return A pointer to an error object, or NULL on success.</span><a name="l00236"></a>00236 <span class="comment"> */</span><a name="l00237"></a>00237 <span class="comment">/***************************************************************************/</span><a name="l00238"></a>00238 <span class="keyword">virtual</span> <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classCanInterface.html#b1">XmitFrame</a>( <a class="code" href="structCanFrame.html">CanFrame</a> &frame, <a class="code" href="CML__Utils_8h.html#a9">int32</a> timeout );<a name="l00239"></a>00239 <a name="l00240"></a>00240 <span class="keywordtype">int</span> <a class="code" href="classCanInterface.html#b2">FindPortNumber</a>( <span class="keyword">const</span> <span class="keywordtype">char</span> *<span class="keywordtype">id</span> );<a name="l00241"></a>00241 <a name="l00242"></a>00242 <span class="keyword">private</span>:<a name="l00243"></a>00243 <span class="keyword">class </span><a class="code" href="classCanOpen.html">CanOpen</a> *canOpenPtr;<a name="l00244"></a><a class="code" href="classCanInterface.html#n0">00244</a> <span class="keyword">friend</span> <span class="keyword">class </span><a class="code" href="classCanOpen.html">CanOpen</a>;<a name="l00245"></a>00245 };<a name="l00246"></a>00246 <a name="l00247"></a>00247 <a class="code" href="CML__Settings_8h.html#a12">CML_NAMESPACE_END</a>()<a name="l00248"></a>00248 <a name="l00249"></a>00249 #endif<a name="l00250"></a>00250 </pre></div><hr><address style="align: right;"><small>Copley Motion Library, Copyright (c) 2002-2003<a href="http://www.copleycontrols.com"><img src="CCC_logo.gif" alt="Copley Controls Corp." align="middle" border=0 ></a></small></address></body></html>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?