📄 classcaninterface.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1"><title>Copley Motion Library: CanInterface Class Reference</title><link href="doxygen.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.4 --><div class="qindex"><a class="qindex" href="main.html">Main Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a></div><h1>CanInterface Class Reference</h1><!-- doxytag: class="CanInterface" --><a href="classCanInterface-members.html">List of all members.</a><hr><a name="_details"></a><h2>Detailed Description</h2>Abstract class used for low level interaction with CAN hardware. <p>This class contains methods that are used to open and close the CAN network adapter, as well as transmit and receive frames over the CAN network.<p>The base CanInterface class defines a standard minimal interface to the CAN network. This base class does not actually provide support for any hardware, rather it should be extended by a class that provides access to the actual CAN network adapter being used.<p><p>Definition at line <a class="el" href="CML__Can_8h-source.html#l00130">130</a> of file <a class="el" href="CML__Can_8h-source.html">CML_Can.h</a>.<table border="0" cellpadding="0" cellspacing="0"><tr><td></td></tr><tr><td colspan="2"><br><h2>Public Member Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a0"></a><!-- doxytag: member="CanInterface::CanInterface" ref="a0" args="(void)" --> </td><td class="memItemRight" valign="bottom"><a class="el" href="classCanInterface.html#a0">CanInterface</a> (void)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Default constructor for a CAN interface object. <br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classCanInterface.html#a1">CanInterface</a> (const char *port)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Standard constructor for the CAN interface object. <a href="#a1"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="a2"></a><!-- doxytag: member="CanInterface::~CanInterface" ref="a2" args="()" -->virtual </td><td class="memItemRight" valign="bottom"><a class="el" href="classCanInterface.html#a2">~CanInterface</a> ()</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Standard destructor for base CanInterface object. <br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">virtual const <a class="el" href="classError.html">Error</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classCanInterface.html#a3">SetName</a> (const char *name)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Set the name of the port. <a href="#a3"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">virtual const <a class="el" href="classError.html">Error</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classCanInterface.html#a4">Open</a> (void)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Open the CAN interface. <a href="#a4"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">virtual const <a class="el" href="classError.html">Error</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classCanInterface.html#a5">Close</a> (void)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Close the CAN interface. <a href="#a5"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">virtual const <a class="el" href="classError.html">Error</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classCanInterface.html#a6">SetBaud</a> (<a class="el" href="CML__Utils_8h.html#a9">int32</a> baud)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Set the CAN interface baud rate. <a href="#a6"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">const <a class="el" href="classError.html">Error</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classCanInterface.html#a7">Recv</a> (<a class="el" href="structCanFrame.html">CanFrame</a> &frame, <a class="el" href="CML__Utils_8h.html#a9">int32</a> timeout=-1)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Receive the next CAN frame. <a href="#a7"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">const <a class="el" href="classError.html">Error</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classCanInterface.html#a8">Xmit</a> (<a class="el" href="structCanFrame.html">CanFrame</a> &frame, <a class="el" href="CML__Utils_8h.html#a9">int32</a> timeout=0)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Write a CAN frame to the CAN network. <a href="#a8"></a><br></td></tr><tr><td colspan="2"><br><h2>Static Public Member Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">static const <a class="el" href="classError.html">Error</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classCanInterface.html#e0">ChkID</a> (<a class="el" href="CML__Utils_8h.html#a9">int32</a> id)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Check an ID to make sure it's valid. <a href="#e0"></a><br></td></tr><tr><td colspan="2"><br><h2>Protected Member Functions</h2></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">virtual const <a class="el" href="classError.html">Error</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classCanInterface.html#b0">RecvFrame</a> (<a class="el" href="structCanFrame.html">CanFrame</a> &frame, <a class="el" href="CML__Utils_8h.html#a9">int32</a> timeout)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Receive the next CAN frame. <a href="#b0"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">virtual const <a class="el" href="classError.html">Error</a> * </td><td class="memItemRight" valign="bottom"><a class="el" href="classCanInterface.html#b1">XmitFrame</a> (<a class="el" href="structCanFrame.html">CanFrame</a> &frame, <a class="el" href="CML__Utils_8h.html#a9">int32</a> timeout)</td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">Write a CAN frame to the CAN network. <a href="#b1"></a><br></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="b2"></a><!-- doxytag: member="CanInterface::FindPortNumber" ref="b2" args="(const char *id)" -->int </td><td class="memItemRight" valign="bottom"><a class="el" href="classCanInterface.html#b2">FindPortNumber</a> (const char *id)</td></tr><tr><td colspan="2"><br><h2>Protected Attributes</h2></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top">const char * </td><td class="memItemRight" valign="bottom"><a class="el" href="classCanInterface.html#p0">portName</a></td></tr><tr><td class="mdescLeft"> </td><td class="mdescRight">This string is initialized by the default constructor. <a href="#p0"></a><br></td></tr><tr><td colspan="2"><br><h2>Friends</h2></td></tr><tr><td class="memItemLeft" nowrap align="right" valign="top"><a class="anchor" name="n0"></a><!-- doxytag: member="CanInterface::CanOpen" ref="n0" args="" -->class </td><td class="memItemRight" valign="bottom"><a class="el" href="classCanInterface.html#n0">CanOpen</a></td></tr></table><hr><h2>Constructor & Destructor Documentation</h2><a class="anchor" name="a1"></a><!-- doxytag: member="CanInterface::CanInterface" ref="a1" args="(const char *port)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top"><a class="el" href="classCanInterface.html">CanInterface</a> </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">const char * </td> <td class="mdname1" valign="top" nowrap> <em>port</em> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap><code> [inline]</code></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Standard constructor for the CAN interface object. <p>The only thing that the constructor does is initialize the portName member variable to the value passed. <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>port</em> </td><td>A string that may be used to identify which port to open.</td></tr> </table></dl><p>Definition at line <a class="el" href="CML__Can_8h-source.html#l00149">149</a> of file <a class="el" href="CML__Can_8h-source.html">CML_Can.h</a>. </td> </tr></table><hr><h2>Member Function Documentation</h2><a class="anchor" name="e0"></a><!-- doxytag: member="CanInterface::ChkID" ref="e0" args="(int32 id)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">static const <a class="el" href="classError.html">Error</a>* ChkID </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="CML__Utils_8h.html#a9">int32</a> </td> <td class="mdname1" valign="top" nowrap> <em>id</em> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap><code> [inline, static]</code></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Check an ID to make sure it's valid. <p>To be valid, a message ID must either be an 11 bit standard ID, or a 28-bit extended ID. By convention, all extended ID's must have bit 29 set to identify them as such. <dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>id</em> </td><td>The ID to be checked </td></tr> </table></dl><dl compact><dt><b>Returns:</b></dt><dd>A pointer to an error object, or NULL on success.</dd></dl><p>Definition at line <a class="el" href="CML__Can_8h-source.html#l00193">193</a> of file <a class="el" href="CML__Can_8h-source.html">CML_Can.h</a>. </td> </tr></table><a class="anchor" name="a5"></a><!-- doxytag: member="CanInterface::Close" ref="a5" args="(void)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">virtual const <a class="el" href="classError.html">Error</a>* Close </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap><code> [inline, virtual]</code></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Close the CAN interface. <p><dl compact><dt><b>Returns:</b></dt><dd>A valid CAN error object</dd></dl><p>Definition at line <a class="el" href="CML__Can_8h-source.html#l00171">171</a> of file <a class="el" href="CML__Can_8h-source.html">CML_Can.h</a>. </td> </tr></table><a class="anchor" name="a4"></a><!-- doxytag: member="CanInterface::Open" ref="a4" args="(void)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">virtual const <a class="el" href="classError.html">Error</a>* Open </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top">void </td> <td class="mdname1" valign="top" nowrap> </td> <td class="md" valign="top"> ) </td> <td class="md" nowrap><code> [inline, virtual]</code></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Open the CAN interface. <p><dl compact><dt><b>Returns:</b></dt><dd>A valid CAN error object</dd></dl><p>Definition at line <a class="el" href="CML__Can_8h-source.html#l00165">165</a> of file <a class="el" href="CML__Can_8h-source.html">CML_Can.h</a>. </td> </tr></table><a class="anchor" name="a7"></a><!-- doxytag: member="CanInterface::Recv" ref="a7" args="(CanFrame &frame, int32 timeout=-1)" --><p><table class="mdTable" cellpadding="2" cellspacing="0"> <tr> <td class="mdRow"> <table cellpadding="0" cellspacing="0" border="0"> <tr> <td class="md" nowrap valign="top">const <a class="el" href="classError.html">Error</a> * Recv </td> <td class="md" valign="top">( </td> <td class="md" nowrap valign="top"><a class="el" href="structCanFrame.html">CanFrame</a> & </td> <td class="mdname" nowrap> <em>frame</em>, </td> </tr> <tr> <td class="md" nowrap align="right"></td> <td class="md"></td> <td class="md" nowrap><a class="el" href="CML__Utils_8h.html#a9">int32</a> </td> <td class="mdname" nowrap> <em>timeout</em> = <code>-1</code></td> </tr> <tr> <td class="md"></td> <td class="md">) </td> <td class="md" colspan="2"></td> </tr> </table> </td> </tr></table><table cellspacing="5" cellpadding="0" border="0"> <tr> <td> </td> <td><p>Receive the next CAN frame. <p>This is the public function used to read CAN messages from the network.<p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td valign="top"></td><td valign="top"><em>frame</em> </td><td>A reference to the frame object that will be filled by the read. </td></tr> <tr><td valign="top"></td><td valign="top"><em>timeout</em> </td><td>The timeout (ms) to wait for the frame. A timeout of 0 will return immediately if no data is available. A timeout of < 0 will wait forever. </td></tr> </table></dl><dl compact><dt><b>Returns:</b></dt><dd>A pointer to an error object, or NULL on success.</dd></dl><p>Definition at line <a class="el" href="Can_8cpp-source.html#l00049">49</a> of file <a class="el" href="Can_8cpp-source.html">Can.cpp</a>. </td> </tr></table>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -