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