/home/epimerde/documents/tc11/CanFestival-3/include/sdo.h

Go to the documentation of this file.
00001 /*
00002 This file is part of CanFestival, a library implementing CanOpen Stack. 
00003 
00004 Copyright (C): Edouard TISSERANT and Francis DUPIN
00005 
00006 See COPYING file for copyrights details.
00007 
00008 This library is free software; you can redistribute it and/or
00009 modify it under the terms of the GNU Lesser General Public
00010 License as published by the Free Software Foundation; either
00011 version 2.1 of the License, or (at your option) any later version.
00012 
00013 This library is distributed in the hope that it will be useful,
00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016 Lesser General Public License for more details.
00017 
00018 You should have received a copy of the GNU Lesser General Public
00019 License along with this library; if not, write to the Free Software
00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 */
00022 
00023 #ifndef __sdo_h__
00024 #define __sdo_h__
00025 
00026 struct struct_s_transfer;
00027 
00028 #include "timer.h"
00029 
00030 typedef void (*SDOCallback_t)(CO_Data* d, UNS8 nodeId);
00031 
00032 /* The Transfer structure
00033 Used to store the different segments of 
00034  - a SDO received before writing in the dictionary  
00035  - the reading of the dictionary to put on a SDO to transmit 
00036 */
00037 
00038 struct struct_s_transfer {
00039   UNS8           nodeId;     /*own ID if server, or node ID of the server if client */
00040   
00041   UNS8           whoami;     /* Takes the values SDO_CLIENT or SDO_SERVER */
00042   UNS8           state;      /* state of the transmission : Takes the values SDO_... */
00043   UNS8           toggle;
00044   UNS32          abortCode;  /* Sent or received */
00045   /* index and subindex of the dictionary where to store */
00046   /* (for a received SDO) or to read (for a transmit SDO) */
00047   UNS16          index; 
00048   UNS8           subIndex; 
00049   UNS32          count;      /* Number of data received or to be sent. */
00050   UNS32          offset;     /* stack pointer of data[]
00051                               * Used only to tranfer part of a line to or from a SDO.
00052                               * offset is always pointing on the next free cell of data[].
00053                               * WARNING s_transfer.data is subject to ENDIANISATION 
00054                               * (with respect to CANOPEN_BIG_ENDIAN)
00055                               */
00056   UNS8           data [SDO_MAX_LENGTH_TRANSFERT];
00057   UNS8           dataType;   /* Defined in objdictdef.h Value is visible_string 
00058                               * if it is a string, any other value if it is not a string, 
00059                               * like 0. In fact, it is used only if client.
00060                               */
00061   TIMER_HANDLE   timer;      /* Time counter to implement a timeout in milliseconds.
00062                               * It is automatically incremented whenever 
00063                               * the line state is in SDO_DOWNLOAD_IN_PROGRESS or 
00064                               * SDO_UPLOAD_IN_PROGRESS, and reseted to 0 
00065                               * when the response SDO have been received.
00066                               */
00067   SDOCallback_t Callback;   /* The user callback func to be called at SDO transaction end */
00068 };
00069 typedef struct struct_s_transfer s_transfer;
00070   
00071 
00072 #include "data.h"
00073 
00074 /* The 8 bytes data of the SDO */
00075 struct BODY{
00076     UNS8 data[8];
00077 };
00078 
00079 /* The SDO structure ...*/
00080 struct struct_s_SDO {
00081   UNS8 nodeId;          /*in any case, Node ID of the server (case sender or receiver).*/
00082   struct BODY body;
00083 };
00084 
00085 
00086 typedef struct struct_s_SDO s_SDO;
00087 
00091 void SDOTimeoutAlarm(CO_Data* d, UNS32 id);
00092 
00095 void resetSDO (CO_Data* d);
00096 
00097 
00101 UNS32 SDOlineToObjdict (CO_Data* d, UNS8 line);
00102 
00106 UNS32 objdictToSDOline (CO_Data* d, UNS8 line);
00107 
00111 UNS8 lineToSDO (CO_Data* d, UNS8 line, UNS8 nbBytes, UNS8 * data);
00112 
00116 UNS8 SDOtoLine (CO_Data* d, UNS8 line, UNS8 nbBytes, UNS8 * data);
00117 
00126 UNS8 failedSDO (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS16 index, 
00127                 UNS8 subIndex, UNS32 abortCode);
00128 
00132 void resetSDOline (CO_Data* d, UNS8 line);
00133 
00137 UNS8 initSDOline (CO_Data* d, UNS8 line, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 state);
00138 
00147 UNS8 getSDOfreeLine (CO_Data* d, UNS8 whoami, UNS8 *line);
00148 
00156 UNS8 getSDOlineOnUse (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS8 *line);
00157 
00162 UNS8 closeSDOtransfer (CO_Data* d, UNS8 nodeId, UNS8 whoami);
00163 
00168 UNS8 getSDOlineRestBytes (CO_Data* d, UNS8 line, UNS8 * nbBytes);
00169 
00174 UNS8 setSDOlineRestBytes (CO_Data* d, UNS8 line, UNS8 nbBytes);
00175 
00182 UNS8 sendSDO (CO_Data* d, UNS8 whoami, s_SDO sdo);
00183 
00191 UNS8 sendSDOabort (CO_Data* d, UNS8 whoami, UNS16 index, UNS8 subIndex, UNS32 abortCode);
00192 
00200 UNS8 proceedSDO (CO_Data* d, Message *m);
00201 
00210 UNS8 writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, 
00211                        UNS8 subIndex, UNS8 count, UNS8 dataType, void *data); 
00216 UNS8 writeNetworkDictCallBack (CO_Data* d, UNS8 nodeId, UNS16 index, 
00217                        UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback);
00225 UNS8 readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, 
00226                       UNS8 subIndex, UNS8 dataType);
00227                        
00232 UNS8 readNetworkDictCallback (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback);
00233 
00249 UNS8 getReadResultNetworkDict (CO_Data* d, UNS8 nodeId, void* data, 
00250                                UNS8 *size, UNS32 * abortCode);
00251 
00268 UNS8 getWriteResultNetworkDict (CO_Data* d, UNS8 nodeId, UNS32 * abortCode);
00269 
00270 
00271  
00272 
00273 #endif

Generated on Mon Jun 4 16:29:06 2007 for CanFestival by  doxygen 1.5.1