ampfw_8cpp-source.html
来自「美国COPLEY驱动器,程序开发工具之一.」· HTML 代码 · 共 239 行 · 第 1/2 页
HTML
239 行
<!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: AmpFW.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 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><div class="nav"><a class="el" href="dir_000000.html">c</a></div><h1>AmpFW.cpp</h1><a href="AmpFW_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">/** \file</span><a name="l00013"></a>00013 <span class="comment">This file contains code used to update an amplifier's firmware over the</span><a name="l00014"></a>00014 <span class="comment">CANopen network.</span><a name="l00015"></a>00015 <span class="comment"></span><a name="l00016"></a>00016 <span class="comment">The firmware update protocol is a non-standard protocol which uses CAN</span><a name="l00017"></a>00017 <span class="comment">messages with the same IDs as the node's CANopen SDO protocol. These </span><a name="l00018"></a>00018 <span class="comment">message IDs were used because they are fixed for a given node ID.</span><a name="l00019"></a>00019 <span class="comment">*/</span><a name="l00020"></a>00020 <a name="l00021"></a>00021 <span class="preprocessor">#include "<a class="code" href="CML__Copley_8h.html">CML_Copley.h</a>"</span><a name="l00022"></a>00022 <span class="preprocessor">#include "<a class="code" href="CML__AmpDef_8h.html">CML_AmpDef.h</a>"</span><a name="l00023"></a>00023 <a name="l00024"></a>00024 <a class="code" href="CML__Settings_8h.html#a13">CML_NAMESPACE_USE</a>();<a name="l00025"></a>00025 <a name="l00026"></a>00026 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00027"></a>00027 <span class="comment">/**</span><a name="l00028"></a>00028 <span class="comment">This class uses a proprietory protocol to update the amplifier's internal </span><a name="l00029"></a>00029 <span class="comment">firmware. This protocol uses the SDO transmit and receive CAN message ID</span><a name="l00030"></a>00030 <span class="comment">values.</span><a name="l00031"></a>00031 <span class="comment">*/</span><a name="l00032"></a>00032 <span class="comment">/***************************************************************************/</span><a name="l00033"></a>00033 <span class="keyword">class </span>FirmwareUpdater: <span class="keyword">public</span> <a class="code" href="classReceiver.html">Receiver</a><a name="l00034"></a>00034 {<a name="l00035"></a>00035 <a class="code" href="classSemaphore.html">Semaphore</a> sem;<a name="l00036"></a>00036 <a class="code" href="CML__Utils_8h.html#a10">uint32</a> xmitId;<a name="l00037"></a>00037 <a name="l00038"></a>00038 <span class="keyword">public</span>:<span class="comment"></span><a name="l00039"></a>00039 <span class="comment"> /// Response code from last received message</span><a name="l00040"></a>00040 <span class="comment"></span> <a class="code" href="CML__Utils_8h.html#a8">uint16</a> resp;<a name="l00041"></a>00041 <span class="comment"></span><a name="l00042"></a>00042 <span class="comment"> /// 32-bit data value received in last response.</span><a name="l00043"></a>00043 <span class="comment"></span> <a class="code" href="CML__Utils_8h.html#a10">uint32</a> data;<a name="l00044"></a>00044 <a name="l00045"></a>00045 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00046"></a>00046 <span class="comment"> /**</span><a name="l00047"></a>00047 <span class="comment"> Initialize the firmware updater using the ID parameters currently associated </span><a name="l00048"></a>00048 <span class="comment"> with the SDO.</span><a name="l00049"></a>00049 <span class="comment"></span><a name="l00050"></a>00050 <span class="comment"> @param sdo The SDO who's message ID values will be used for this updater.</span><a name="l00051"></a>00051 <span class="comment"> */</span><a name="l00052"></a>00052 <span class="comment">/***************************************************************************/</span><a name="l00053"></a>00053 FirmwareUpdater( <a class="code" href="classSDO.html">SDO</a> &sdo )<a name="l00054"></a>00054 {<a name="l00055"></a>00055 xmitId = sdo.<a class="code" href="classSDO.html#a29">getXmitID</a>();<a name="l00056"></a>00056 <a class="code" href="classReceiver.html#a3">Init</a>( sdo.<a class="code" href="classReceiver.html#a9">GetCanOpen</a>(), sdo.<a class="code" href="classReceiver.html#a6">getRecvID</a>() );<a name="l00057"></a>00057 }<a name="l00058"></a>00058 <a name="l00059"></a>00059 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00060"></a>00060 <span class="comment"> /**</span><a name="l00061"></a>00061 <span class="comment"> Receive frame handler called by the receive task when a new CAN message of </span><a name="l00062"></a>00062 <span class="comment"> the proper ID is received.</span><a name="l00063"></a>00063 <span class="comment"></span><a name="l00064"></a>00064 <span class="comment"> This function simply copies the data out of the received frame and posts to </span><a name="l00065"></a>00065 <span class="comment"> the semaphore associated with this object.</span><a name="l00066"></a>00066 <span class="comment"></span><a name="l00067"></a>00067 <span class="comment"> @param frame The received CAN frame</span><a name="l00068"></a>00068 <span class="comment"> @return Always returns 1.</span><a name="l00069"></a>00069 <span class="comment"> */</span><a name="l00070"></a>00070 <span class="comment">/***************************************************************************/</span><a name="l00071"></a>00071 <span class="keywordtype">int</span> <a class="code" href="classReceiver.html#a5">NewFrame</a>( <a class="code" href="structCanFrame.html">CanFrame</a> &frame )<a name="l00072"></a>00072 {<a name="l00073"></a>00073 resp = ((<a class="code" href="CML__Utils_8h.html#a8">uint16</a>)frame.<a class="code" href="structCanFrame.html#o3">data</a>[0]) | ((<a class="code" href="CML__Utils_8h.html#a8">uint16</a>)frame.<a class="code" href="structCanFrame.html#o3">data</a>[1]<<8);<a name="l00074"></a>00074 <a name="l00075"></a>00075 data = ((<a class="code" href="CML__Utils_8h.html#a10">uint32</a>)frame.<a class="code" href="structCanFrame.html#o3">data</a>[2]) | ((<a class="code" href="CML__Utils_8h.html#a10">uint32</a>)frame.<a class="code" href="structCanFrame.html#o3">data</a>[3]<<8) |<a name="l00076"></a>00076 ((<a class="code" href="CML__Utils_8h.html#a10">uint32</a>)frame.<a class="code" href="structCanFrame.html#o3">data</a>[4]<<16) | ((<a class="code" href="CML__Utils_8h.html#a10">uint32</a>)frame.<a class="code" href="structCanFrame.html#o3">data</a>[5]<<24);<a name="l00077"></a>00077 <a name="l00078"></a>00078 sem.Put();<a name="l00079"></a>00079 <span class="keywordflow">return</span> 1;<a name="l00080"></a>00080 }<a name="l00081"></a>00081 <a name="l00082"></a>00082 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00083"></a>00083 <span class="comment"> /**</span><a name="l00084"></a>00084 <span class="comment"> Send a command with no parameters</span><a name="l00085"></a>00085 <span class="comment"> @param cmd The command code. This code is part of the amplifiers</span><a name="l00086"></a>00086 <span class="comment"> special firmware upload protocol.</span><a name="l00087"></a>00087 <span class="comment"> @param timeout The time to wait for a response to this command.</span><a name="l00088"></a>00088 <span class="comment"> (milliseconds).</span><a name="l00089"></a>00089 <span class="comment"> @return An error object</span><a name="l00090"></a>00090 <span class="comment"> */</span><a name="l00091"></a>00091 <span class="comment">/***************************************************************************/</span><a name="l00092"></a>00092 <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *SendCmd( <a class="code" href="CML__Utils_8h.html#a8">uint16</a> cmd, <a class="code" href="CML__Utils_8h.html#a9">int32</a> timeout )<a name="l00093"></a>00093 {<a name="l00094"></a>00094 <span class="keywordflow">return</span> SendCmd( cmd, 0, 0, timeout );<a name="l00095"></a>00095 }<a name="l00096"></a>00096 <a name="l00097"></a>00097 <span class="comment">/***************************************************************************/</span><span class="comment"></span><a name="l00098"></a>00098 <span class="comment"> /**</span><a name="l00099"></a>00099 <span class="comment"> Send a command to the amplifier. The command is part of the amps special </span><a name="l00100"></a>00100 <span class="comment"> firmware upload protocol documented elsewhere.</span><a name="l00101"></a>00101 <span class="comment"> @param cmd The command code to send</span><a name="l00102"></a>00102 <span class="comment"> @param ct The length of the parameter array passed</span><a name="l00103"></a>00103 <span class="comment"> @param param An array of additional parameter data passed with the command.</span><a name="l00104"></a>00104 <span class="comment"> @param timeout The time to wait for a response to this command.</span><a name="l00105"></a>00105 <span class="comment"> (milliseconds).</span><a name="l00106"></a>00106 <span class="comment"> @return An error object</span><a name="l00107"></a>00107 <span class="comment"> */</span><a name="l00108"></a>00108 <span class="comment">/***************************************************************************/</span><a name="l00109"></a>00109 <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *SendCmd( <a class="code" href="CML__Utils_8h.html#a8">uint16</a> cmd, <a class="code" href="CML__Utils_8h.html#a8">uint16</a> ct, <a class="code" href="CML__Utils_8h.html#a8">uint16</a> *param, <a class="code" href="CML__Utils_8h.html#a9">int32</a> timeout )<a name="l00110"></a>00110 {<a name="l00111"></a>00111 <span class="keyword">const</span> <a class="code" href="classError.html">Error</a> *err;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?