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

📄 sdo_8cpp-source.html

📁 美国COPLEY驱动器,程序开发工具之一.
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<!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: SDO.cpp Source File</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&nbsp;Page</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical&nbsp;List</a> | <a class="qindex" href="annotated.html">Class&nbsp;List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Class&nbsp;Members</a> | <a class="qindex" href="globals.html">File&nbsp;Members</a></div><div class="nav"><a class="el" href="dir_000000.html">c</a></div><h1>SDO.cpp</h1><a href="SDO_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/************************************************************/</span><a name="l00002"></a>00002 <span class="comment">/*                                                          */</span><a name="l00003"></a>00003 <span class="comment">/*  Copley Motion Libraries                                 */</span><a name="l00004"></a>00004 <span class="comment">/*                                                          */</span><a name="l00005"></a>00005 <span class="comment">/*  Author: Stephen Glow                                    */</span><a name="l00006"></a>00006 <span class="comment">/*                                                          */</span><a name="l00007"></a>00007 <span class="comment">/*  Copyright (c) 2002-2005 Copley Controls Corp.           */</span><a name="l00008"></a>00008 <span class="comment">/*                          http://www.copleycontrols.com   */</span><a name="l00009"></a>00009 <span class="comment">/*                                                          */</span><a name="l00010"></a>00010 <span class="comment">/************************************************************/</span><a name="l00011"></a>00011 <span class="comment"></span><a name="l00012"></a>00012 <span class="comment">/**</span><a name="l00013"></a>00013 <span class="comment">\file</span><a name="l00014"></a>00014 <span class="comment"></span><a name="l00015"></a>00015 <span class="comment">This file contains the code used to implement the CANopen SDO objects.</span><a name="l00016"></a>00016 <span class="comment">*/</span><a name="l00017"></a>00017 <a name="l00018"></a>00018 <span class="preprocessor">#include "<a class="code" href="CML_8h.html">CML.h</a>"</span><a name="l00019"></a>00019 <a name="l00020"></a>00020 <a class="code" href="CML__Settings_8h.html#a13">CML_NAMESPACE_USE</a>();<a name="l00021"></a>00021 <a name="l00022"></a>00022 <span class="comment">/**************************************************</span><a name="l00023"></a>00023 <span class="comment">* SDO Error objects</span><a name="l00024"></a>00024 <span class="comment">**************************************************/</span><a name="l00025"></a>00025 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, NoAbortCode,       <span class="stringliteral">"SDO Aborted"</span> );<a name="l00026"></a>00026 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Togglebit,         <span class="stringliteral">"SDO Abort: Toggle bit not alternated."</span> );<a name="l00027"></a>00027 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Timeout,           <span class="stringliteral">"SDO Abort: SDO Protocol timed out."</span> );<a name="l00028"></a>00028 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Bad_scs,           <span class="stringliteral">"SDO Abort: Client/Server command specifier not known."</span> );<a name="l00029"></a>00029 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Block_size,        <span class="stringliteral">"SDO Abort: Invalid block size."</span> );<a name="l00030"></a>00030 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Block_seq,         <span class="stringliteral">"SDO Abort: Invalid block sequence."</span> );<a name="l00031"></a>00031 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Block_crc,         <span class="stringliteral">"SDO Abort: CRC error."</span> );<a name="l00032"></a>00032 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Memory,            <span class="stringliteral">"SDO Abort: Memory allocation error."</span> );<a name="l00033"></a>00033 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Access,            <span class="stringliteral">"SDO Abort: Unsupported object access."</span> );<a name="l00034"></a>00034 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Writeonly,         <span class="stringliteral">"SDO Abort: Object is write only."</span> );<a name="l00035"></a>00035 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Readonly,          <span class="stringliteral">"SDO Abort: Object is read only."</span> );<a name="l00036"></a>00036 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Bad_object,        <span class="stringliteral">"SDO Abort: Object does not exist."</span> );<a name="l00037"></a>00037 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Pdo_map,           <span class="stringliteral">"SDO Abort: Object can not be mapped to PDO."</span> );<a name="l00038"></a>00038 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Pdo_length,        <span class="stringliteral">"SDO Abort: PDO length would be exceeded."</span> );<a name="l00039"></a>00039 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Bad_param,         <span class="stringliteral">"SDO Abort: General parameter error."</span> );<a name="l00040"></a>00040 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Incompatible,      <span class="stringliteral">"SDO Abort: General internal incompatibility."</span> );<a name="l00041"></a>00041 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Hardware,          <span class="stringliteral">"SDO Abort: Hardware failure."</span> );<a name="l00042"></a>00042 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Bad_length,        <span class="stringliteral">"SDO Abort: Data length incorrect."</span> );<a name="l00043"></a>00043 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Too_long,          <span class="stringliteral">"SDO Abort: Data length too long."</span> );<a name="l00044"></a>00044 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Too_short,         <span class="stringliteral">"SDO Abort: Data length too short."</span> );<a name="l00045"></a>00045 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Subindex,          <span class="stringliteral">"SDO Abort: Sub-index does not exist."</span> );<a name="l00046"></a>00046 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Param_range,       <span class="stringliteral">"SDO Abort: Parameter range error."</span> );<a name="l00047"></a>00047 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Param_high,        <span class="stringliteral">"SDO Abort: Parameter value too high."</span> );<a name="l00048"></a>00048 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Param_low,         <span class="stringliteral">"SDO Abort: Parameter value too low."</span> );<a name="l00049"></a>00049 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Min_max,           <span class="stringliteral">"SDO Abort: Maximum value less then minimum."</span> );<a name="l00050"></a>00050 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, General,           <span class="stringliteral">"SDO Abort: General error."</span> );<a name="l00051"></a>00051 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Transfer,          <span class="stringliteral">"SDO Abort: Data transfer error."</span> );<a name="l00052"></a>00052 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Transfer_Local,    <span class="stringliteral">"SDO Abort: Data transfer error; local control."</span> );<a name="l00053"></a>00053 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Transfer_State,    <span class="stringliteral">"SDO Abort: Data transfer error; device state."</span> );<a name="l00054"></a>00054 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, OD_Gen_Fail,       <span class="stringliteral">"SDO Abort: Object dictionary generation failure."</span> );<a name="l00055"></a>00055 <a class="code" href="CML__Error_8h.html#a0">CML_NEW_ERROR</a>( <a class="code" href="classSDO__Error.html">SDO_Error</a>, Unknown,           <span class="stringliteral">"SDO Abort: Unknown abort code"</span> );<a name="l00056"></a>00056 <a name="l00057"></a>00057 <a name="l00058"></a>00058 <span class="comment">/**************************************************</span><a name="l00059"></a>00059 <span class="comment">* States used internally by the SDO object</span><a name="l00060"></a>00060 <span class="comment">**************************************************/</span><a name="l00061"></a><a class="code" href="SDO_8cpp.html#a0">00061</a> <span class="preprocessor">#define SDO_STATE_IDLE                   0     // SDO is idle</span><a name="l00062"></a><a class="code" href="SDO_8cpp.html#a1">00062</a> <span class="preprocessor"></span><span class="preprocessor">#define SDO_STATE_DONE                   1     // SDO transfer finished</span><a name="l00063"></a><a class="code" href="SDO_8cpp.html#a2">00063</a> <span class="preprocessor"></span><span class="preprocessor">#define SDO_STATE_SENT_DNLD_INIT         2     // SDO download init was sent.</span><a name="l00064"></a><a class="code" href="SDO_8cpp.html#a3">00064</a> <span class="preprocessor"></span><span class="preprocessor">#define SDO_STATE_SENT_DOWNLOAD          3     // SDO download sent</span><a name="l00065"></a><a class="code" href="SDO_8cpp.html#a4">00065</a> <span class="preprocessor"></span><span class="preprocessor">#define SDO_STATE_SENT_UPLD_INIT         4     // SDO upload init was sent.</span><a name="l00066"></a><a class="code" href="SDO_8cpp.html#a5">00066</a> <span class="preprocessor"></span><span class="preprocessor">#define SDO_STATE_SENT_UPLD_RQST         5     // SDO upload request sent</span><a name="l00067"></a><a class="code" href="SDO_8cpp.html#a6">00067</a> <span class="preprocessor"></span><span class="preprocessor">#define SDO_STATE_SENT_BUP_INIT          6     // Block upload init sent</span><a name="l00068"></a><a class="code" href="SDO_8cpp.html#a7">00068</a> <span class="preprocessor"></span><span class="preprocessor">#define SDO_STATE_SENT_BUP_START         7     // Block upload data expected</span><a name="l00069"></a><a class="code" href="SDO_8cpp.html#a8">00069</a> <span class="preprocessor"></span><span class="preprocessor">#define SDO_STATE_SENT_BUP_LAST          8     // Block upload done</span><a name="l00070"></a>00070 <span class="preprocessor"></span><a name="l00071"></a><a class="code" href="SDO_8cpp.html#a9">00071</a> <span class="preprocessor">#define SDO_STATE_SEND_ABORT            10     // I need to send an abort</span><a name="l00072"></a><a class="code" href="SDO_8cpp.html#a10">00072</a> <span class="preprocessor"></span><span class="preprocessor">#define SDO_STATE_SEND_DATA             11     // I need to send more data</span><a name="l00073"></a><a class="code" href="SDO_8cpp.html#a11">00073</a> <span class="preprocessor"></span><span class="preprocessor">#define SDO_STATE_SEND_UPLD             12     // I need to send an upload request</span><a name="l00074"></a><a class="code" href="SDO_8cpp.html#a12">00074</a> <span class="preprocessor"></span><span class="preprocessor">#define SDO_STATE_SEND_BUP_START        13     // I need to send a block upload start</span><a name="l00075"></a><a class="code" href="SDO_8cpp.html#a13">00075</a> <span class="preprocessor"></span><span class="preprocessor">#define SDO_STATE_SEND_BUP_NEXT         14     // request next block upload block</span><a name="l00076"></a><a class="code" href="SDO_8cpp.html#a14">00076</a> <span class="preprocessor"></span><span class="preprocessor">#define SDO_STATE_SEND_BUP_LAST         15     // Last block has been uploaded</span><a name="l00077"></a><a class="code" href="SDO_8cpp.html#a15">00077</a> <span class="preprocessor"></span><span class="preprocessor">#define SDO_STATE_SEND_BUP_DONE         16     // Upload finished, send confirmation</span><a name="l00078"></a>00078 <span class="preprocessor"></span><a name="l00079"></a>00079 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00080"></a>00080 <span class="comment">/**</span><a name="l00081"></a>00081 <span class="comment">Initialize the CANopen Service Data Object (SDO).</span><a name="l00082"></a>00082 <span class="comment">@param canOpen The CANopen network object that this SDO is associated with</span><a name="l00083"></a>00083 <span class="comment">@param xmit The COB ID used when transmitting SDO frames</span><a name="l00084"></a>00084 <span class="comment">@param recv The COB ID used for receive frames</span><a name="l00085"></a>00085 <span class="comment">@param to The timeout (milliseconds) for use with this SDO.</span><a name="l00086"></a>00086 <span class="comment">*/</span><a name="l00087"></a>00087 <span class="comment">/***************************************************************************/</span><a name="l00088"></a><a class="code" href="classSDO.html#a2">00088</a> <a class="code" href="classSDO.html#a0">SDO::SDO</a>( <a class="code" href="classCanOpen.html">CanOpen</a> &amp;canOpen, <a class="code" href="CML__Utils_8h.html#a10">uint32</a> xmit, <a class="code" href="CML__Utils_8h.html#a10">uint32</a> recv, <a class="code" href="CML__Utils_8h.html#a9">int32</a> to )<a name="l00089"></a>00089 {<a name="l00090"></a>00090    <a class="code" href="classSDO.html#a3">Init</a>( canOpen, xmit, recv, to );<a name="l00091"></a>00091 }<a name="l00092"></a>00092 <a name="l00093"></a>00093 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00094"></a>00094 <span class="comment">/**</span><a name="l00095"></a>00095 <span class="comment">Initialize a CANopen Service Data Object (SDO).</span><a name="l00096"></a>00096 <span class="comment">@param canOpen The CANopen network object that this SDO is associated with</span><a name="l00097"></a>00097 <span class="comment">@param xmit The COB ID used when transmitting SDO frames</span><a name="l00098"></a>00098 <span class="comment">@param recv The COB ID used for receive frames</span><a name="l00099"></a>00099 <span class="comment">@param to The timeout (milliseconds) for use with this SDO.</span><a name="l00100"></a>00100 <span class="comment">@return A valid CANopen error object</span><a name="l00101"></a>00101 <span class="comment">*/</span><a name="l00102"></a>00102 <span class="comment">/***************************************************************************/</span><a name="l00103"></a><a class="code" href="classSDO.html#a3">00103</a> <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *<a class="code" href="classSDO.html#a3">SDO::Init</a>( <a class="code" href="classCanOpen.html">CanOpen</a> &amp;canOpen, <a class="code" href="CML__Utils_8h.html#a10">uint32</a> xmit, <a class="code" href="CML__Utils_8h.html#a10">uint32</a> recv, <a class="code" href="CML__Utils_8h.html#a9">int32</a> to)<a name="l00104"></a>00104 {<a name="l00105"></a>00105    xmitID = xmit;<a name="l00106"></a>00106    state = <a class="code" href="SDO_8cpp.html#a0">SDO_STATE_IDLE</a>;<a name="l00107"></a>00107    timeout = to;<a name="l00108"></a>00108    lastErr = 0;<a name="l00109"></a>00109 <a name="l00110"></a>00110    <a class="code" href="classSDO.html#o0">blkUpldOK</a> = <span class="keyword">false</span>;<a name="l00111"></a>00111    <a class="code" href="classSDO.html#o1">blkDnldOK</a> = <span class="keyword">false</span>;

⌨️ 快捷键说明

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