Can_open_slavenode

Dependencies:   mbed

Committer:
sam_grove
Date:
Wed Sep 26 05:43:05 2012 +0000
Revision:
6:bc64031ac849
Parent:
0:6219434a0cb5
Change a typecast in can_mbed.cpp from unit8_t * to char * to fit the CANMessage constructor

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sam_grove 0:6219434a0cb5 1 /*
sam_grove 0:6219434a0cb5 2 This file is part of CanFestival, a library implementing CanOpen Stack.
sam_grove 0:6219434a0cb5 3
sam_grove 0:6219434a0cb5 4 Copyright (C): Edouard TISSERANT and Francis DUPIN
sam_grove 0:6219434a0cb5 5
sam_grove 0:6219434a0cb5 6 See COPYING file for copyrights details.
sam_grove 0:6219434a0cb5 7
sam_grove 0:6219434a0cb5 8 This library is free software; you can redistribute it and/or
sam_grove 0:6219434a0cb5 9 modify it under the terms of the GNU Lesser General Public
sam_grove 0:6219434a0cb5 10 License as published by the Free Software Foundation; either
sam_grove 0:6219434a0cb5 11 version 2.1 of the License, or (at your option) any later version.
sam_grove 0:6219434a0cb5 12
sam_grove 0:6219434a0cb5 13 This library is distributed in the hope that it will be useful,
sam_grove 0:6219434a0cb5 14 but WITHOUT ANY WARRANTY; without even the implied warranty of
sam_grove 0:6219434a0cb5 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
sam_grove 0:6219434a0cb5 16 Lesser General Public License for more details.
sam_grove 0:6219434a0cb5 17
sam_grove 0:6219434a0cb5 18 You should have received a copy of the GNU Lesser General Public
sam_grove 0:6219434a0cb5 19 License along with this library; if not, write to the Free Software
sam_grove 0:6219434a0cb5 20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
sam_grove 0:6219434a0cb5 21 */
sam_grove 0:6219434a0cb5 22
sam_grove 0:6219434a0cb5 23 /** @defgroup comobj Communication Objects
sam_grove 0:6219434a0cb5 24 * @ingroup userapi
sam_grove 0:6219434a0cb5 25 */
sam_grove 0:6219434a0cb5 26
sam_grove 0:6219434a0cb5 27 /** @defgroup sdo Service Data Object (SDO)
sam_grove 0:6219434a0cb5 28 * SDOs provide the access to entries in the CANopen Object Dictionary.
sam_grove 0:6219434a0cb5 29 * An SDO is made up of at least two CAN messages with different identifiers.
sam_grove 0:6219434a0cb5 30 * SDO s are always confirmed point-to-point communications services.
sam_grove 0:6219434a0cb5 31 * @ingroup comobj
sam_grove 0:6219434a0cb5 32 */
sam_grove 0:6219434a0cb5 33
sam_grove 0:6219434a0cb5 34 #ifndef __sdo_h__
sam_grove 0:6219434a0cb5 35 #define __sdo_h__
sam_grove 0:6219434a0cb5 36
sam_grove 0:6219434a0cb5 37 struct struct_s_transfer;
sam_grove 0:6219434a0cb5 38
sam_grove 0:6219434a0cb5 39 #include "canopen_timer.h"
sam_grove 0:6219434a0cb5 40
sam_grove 0:6219434a0cb5 41 typedef void (*SDOCallback_t)(CO_Data* d, UNS8 nodeId);
sam_grove 0:6219434a0cb5 42
sam_grove 0:6219434a0cb5 43 /* The Transfer structure
sam_grove 0:6219434a0cb5 44 Used to store the different segments of
sam_grove 0:6219434a0cb5 45 - a SDO received before writing in the dictionary
sam_grove 0:6219434a0cb5 46 - the reading of the dictionary to put on a SDO to transmit
sam_grove 0:6219434a0cb5 47 */
sam_grove 0:6219434a0cb5 48
sam_grove 0:6219434a0cb5 49 struct struct_s_transfer {
sam_grove 0:6219434a0cb5 50 UNS8 nodeId; /**<own ID if server, or node ID of the server if client */
sam_grove 0:6219434a0cb5 51
sam_grove 0:6219434a0cb5 52 UNS8 whoami; /**< Takes the values SDO_CLIENT or SDO_SERVER */
sam_grove 0:6219434a0cb5 53 UNS8 state; /**< state of the transmission : Takes the values SDO_... */
sam_grove 0:6219434a0cb5 54 UNS8 toggle;
sam_grove 0:6219434a0cb5 55 UNS32 abortCode; /**< Sent or received */
sam_grove 0:6219434a0cb5 56 /**< index and subindex of the dictionary where to store */
sam_grove 0:6219434a0cb5 57 /**< (for a received SDO) or to read (for a transmit SDO) */
sam_grove 0:6219434a0cb5 58 UNS16 index;
sam_grove 0:6219434a0cb5 59 UNS8 subIndex;
sam_grove 0:6219434a0cb5 60 UNS32 count; /**< Number of data received or to be sent. */
sam_grove 0:6219434a0cb5 61 UNS32 offset; /**< stack pointer of data[]
sam_grove 0:6219434a0cb5 62 * Used only to tranfer part of a line to or from a SDO.
sam_grove 0:6219434a0cb5 63 * offset is always pointing on the next free cell of data[].
sam_grove 0:6219434a0cb5 64 * WARNING s_transfer.data is subject to ENDIANISATION
sam_grove 0:6219434a0cb5 65 * (with respect to CANOPEN_BIG_ENDIAN)
sam_grove 0:6219434a0cb5 66 */
sam_grove 0:6219434a0cb5 67 UNS8 data [SDO_MAX_LENGTH_TRANSFERT];
sam_grove 0:6219434a0cb5 68 #ifdef SDO_DYNAMIC_BUFFER_ALLOCATION
sam_grove 0:6219434a0cb5 69 UNS8 *dynamicData;
sam_grove 0:6219434a0cb5 70 UNS32 dynamicDataSize;
sam_grove 0:6219434a0cb5 71 #endif //SDO_DYNAMIC_BUFFER_ALLOCATION
sam_grove 0:6219434a0cb5 72 UNS8 dataType; /**< Defined in objdictdef.h Value is visible_string
sam_grove 0:6219434a0cb5 73 * if it is a string, any other value if it is not a string,
sam_grove 0:6219434a0cb5 74 * like 0. In fact, it is used only if client.
sam_grove 0:6219434a0cb5 75 */
sam_grove 0:6219434a0cb5 76 TIMER_HANDLE timer; /**< Time counter to implement a timeout in milliseconds.
sam_grove 0:6219434a0cb5 77 * It is automatically incremented whenever
sam_grove 0:6219434a0cb5 78 * the line state is in SDO_DOWNLOAD_IN_PROGRESS or
sam_grove 0:6219434a0cb5 79 * SDO_UPLOAD_IN_PROGRESS, and reseted to 0
sam_grove 0:6219434a0cb5 80 * when the response SDO have been received.
sam_grove 0:6219434a0cb5 81 */
sam_grove 0:6219434a0cb5 82 SDOCallback_t Callback; /**< The user callback func to be called at SDO transaction end */
sam_grove 0:6219434a0cb5 83 };
sam_grove 0:6219434a0cb5 84 typedef struct struct_s_transfer s_transfer;
sam_grove 0:6219434a0cb5 85
sam_grove 0:6219434a0cb5 86
sam_grove 0:6219434a0cb5 87 #include "data.h"
sam_grove 0:6219434a0cb5 88
sam_grove 0:6219434a0cb5 89
sam_grove 0:6219434a0cb5 90 struct BODY{
sam_grove 0:6219434a0cb5 91 UNS8 data[8]; /**< The 8 bytes data of the SDO */
sam_grove 0:6219434a0cb5 92 };
sam_grove 0:6219434a0cb5 93
sam_grove 0:6219434a0cb5 94 /* The SDO structure ...*/
sam_grove 0:6219434a0cb5 95 struct struct_s_SDO {
sam_grove 0:6219434a0cb5 96 UNS8 nodeId; /**< In any case, Node ID of the server (case sender or receiver).*/
sam_grove 0:6219434a0cb5 97 struct BODY body;
sam_grove 0:6219434a0cb5 98 };
sam_grove 0:6219434a0cb5 99
sam_grove 0:6219434a0cb5 100
sam_grove 0:6219434a0cb5 101 typedef struct struct_s_SDO s_SDO;
sam_grove 0:6219434a0cb5 102
sam_grove 0:6219434a0cb5 103 /*!
sam_grove 0:6219434a0cb5 104 ** Called by writeNetworkDict
sam_grove 0:6219434a0cb5 105 **
sam_grove 0:6219434a0cb5 106 ** @param d
sam_grove 0:6219434a0cb5 107 ** @param nodeId
sam_grove 0:6219434a0cb5 108 ** @param index
sam_grove 0:6219434a0cb5 109 ** @param subIndex
sam_grove 0:6219434a0cb5 110 ** @param count
sam_grove 0:6219434a0cb5 111 ** @param dataType
sam_grove 0:6219434a0cb5 112 ** @param data
sam_grove 0:6219434a0cb5 113 ** @param Callback
sam_grove 0:6219434a0cb5 114 ** @param endianize
sam_grove 0:6219434a0cb5 115 **
sam_grove 0:6219434a0cb5 116 ** @return
sam_grove 0:6219434a0cb5 117 **/
sam_grove 0:6219434a0cb5 118 UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index,
sam_grove 0:6219434a0cb5 119 UNS8 subIndex, UNS32 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize);
sam_grove 0:6219434a0cb5 120
sam_grove 0:6219434a0cb5 121 /**
sam_grove 0:6219434a0cb5 122 * @brief Reset of a SDO exchange on timeout.
sam_grove 0:6219434a0cb5 123 * Send a SDO abort.
sam_grove 0:6219434a0cb5 124 * @param *d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 125 * @param id
sam_grove 0:6219434a0cb5 126 */
sam_grove 0:6219434a0cb5 127 void SDOTimeoutAlarm(CO_Data* d, UNS32 id);
sam_grove 0:6219434a0cb5 128
sam_grove 0:6219434a0cb5 129 /**
sam_grove 0:6219434a0cb5 130 * @brief Reset all SDO buffers.
sam_grove 0:6219434a0cb5 131 * @param *d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 132 */
sam_grove 0:6219434a0cb5 133 void resetSDO (CO_Data* d);
sam_grove 0:6219434a0cb5 134
sam_grove 0:6219434a0cb5 135
sam_grove 0:6219434a0cb5 136 /**
sam_grove 0:6219434a0cb5 137 * @brief Copy the data received from the SDO line transfert to the object dictionary.
sam_grove 0:6219434a0cb5 138 * @param *d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 139 * @param line SDO line
sam_grove 0:6219434a0cb5 140 * @return SDO error code if error. Else, returns 0.
sam_grove 0:6219434a0cb5 141 */
sam_grove 0:6219434a0cb5 142 UNS32 SDOlineToObjdict (CO_Data* d, UNS8 line);
sam_grove 0:6219434a0cb5 143
sam_grove 0:6219434a0cb5 144 /**
sam_grove 0:6219434a0cb5 145 * @brief Copy the data from the object dictionary to the SDO line for a network transfert.
sam_grove 0:6219434a0cb5 146 * @param *d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 147 * @param line SDO line
sam_grove 0:6219434a0cb5 148 * @return SDO error code if error. Else, returns 0.
sam_grove 0:6219434a0cb5 149 */
sam_grove 0:6219434a0cb5 150 UNS32 objdictToSDOline (CO_Data* d, UNS8 line);
sam_grove 0:6219434a0cb5 151
sam_grove 0:6219434a0cb5 152 /**
sam_grove 0:6219434a0cb5 153 * @brief Copy data from an existant line in the argument "* data"
sam_grove 0:6219434a0cb5 154 * @param d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 155 * @param line SDO line
sam_grove 0:6219434a0cb5 156 * @param nbBytes
sam_grove 0:6219434a0cb5 157 * @param *data Pointer on the data
sam_grove 0:6219434a0cb5 158 * @return 0xFF if error. Else, returns 0.
sam_grove 0:6219434a0cb5 159 */
sam_grove 0:6219434a0cb5 160 UNS8 lineToSDO (CO_Data* d, UNS8 line, UNS32 nbBytes, UNS8 * data);
sam_grove 0:6219434a0cb5 161
sam_grove 0:6219434a0cb5 162 /**
sam_grove 0:6219434a0cb5 163 * @brief Add data to an existant line
sam_grove 0:6219434a0cb5 164 * @param d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 165 * @param line SDO line
sam_grove 0:6219434a0cb5 166 * @param nbBytes
sam_grove 0:6219434a0cb5 167 * @param *data Pointer on the data
sam_grove 0:6219434a0cb5 168 * @return 0xFF if error. Else, returns 0.
sam_grove 0:6219434a0cb5 169 */
sam_grove 0:6219434a0cb5 170 UNS8 SDOtoLine (CO_Data* d, UNS8 line, UNS32 nbBytes, UNS8 * data);
sam_grove 0:6219434a0cb5 171
sam_grove 0:6219434a0cb5 172 /**
sam_grove 0:6219434a0cb5 173 * @brief Called when an internal SDO abort occurs.
sam_grove 0:6219434a0cb5 174 * Release the line * Only if server *
sam_grove 0:6219434a0cb5 175 * If client, the line must be released manually in the core application.
sam_grove 0:6219434a0cb5 176 * The reason of that is to permit the program to read the transfers structure before its reset,
sam_grove 0:6219434a0cb5 177 * because many informations are stored on it : index, subindex, data received or trasmited, ...
sam_grove 0:6219434a0cb5 178 * In all cases, sends a SDO abort.
sam_grove 0:6219434a0cb5 179 * @param *d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 180 * @param nodeId
sam_grove 0:6219434a0cb5 181 * @param whoami
sam_grove 0:6219434a0cb5 182 * @param index
sam_grove 0:6219434a0cb5 183 * @param subIndex
sam_grove 0:6219434a0cb5 184 * @param abortCode
sam_grove 0:6219434a0cb5 185 * @return 0
sam_grove 0:6219434a0cb5 186 */
sam_grove 0:6219434a0cb5 187 UNS8 failedSDO (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS16 index, UNS8 subIndex, UNS32 abortCode);
sam_grove 0:6219434a0cb5 188
sam_grove 0:6219434a0cb5 189 /**
sam_grove 0:6219434a0cb5 190 * @brief Reset an unused line.
sam_grove 0:6219434a0cb5 191 * @param *d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 192 * @param line SDO line
sam_grove 0:6219434a0cb5 193 */
sam_grove 0:6219434a0cb5 194 void resetSDOline (CO_Data* d, UNS8 line);
sam_grove 0:6219434a0cb5 195
sam_grove 0:6219434a0cb5 196 /**
sam_grove 0:6219434a0cb5 197 * @brief Initialize some fields of the structure.
sam_grove 0:6219434a0cb5 198 * @param *d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 199 * @param line
sam_grove 0:6219434a0cb5 200 * @param nodeId
sam_grove 0:6219434a0cb5 201 * @param index
sam_grove 0:6219434a0cb5 202 * @param subIndex
sam_grove 0:6219434a0cb5 203 * @param state
sam_grove 0:6219434a0cb5 204 * @return 0
sam_grove 0:6219434a0cb5 205 */
sam_grove 0:6219434a0cb5 206 UNS8 initSDOline (CO_Data* d, UNS8 line, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 state);
sam_grove 0:6219434a0cb5 207
sam_grove 0:6219434a0cb5 208 /**
sam_grove 0:6219434a0cb5 209 * @brief Search for an unused line in the transfers array
sam_grove 0:6219434a0cb5 210 * to store a new SDO.
sam_grove 0:6219434a0cb5 211 * ie a line which value of the field "state" is "SDO_RESET"
sam_grove 0:6219434a0cb5 212 * An unused line have the field "state" at the value SDO_RESET
sam_grove 0:6219434a0cb5 213 * @param *d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 214 * @param whoami Create the line for a SDO_SERVER or SDO_CLIENT.
sam_grove 0:6219434a0cb5 215 * @param *line Pointer on a SDO line
sam_grove 0:6219434a0cb5 216 * @return 0xFF if all the lines are on use. Else, return 0.
sam_grove 0:6219434a0cb5 217 */
sam_grove 0:6219434a0cb5 218 UNS8 getSDOfreeLine (CO_Data* d, UNS8 whoami, UNS8 *line);
sam_grove 0:6219434a0cb5 219
sam_grove 0:6219434a0cb5 220 /**
sam_grove 0:6219434a0cb5 221 * @brief Search for the line, in the transfers array, which contains the
sam_grove 0:6219434a0cb5 222 * beginning of the reception of a fragmented SDO
sam_grove 0:6219434a0cb5 223 * @param *d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 224 * @param nodeId correspond to the message node-id
sam_grove 0:6219434a0cb5 225 * @param whoami takes 2 values : look for a line opened as SDO_CLIENT or SDO_SERVER
sam_grove 0:6219434a0cb5 226 * @param *line Pointer on a SDO line
sam_grove 0:6219434a0cb5 227 * @return 0xFF if error. Else, return 0
sam_grove 0:6219434a0cb5 228 */
sam_grove 0:6219434a0cb5 229 UNS8 getSDOlineOnUse (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS8 *line);
sam_grove 0:6219434a0cb5 230
sam_grove 0:6219434a0cb5 231 /**
sam_grove 0:6219434a0cb5 232 * @brief Search for the line, in the transfers array, which contains the
sam_grove 0:6219434a0cb5 233 * beginning of the reception of a fragmented SDO
sam_grove 0:6219434a0cb5 234 *
sam_grove 0:6219434a0cb5 235 * Because getSDOlineOnUse() does not return any line in state \c SDO_ABORTED_INTERNAL,
sam_grove 0:6219434a0cb5 236 * this funtion is used to return them, too.
sam_grove 0:6219434a0cb5 237 *
sam_grove 0:6219434a0cb5 238 * @param *d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 239 * @param nodeId correspond to the message node-id
sam_grove 0:6219434a0cb5 240 * @param whoami takes 2 values : look for a line opened as SDO_CLIENT or SDO_SERVER
sam_grove 0:6219434a0cb5 241 * @param *line Pointer on a SDO line
sam_grove 0:6219434a0cb5 242 * @return 0xFF if error. Else, return 0
sam_grove 0:6219434a0cb5 243 */
sam_grove 0:6219434a0cb5 244 UNS8 getSDOlineToClose (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS8 *line);
sam_grove 0:6219434a0cb5 245
sam_grove 0:6219434a0cb5 246 /**
sam_grove 0:6219434a0cb5 247 * @brief Close a transmission.
sam_grove 0:6219434a0cb5 248 * @param *d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 249 * @param nodeId Node id of the server if both server or client
sam_grove 0:6219434a0cb5 250 * @param whoami Line opened as SDO_CLIENT or SDO_SERVER
sam_grove 0:6219434a0cb5 251 */
sam_grove 0:6219434a0cb5 252 UNS8 closeSDOtransfer (CO_Data* d, UNS8 nodeId, UNS8 whoami);
sam_grove 0:6219434a0cb5 253
sam_grove 0:6219434a0cb5 254 /**
sam_grove 0:6219434a0cb5 255 * @brief Bytes in the line structure which must be transmited (or received)
sam_grove 0:6219434a0cb5 256 * @param *d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 257 * @param line SDO line
sam_grove 0:6219434a0cb5 258 * @param *nbBytes Pointer on nbBytes
sam_grove 0:6219434a0cb5 259 * @return 0.
sam_grove 0:6219434a0cb5 260 */
sam_grove 0:6219434a0cb5 261 UNS8 getSDOlineRestBytes (CO_Data* d, UNS8 line, UNS32 * nbBytes);
sam_grove 0:6219434a0cb5 262
sam_grove 0:6219434a0cb5 263 /**
sam_grove 0:6219434a0cb5 264 * @brief Store in the line structure the nb of bytes which must be transmited (or received)
sam_grove 0:6219434a0cb5 265 * @param *d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 266 * @param line SDO line
sam_grove 0:6219434a0cb5 267 * @param nbBytes
sam_grove 0:6219434a0cb5 268 * @return 0 if success, 0xFF if error.
sam_grove 0:6219434a0cb5 269 */
sam_grove 0:6219434a0cb5 270 UNS8 setSDOlineRestBytes (CO_Data* d, UNS8 line, UNS32 nbBytes);
sam_grove 0:6219434a0cb5 271
sam_grove 0:6219434a0cb5 272 /**
sam_grove 0:6219434a0cb5 273 * @brief Transmit a SDO frame on the bus bus_id
sam_grove 0:6219434a0cb5 274 * @param *d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 275 * @param whoami Takes 2 values : SDO_CLIENT or SDO_SERVER
sam_grove 0:6219434a0cb5 276 * @param sdo SDO Structure which contains the sdo to transmit
sam_grove 0:6219434a0cb5 277 * @return canSend(bus_id,&m) or 0xFF if error.
sam_grove 0:6219434a0cb5 278 */
sam_grove 0:6219434a0cb5 279 UNS8 sendSDO (CO_Data* d, UNS8 whoami, s_SDO sdo);
sam_grove 0:6219434a0cb5 280
sam_grove 0:6219434a0cb5 281 /**
sam_grove 0:6219434a0cb5 282 * @brief Transmit a SDO error to the client. The reasons may be :
sam_grove 0:6219434a0cb5 283 * Read/Write to a undefined object
sam_grove 0:6219434a0cb5 284 * Read/Write to a undefined subindex
sam_grove 0:6219434a0cb5 285 * Read/write a not valid length object
sam_grove 0:6219434a0cb5 286 * Write a read only object
sam_grove 0:6219434a0cb5 287 * @param *d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 288 * @param whoami takes 2 values : SDO_CLIENT or SDO_SERVER
sam_grove 0:6219434a0cb5 289 * @param nodeId
sam_grove 0:6219434a0cb5 290 * @param index
sam_grove 0:6219434a0cb5 291 * @param subIndex
sam_grove 0:6219434a0cb5 292 * @param abortCode
sam_grove 0:6219434a0cb5 293 * @return 0
sam_grove 0:6219434a0cb5 294 */
sam_grove 0:6219434a0cb5 295 UNS8 sendSDOabort (CO_Data* d, UNS8 whoami, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS32 abortCode);
sam_grove 0:6219434a0cb5 296
sam_grove 0:6219434a0cb5 297 /**
sam_grove 0:6219434a0cb5 298 * @brief Treat a SDO frame reception
sam_grove 0:6219434a0cb5 299 * call the function sendSDO
sam_grove 0:6219434a0cb5 300 * @param *d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 301 * @param *m Pointer on a CAN message structure
sam_grove 0:6219434a0cb5 302 * @return code :
sam_grove 0:6219434a0cb5 303 * - 0xFF if error
sam_grove 0:6219434a0cb5 304 * - 0x80 if transfert aborted by the server
sam_grove 0:6219434a0cb5 305 * - 0x0 ok
sam_grove 0:6219434a0cb5 306 */
sam_grove 0:6219434a0cb5 307 UNS8 proceedSDO (CO_Data* d, Message *m);
sam_grove 0:6219434a0cb5 308
sam_grove 0:6219434a0cb5 309 /**
sam_grove 0:6219434a0cb5 310 * @ingroup sdo
sam_grove 0:6219434a0cb5 311 * @brief Used to send a SDO request frame to write the data at the index and subIndex indicated
sam_grove 0:6219434a0cb5 312 * @param *d Pointer to a CAN object data structure
sam_grove 0:6219434a0cb5 313 * @param nodeId Node Id of the slave
sam_grove 0:6219434a0cb5 314 * @param index At index indicated
sam_grove 0:6219434a0cb5 315 * @param subIndex At subIndex indicated
sam_grove 0:6219434a0cb5 316 * @param count number of bytes to write in the dictionnary.
sam_grove 0:6219434a0cb5 317 * @param dataType (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value.
sam_grove 0:6219434a0cb5 318 * @param *data Pointer to data
sam_grove 0:6219434a0cb5 319 * @return
sam_grove 0:6219434a0cb5 320 * - 0 is returned upon success.
sam_grove 0:6219434a0cb5 321 * - 0xFE is returned when no sdo client to communicate with node.
sam_grove 0:6219434a0cb5 322 * - 0xFF is returned when error occurs.
sam_grove 0:6219434a0cb5 323 */
sam_grove 0:6219434a0cb5 324 UNS8 writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index,
sam_grove 0:6219434a0cb5 325 UNS8 subIndex, UNS32 count, UNS8 dataType, void *data);
sam_grove 0:6219434a0cb5 326
sam_grove 0:6219434a0cb5 327 /**
sam_grove 0:6219434a0cb5 328 * @ingroup sdo
sam_grove 0:6219434a0cb5 329 * @brief Used to send a SDO request frame to write in a distant node dictionnary.
sam_grove 0:6219434a0cb5 330 * @details The function Callback which must be defined in the user code is called at the
sam_grove 0:6219434a0cb5 331 * end of the exchange. (on succes or abort).
sam_grove 0:6219434a0cb5 332 * @param *d Pointer to a CAN object data structure
sam_grove 0:6219434a0cb5 333 * @param nodeId Node Id of the slave
sam_grove 0:6219434a0cb5 334 * @param index At index indicated
sam_grove 0:6219434a0cb5 335 * @param subIndex At subIndex indicated
sam_grove 0:6219434a0cb5 336 * @param count number of bytes to write in the dictionnary.
sam_grove 0:6219434a0cb5 337 * @param dataType (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value.
sam_grove 0:6219434a0cb5 338 * @param *data Pointer to data
sam_grove 0:6219434a0cb5 339 * @param Callback Callback function
sam_grove 0:6219434a0cb5 340 * @return
sam_grove 0:6219434a0cb5 341 * - 0 is returned upon success.
sam_grove 0:6219434a0cb5 342 * - 0xFE is returned when no sdo client to communicate with node.
sam_grove 0:6219434a0cb5 343 * - 0xFF is returned when error occurs.
sam_grove 0:6219434a0cb5 344 */
sam_grove 0:6219434a0cb5 345 UNS8 writeNetworkDictCallBack (CO_Data* d, UNS8 nodeId, UNS16 index,
sam_grove 0:6219434a0cb5 346 UNS8 subIndex, UNS32 count, UNS8 dataType, void *data, SDOCallback_t Callback);
sam_grove 0:6219434a0cb5 347
sam_grove 0:6219434a0cb5 348 /**
sam_grove 0:6219434a0cb5 349 * @ingroup sdo
sam_grove 0:6219434a0cb5 350 * @brief Used to send a SDO request frame to write in a distant node dictionnary.
sam_grove 0:6219434a0cb5 351 * @details The function Callback which must be defined in the user code is called at the
sam_grove 0:6219434a0cb5 352 * end of the exchange. (on succes or abort). First free SDO client parameter is
sam_grove 0:6219434a0cb5 353 * automatically initialized for specific node if not already defined.
sam_grove 0:6219434a0cb5 354 * @param *d Pointer to a CAN object data structure
sam_grove 0:6219434a0cb5 355 * @param nodeId Node Id of the slave
sam_grove 0:6219434a0cb5 356 * @param index At index indicated
sam_grove 0:6219434a0cb5 357 * @param subIndex At subIndex indicated
sam_grove 0:6219434a0cb5 358 * @param count number of bytes to write in the dictionnary.
sam_grove 0:6219434a0cb5 359 * @param dataType (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value.
sam_grove 0:6219434a0cb5 360 * @param *data Pointer to data
sam_grove 0:6219434a0cb5 361 * @param Callback Callback function
sam_grove 0:6219434a0cb5 362 * @param endianize When not 0, data is endianized into network byte order
sam_grove 0:6219434a0cb5 363 * when 0, data is not endianized and copied in machine native
sam_grove 0:6219434a0cb5 364 * endianness
sam_grove 0:6219434a0cb5 365 * @return
sam_grove 0:6219434a0cb5 366 * - 0 is returned upon success.
sam_grove 0:6219434a0cb5 367 * - 0xFF is returned when error occurs.
sam_grove 0:6219434a0cb5 368 */
sam_grove 0:6219434a0cb5 369 UNS8 writeNetworkDictCallBackAI (CO_Data* d, UNS8 nodeId, UNS16 index,
sam_grove 0:6219434a0cb5 370 UNS8 subIndex, UNS32 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize);
sam_grove 0:6219434a0cb5 371
sam_grove 0:6219434a0cb5 372 /**
sam_grove 0:6219434a0cb5 373 * @ingroup sdo
sam_grove 0:6219434a0cb5 374 * @brief Used to send a SDO request frame to read.
sam_grove 0:6219434a0cb5 375 * @param *d Pointer to a CAN object data structure
sam_grove 0:6219434a0cb5 376 * @param nodeId Node Id of the slave
sam_grove 0:6219434a0cb5 377 * @param index At index indicated
sam_grove 0:6219434a0cb5 378 * @param subIndex At subIndex indicated
sam_grove 0:6219434a0cb5 379 * @param dataType (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value.
sam_grove 0:6219434a0cb5 380 * @return
sam_grove 0:6219434a0cb5 381 * - 0 is returned upon success.
sam_grove 0:6219434a0cb5 382 * - 0xFE is returned when no sdo client to communicate with node.
sam_grove 0:6219434a0cb5 383 * - 0xFF is returned when error occurs.
sam_grove 0:6219434a0cb5 384 */
sam_grove 0:6219434a0cb5 385 UNS8 readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType);
sam_grove 0:6219434a0cb5 386
sam_grove 0:6219434a0cb5 387 /**
sam_grove 0:6219434a0cb5 388 * @ingroup sdo
sam_grove 0:6219434a0cb5 389 * @brief Used to send a SDO request frame to read in a distant node dictionnary.
sam_grove 0:6219434a0cb5 390 * @details The function Callback which must be defined in the user code is called at the
sam_grove 0:6219434a0cb5 391 * end of the exchange. (on succes or abort).
sam_grove 0:6219434a0cb5 392 * @param *d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 393 * @param nodeId Node Id of the slave
sam_grove 0:6219434a0cb5 394 * @param index At index indicated
sam_grove 0:6219434a0cb5 395 * @param subIndex At subIndex indicated
sam_grove 0:6219434a0cb5 396 * @param dataType (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value.
sam_grove 0:6219434a0cb5 397 * @param Callback Callback function
sam_grove 0:6219434a0cb5 398 * @return
sam_grove 0:6219434a0cb5 399 * - 0 is returned upon success.
sam_grove 0:6219434a0cb5 400 * - 0xFE is returned when no sdo client to communicate with node.
sam_grove 0:6219434a0cb5 401 * - 0xFF is returned when error occurs.
sam_grove 0:6219434a0cb5 402 */
sam_grove 0:6219434a0cb5 403 UNS8 readNetworkDictCallback (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback);
sam_grove 0:6219434a0cb5 404
sam_grove 0:6219434a0cb5 405 /**
sam_grove 0:6219434a0cb5 406 * @ingroup sdo
sam_grove 0:6219434a0cb5 407 * @brief Used to send a SDO request frame to read in a distant node dictionnary.
sam_grove 0:6219434a0cb5 408 * @details The function Callback which must be defined in the user code is called at the
sam_grove 0:6219434a0cb5 409 * end of the exchange. (on succes or abort). First free SDO client parameter is
sam_grove 0:6219434a0cb5 410 * automatically initialized for specific node if not already defined.
sam_grove 0:6219434a0cb5 411 * @param *d Pointer on a CAN object data structure
sam_grove 0:6219434a0cb5 412 * @param nodeId Node Id of the slave
sam_grove 0:6219434a0cb5 413 * @param index At index indicated
sam_grove 0:6219434a0cb5 414 * @param subIndex At subIndex indicated
sam_grove 0:6219434a0cb5 415 * @param dataType (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value.
sam_grove 0:6219434a0cb5 416 * @param Callback Callback function
sam_grove 0:6219434a0cb5 417 * @return
sam_grove 0:6219434a0cb5 418 * - 0 is returned upon success.
sam_grove 0:6219434a0cb5 419 * - 0xFF is returned when error occurs.
sam_grove 0:6219434a0cb5 420 */
sam_grove 0:6219434a0cb5 421 UNS8 readNetworkDictCallbackAI (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback);
sam_grove 0:6219434a0cb5 422
sam_grove 0:6219434a0cb5 423 /**
sam_grove 0:6219434a0cb5 424 * @ingroup sdo
sam_grove 0:6219434a0cb5 425 * @brief Use this function after calling readNetworkDict to get the result.
sam_grove 0:6219434a0cb5 426 *
sam_grove 0:6219434a0cb5 427 * @param *d Pointer to a CAN object data structure
sam_grove 0:6219434a0cb5 428 * @param nodeId Node Id of the slave
sam_grove 0:6219434a0cb5 429 * @param *data Pointer to the datas
sam_grove 0:6219434a0cb5 430 * @param *size Pointer to the size
sam_grove 0:6219434a0cb5 431 * @param *abortCode Pointer to the abortcode. (0 = not available. Else : SDO abort code. (received if return SDO_ABORTED_RCV)
sam_grove 0:6219434a0cb5 432 *
sam_grove 0:6219434a0cb5 433 *
sam_grove 0:6219434a0cb5 434 * @return
sam_grove 0:6219434a0cb5 435 * - SDO_FINISHED // datas are available
sam_grove 0:6219434a0cb5 436 * - SDO_ABORTED_RCV // Transfert failed (abort SDO received)
sam_grove 0:6219434a0cb5 437 * - SDO_ABORTED_INTERNAL // Transfert failed (internal abort)
sam_grove 0:6219434a0cb5 438 * - SDO_UPLOAD_IN_PROGRESS // Datas are not yet available
sam_grove 0:6219434a0cb5 439 * - SDO_DOWNLOAD_IN_PROGRESS // Download is in progress
sam_grove 0:6219434a0cb5 440 * \n\n
sam_grove 0:6219434a0cb5 441 * example :
sam_grove 0:6219434a0cb5 442 * @code
sam_grove 0:6219434a0cb5 443 * UNS32 data;
sam_grove 0:6219434a0cb5 444 * UNS8 size;
sam_grove 0:6219434a0cb5 445 * readNetworkDict(0, 0x05, 0x1016, 1, 0) // get the data index 1016 subindex 1 of node 5
sam_grove 0:6219434a0cb5 446 * while (getReadResultNetworkDict (0, 0x05, &data, &size) == SDO_UPLOAD_IN_PROGRESS);
sam_grove 0:6219434a0cb5 447 * @endcode
sam_grove 0:6219434a0cb5 448 */
sam_grove 0:6219434a0cb5 449 UNS8 getReadResultNetworkDict (CO_Data* d, UNS8 nodeId, void* data, UNS32 *size, UNS32 * abortCode);
sam_grove 0:6219434a0cb5 450
sam_grove 0:6219434a0cb5 451 /**
sam_grove 0:6219434a0cb5 452 * @ingroup sdo
sam_grove 0:6219434a0cb5 453 * @brief Use this function after calling writeNetworkDict function to get the result of the write.
sam_grove 0:6219434a0cb5 454 * @details It is mandatory to call this function because it is releasing the line used for the transfer.
sam_grove 0:6219434a0cb5 455 * @param *d Pointer to a CAN object data structure
sam_grove 0:6219434a0cb5 456 * @param nodeId Node Id of the slave
sam_grove 0:6219434a0cb5 457 * @param *abortCode Pointer to the abortcode
sam_grove 0:6219434a0cb5 458 * - 0 = not available.
sam_grove 0:6219434a0cb5 459 * - SDO abort code (received if return SDO_ABORTED_RCV)
sam_grove 0:6219434a0cb5 460 *
sam_grove 0:6219434a0cb5 461 * @return :
sam_grove 0:6219434a0cb5 462 * - SDO_FINISHED // datas are available
sam_grove 0:6219434a0cb5 463 * - SDO_ABORTED_RCV // Transfert failed (abort SDO received)
sam_grove 0:6219434a0cb5 464 * - SDO_ABORTED_INTERNAL // Transfert failed (Internal abort)
sam_grove 0:6219434a0cb5 465 * - SDO_DOWNLOAD_IN_PROGRESS // Datas are not yet available
sam_grove 0:6219434a0cb5 466 * - SDO_UPLOAD_IN_PROGRESS // Upload in progress
sam_grove 0:6219434a0cb5 467 * \n\n
sam_grove 0:6219434a0cb5 468 * example :
sam_grove 0:6219434a0cb5 469 * @code
sam_grove 0:6219434a0cb5 470 * UNS32 data = 0x50;
sam_grove 0:6219434a0cb5 471 * UNS8 size;
sam_grove 0:6219434a0cb5 472 * UNS32 abortCode;
sam_grove 0:6219434a0cb5 473 * writeNetworkDict(0, 0x05, 0x1016, 1, size, &data) // write the data index 1016 subindex 1 of node 5
sam_grove 0:6219434a0cb5 474 * while (getWriteResultNetworkDict (0, 0x05, &abortCode) == SDO_DOWNLOAD_IN_PROGRESS);
sam_grove 0:6219434a0cb5 475 * @endcode
sam_grove 0:6219434a0cb5 476 */
sam_grove 0:6219434a0cb5 477 UNS8 getWriteResultNetworkDict (CO_Data* d, UNS8 nodeId, UNS32 * abortCode);
sam_grove 0:6219434a0cb5 478
sam_grove 0:6219434a0cb5 479 #endif