nico@207: nico@207: nico@207: CanFestival: /home/epimerde/documents/tc11/CanFestival-3/include/sdo.h Source File nico@207: nico@207: nico@207: nico@207: nico@207:
nico@207:
nico@207:
nico@207:
nico@207:

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

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

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