34 - a SDO received before writing in the dictionary |
45 - a SDO received before writing in the dictionary |
35 - the reading of the dictionary to put on a SDO to transmit |
46 - the reading of the dictionary to put on a SDO to transmit |
36 */ |
47 */ |
37 |
48 |
38 struct struct_s_transfer { |
49 struct struct_s_transfer { |
39 UNS8 nodeId; /*own ID if server, or node ID of the server if client */ |
50 UNS8 nodeId; /**<own ID if server, or node ID of the server if client */ |
40 |
51 |
41 UNS8 whoami; /* Takes the values SDO_CLIENT or SDO_SERVER */ |
52 UNS8 whoami; /**< Takes the values SDO_CLIENT or SDO_SERVER */ |
42 UNS8 state; /* state of the transmission : Takes the values SDO_... */ |
53 UNS8 state; /**< state of the transmission : Takes the values SDO_... */ |
43 UNS8 toggle; |
54 UNS8 toggle; |
44 UNS32 abortCode; /* Sent or received */ |
55 UNS32 abortCode; /**< Sent or received */ |
45 /* index and subindex of the dictionary where to store */ |
56 /**< index and subindex of the dictionary where to store */ |
46 /* (for a received SDO) or to read (for a transmit SDO) */ |
57 /**< (for a received SDO) or to read (for a transmit SDO) */ |
47 UNS16 index; |
58 UNS16 index; |
48 UNS8 subIndex; |
59 UNS8 subIndex; |
49 UNS32 count; /* Number of data received or to be sent. */ |
60 UNS32 count; /**< Number of data received or to be sent. */ |
50 UNS32 offset; /* stack pointer of data[] |
61 UNS32 offset; /**< stack pointer of data[] |
51 * Used only to tranfer part of a line to or from a SDO. |
62 * Used only to tranfer part of a line to or from a SDO. |
52 * offset is always pointing on the next free cell of data[]. |
63 * offset is always pointing on the next free cell of data[]. |
53 * WARNING s_transfer.data is subject to ENDIANISATION |
64 * WARNING s_transfer.data is subject to ENDIANISATION |
54 * (with respect to CANOPEN_BIG_ENDIAN) |
65 * (with respect to CANOPEN_BIG_ENDIAN) |
55 */ |
66 */ |
56 UNS8 data [SDO_MAX_LENGTH_TRANSFERT]; |
67 UNS8 data [SDO_MAX_LENGTH_TRANSFERT]; |
57 UNS8 dataType; /* Defined in objdictdef.h Value is visible_string |
68 UNS8 dataType; /**< Defined in objdictdef.h Value is visible_string |
58 * if it is a string, any other value if it is not a string, |
69 * if it is a string, any other value if it is not a string, |
59 * like 0. In fact, it is used only if client. |
70 * like 0. In fact, it is used only if client. |
60 */ |
71 */ |
61 TIMER_HANDLE timer; /* Time counter to implement a timeout in milliseconds. |
72 TIMER_HANDLE timer; /**< Time counter to implement a timeout in milliseconds. |
62 * It is automatically incremented whenever |
73 * It is automatically incremented whenever |
63 * the line state is in SDO_DOWNLOAD_IN_PROGRESS or |
74 * the line state is in SDO_DOWNLOAD_IN_PROGRESS or |
64 * SDO_UPLOAD_IN_PROGRESS, and reseted to 0 |
75 * SDO_UPLOAD_IN_PROGRESS, and reseted to 0 |
65 * when the response SDO have been received. |
76 * when the response SDO have been received. |
66 */ |
77 */ |
67 SDOCallback_t Callback; /* The user callback func to be called at SDO transaction end */ |
78 SDOCallback_t Callback; /**< The user callback func to be called at SDO transaction end */ |
68 }; |
79 }; |
69 typedef struct struct_s_transfer s_transfer; |
80 typedef struct struct_s_transfer s_transfer; |
70 |
81 |
71 |
82 |
72 #include "data.h" |
83 #include "data.h" |
73 |
84 |
74 /* The 8 bytes data of the SDO */ |
85 |
75 struct BODY{ |
86 struct BODY{ |
76 UNS8 data[8]; |
87 UNS8 data[8]; /**< The 8 bytes data of the SDO */ |
77 }; |
88 }; |
78 |
89 |
79 /* The SDO structure ...*/ |
90 /* The SDO structure ...*/ |
80 struct struct_s_SDO { |
91 struct struct_s_SDO { |
81 UNS8 nodeId; /*in any case, Node ID of the server (case sender or receiver).*/ |
92 UNS8 nodeId; /**< In any case, Node ID of the server (case sender or receiver).*/ |
82 struct BODY body; |
93 struct BODY body; |
83 }; |
94 }; |
84 |
95 |
85 |
96 |
86 typedef struct struct_s_SDO s_SDO; |
97 typedef struct struct_s_SDO s_SDO; |
87 |
98 |
88 /** Reset of a SDO exchange on timeout. |
99 /** |
89 * Send a SDO abort |
100 * @brief Reset of a SDO exchange on timeout. |
|
101 * Send a SDO abort. |
|
102 * @param *d Pointer on a CAN object data structure |
|
103 * @param id |
90 */ |
104 */ |
91 void SDOTimeoutAlarm(CO_Data* d, UNS32 id); |
105 void SDOTimeoutAlarm(CO_Data* d, UNS32 id); |
92 |
106 |
93 /** Reset all sdo buffers |
107 /** |
|
108 * @brief Reset all SDO buffers. |
|
109 * @param *d Pointer on a CAN object data structure |
94 */ |
110 */ |
95 void resetSDO (CO_Data* d); |
111 void resetSDO (CO_Data* d); |
96 |
112 |
97 |
113 |
98 /** Copy the data received from the SDO line transfert to the object dictionary |
114 /** |
99 * Returns SDO error code if error. Else, returns 0; |
115 * @brief Copy the data received from the SDO line transfert to the object dictionary. |
|
116 * @param *d Pointer on a CAN object data structure |
|
117 * @param line SDO line |
|
118 * @return SDO error code if error. Else, returns 0. |
100 */ |
119 */ |
101 UNS32 SDOlineToObjdict (CO_Data* d, UNS8 line); |
120 UNS32 SDOlineToObjdict (CO_Data* d, UNS8 line); |
102 |
121 |
103 /** Copy the data from the object dictionary to the SDO line for a network transfert. |
122 /** |
104 * Returns SDO error code if error. Else, returns 0; |
123 * @brief Copy the data from the object dictionary to the SDO line for a network transfert. |
|
124 * @param *d Pointer on a CAN object data structure |
|
125 * @param line SDO line |
|
126 * @return SDO error code if error. Else, returns 0. |
105 */ |
127 */ |
106 UNS32 objdictToSDOline (CO_Data* d, UNS8 line); |
128 UNS32 objdictToSDOline (CO_Data* d, UNS8 line); |
107 |
129 |
108 /** copy data from an existant line in the argument "* data" |
130 /** |
109 * Returns 0xFF if error. Else, returns 0; |
131 * @brief Copy data from an existant line in the argument "* data" |
|
132 * @param d Pointer on a CAN object data structure |
|
133 * @param line SDO line |
|
134 * @param nbBytes |
|
135 * @param *data Pointer on the data |
|
136 * @return 0xFF if error. Else, returns 0. |
110 */ |
137 */ |
111 UNS8 lineToSDO (CO_Data* d, UNS8 line, UNS8 nbBytes, UNS8 * data); |
138 UNS8 lineToSDO (CO_Data* d, UNS8 line, UNS8 nbBytes, UNS8 * data); |
112 |
139 |
113 /** Add data to an existant line |
140 /** |
114 * Returns 0xFF if error. Else, returns 0; |
141 * @brief Add data to an existant line |
|
142 * @param d Pointer on a CAN object data structure |
|
143 * @param line SDO line |
|
144 * @param nbBytes |
|
145 * @param *data Pointer on the data |
|
146 * @return 0xFF if error. Else, returns 0. |
115 */ |
147 */ |
116 UNS8 SDOtoLine (CO_Data* d, UNS8 line, UNS8 nbBytes, UNS8 * data); |
148 UNS8 SDOtoLine (CO_Data* d, UNS8 line, UNS8 nbBytes, UNS8 * data); |
117 |
149 |
118 /** Called when an internal SDO abort occurs. |
150 /** |
|
151 * @brief Called when an internal SDO abort occurs. |
119 * Release the line * Only if server * |
152 * Release the line * Only if server * |
120 * If client, the line must be released manually in the core application. |
153 * If client, the line must be released manually in the core application. |
121 * The reason of that is to permit the program to read the transfers[][] structure before its reset, |
154 * The reason of that is to permit the program to read the transfers structure before its reset, |
122 * because many informations are stored on it : index, subindex, data received or trasmited, ... |
155 * because many informations are stored on it : index, subindex, data received or trasmited, ... |
123 * In all cases, sends a SDO abort. |
156 * In all cases, sends a SDO abort. |
124 * Returns 0 |
157 * @param *d Pointer on a CAN object data structure |
125 */ |
158 * @param nodeId |
126 UNS8 failedSDO (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS16 index, |
159 * @param whoami |
127 UNS8 subIndex, UNS32 abortCode); |
160 * @param index |
128 |
161 * @param subIndex |
129 /** Reset an unused line. |
162 * @param abortCode |
130 * |
163 * @return 0 |
|
164 */ |
|
165 UNS8 failedSDO (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS16 index, UNS8 subIndex, UNS32 abortCode); |
|
166 |
|
167 /** |
|
168 * @brief Reset an unused line. |
|
169 * @param *d Pointer on a CAN object data structure |
|
170 * @param line SDO line |
131 */ |
171 */ |
132 void resetSDOline (CO_Data* d, UNS8 line); |
172 void resetSDOline (CO_Data* d, UNS8 line); |
133 |
173 |
134 /** Initialize some fields of the structure. |
174 /** |
135 * Returns 0 |
175 * @brief Initialize some fields of the structure. |
|
176 * @param *d Pointer on a CAN object data structure |
|
177 * @param line |
|
178 * @param nodeId |
|
179 * @param index |
|
180 * @param subIndex |
|
181 * @param state |
|
182 * @return 0 |
136 */ |
183 */ |
137 UNS8 initSDOline (CO_Data* d, UNS8 line, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 state); |
184 UNS8 initSDOline (CO_Data* d, UNS8 line, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 state); |
138 |
185 |
139 /** Search for an unused line in the transfers array |
186 /** |
|
187 * @brief Search for an unused line in the transfers array |
140 * to store a new SDO. |
188 * to store a new SDO. |
141 * ie a line which value of the field "state" is "SDO_RESET" |
189 * ie a line which value of the field "state" is "SDO_RESET" |
142 * An unused line have the field "state" at the value SDO_RESET |
190 * An unused line have the field "state" at the value SDO_RESET |
143 * bus_id is hardware dependant |
191 * bus_id is hardware dependant |
144 * whoami : create the line for a SDO_SERVER or SDO_CLIENT. |
192 * @param *d Pointer on a CAN object data structure |
145 * return 0xFF if all the lines are on use. Else, return 0 |
193 * @param whoami Create the line for a SDO_SERVER or SDO_CLIENT. |
|
194 * @param *line Pointer on a SDO line |
|
195 * @return 0xFF if all the lines are on use. Else, return 0. |
146 */ |
196 */ |
147 UNS8 getSDOfreeLine (CO_Data* d, UNS8 whoami, UNS8 *line); |
197 UNS8 getSDOfreeLine (CO_Data* d, UNS8 whoami, UNS8 *line); |
148 |
198 |
149 /** Search for the line, in the transfers array, which contains the |
199 /** |
|
200 * @brief Search for the line, in the transfers array, which contains the |
150 * beginning of the reception of a fragmented SDO |
201 * beginning of the reception of a fragmented SDO |
151 * whoami takes 2 values : look for a line opened as SDO_CLIENT or SDO_SERVER |
|
152 * bus_id is hardware dependant |
202 * bus_id is hardware dependant |
153 * nodeId correspond to the message node-id |
203 * @param *d Pointer on a CAN object data structure |
154 * return 0xFF if error. Else, return 0 |
204 * @param nodeId correspond to the message node-id |
|
205 * @param whoami takes 2 values : look for a line opened as SDO_CLIENT or SDO_SERVER |
|
206 * @param *line Pointer on a SDO line |
|
207 * @return 0xFF if error. Else, return 0 |
155 */ |
208 */ |
156 UNS8 getSDOlineOnUse (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS8 *line); |
209 UNS8 getSDOlineOnUse (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS8 *line); |
157 |
210 |
158 /** Close a transmission. |
211 /** |
159 * nodeId : Node id of the server if both server or client |
212 * @brief Close a transmission. |
160 * whoami : Line opened as SDO_CLIENT or SDO_SERVER |
213 * @param *d Pointer on a CAN object data structure |
|
214 * @param nodeId Node id of the server if both server or client |
|
215 * @param whoami Line opened as SDO_CLIENT or SDO_SERVER |
161 */ |
216 */ |
162 UNS8 closeSDOtransfer (CO_Data* d, UNS8 nodeId, UNS8 whoami); |
217 UNS8 closeSDOtransfer (CO_Data* d, UNS8 nodeId, UNS8 whoami); |
163 |
218 |
164 /** Bytes in the line structure which must be transmited (or received) |
219 /** |
|
220 * @brief Bytes in the line structure which must be transmited (or received) |
165 * bus_id is hardware dependant. |
221 * bus_id is hardware dependant. |
166 * return 0. |
222 * @param *d Pointer on a CAN object data structure |
|
223 * @param line SDO line |
|
224 * @param *nbBytes Pointer on nbBytes |
|
225 * @return 0. |
167 */ |
226 */ |
168 UNS8 getSDOlineRestBytes (CO_Data* d, UNS8 line, UNS8 * nbBytes); |
227 UNS8 getSDOlineRestBytes (CO_Data* d, UNS8 line, UNS8 * nbBytes); |
169 |
228 |
170 /** Store in the line structure the nb of bytes which must be transmited (or received) |
229 /** |
|
230 * @brief Store in the line structure the nb of bytes which must be transmited (or received) |
171 * bus_id is hardware dependant. |
231 * bus_id is hardware dependant. |
172 * return 0 if success, 0xFF if error. |
232 * @param *d Pointer on a CAN object data structure |
|
233 * @param line SDO line |
|
234 * @param nbBytes |
|
235 * @return 0 if success, 0xFF if error. |
173 */ |
236 */ |
174 UNS8 setSDOlineRestBytes (CO_Data* d, UNS8 line, UNS8 nbBytes); |
237 UNS8 setSDOlineRestBytes (CO_Data* d, UNS8 line, UNS8 nbBytes); |
175 |
238 |
176 /** Transmit a SDO frame on the bus bus_id |
239 /** |
177 * sdo is a structure which contains the sdo to transmit |
240 * @brief Transmit a SDO frame on the bus bus_id |
178 * bus_id is hardware dependant |
241 * bus_id is hardware dependant |
179 * whoami takes 2 values : SDO_CLIENT or SDO_SERVER |
242 * @param *d Pointer on a CAN object data structure |
180 * return canSend(bus_id,&m) or 0xFF if error |
243 * @param whoami Takes 2 values : SDO_CLIENT or SDO_SERVER |
|
244 * @param sdo SDO Structure which contains the sdo to transmit |
|
245 * @return canSend(bus_id,&m) or 0xFF if error. |
181 */ |
246 */ |
182 UNS8 sendSDO (CO_Data* d, UNS8 whoami, s_SDO sdo); |
247 UNS8 sendSDO (CO_Data* d, UNS8 whoami, s_SDO sdo); |
183 |
248 |
184 /** Transmit a SDO error to the client. The reasons may be : |
249 /** |
|
250 * @brief Transmit a SDO error to the client. The reasons may be : |
185 * Read/Write to a undefined object |
251 * Read/Write to a undefined object |
186 * Read/Write to a undefined subindex |
252 * Read/Write to a undefined subindex |
187 * Read/write a not valid length object |
253 * Read/write a not valid length object |
188 * Write a read only object |
254 * Write a read only object |
189 * whoami takes 2 values : SDO_CLIENT or SDO_SERVER |
255 * @param *d Pointer on a CAN object data structure |
|
256 * @param whoami takes 2 values : SDO_CLIENT or SDO_SERVER |
|
257 * @param nodeId |
|
258 * @param index |
|
259 * @param subIndex |
|
260 * @param abortCode |
|
261 * @return 0 |
190 */ |
262 */ |
191 UNS8 sendSDOabort (CO_Data* d, UNS8 whoami, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS32 abortCode); |
263 UNS8 sendSDOabort (CO_Data* d, UNS8 whoami, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS32 abortCode); |
192 |
264 |
193 /** Treat a SDO frame reception |
265 /** |
|
266 * @brief Treat a SDO frame reception |
194 * bus_id is hardware dependant |
267 * bus_id is hardware dependant |
195 * call the function sendSDO |
268 * call the function sendSDO |
196 * return 0xFF if error |
269 * @param *d Pointer on a CAN object data structure |
197 * 0x80 if transfert aborted by the server |
270 * @param *m Pointer on a CAN message structure |
198 * 0x0 ok |
271 * @return code : |
|
272 * - 0xFF if error |
|
273 * - 0x80 if transfert aborted by the server |
|
274 * - 0x0 ok |
199 */ |
275 */ |
200 UNS8 proceedSDO (CO_Data* d, Message *m); |
276 UNS8 proceedSDO (CO_Data* d, Message *m); |
201 |
277 |
202 /** Used by the application to send a SDO request frame to write the data *data |
278 /** |
|
279 * @ingroup sdo |
|
280 * @brief Used by the application to send a SDO request frame to write the data *data |
203 * at the index and subIndex indicated |
281 * at the index and subIndex indicated |
204 * in the dictionary of the slave whose node_id is nodeId |
|
205 * Count : nb of bytes to write in the dictionnary. |
|
206 * datatype (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value. |
|
207 * bus_id is hardware dependant |
282 * bus_id is hardware dependant |
208 * return 0xFF if error, else return 0 |
283 * @param *d Pointer on a CAN object data structure |
|
284 * @param nodeId In the dictionary of the slave whose node_id is nodeId |
|
285 * @param index At index indicated |
|
286 * @param subIndex At subIndex indicated |
|
287 * @param count number of bytes to write in the dictionnary. |
|
288 * @param dataType (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value. |
|
289 * @param *data Pointer on data |
|
290 * @return 0xFF if error, else return 0 |
209 */ |
291 */ |
210 UNS8 writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, |
292 UNS8 writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, |
211 UNS8 subIndex, UNS8 count, UNS8 dataType, void *data); |
293 UNS8 subIndex, UNS8 count, UNS8 dataType, void *data); |
212 /** Used to send a SDO request frame to write in a distant node dictionnary. |
294 |
213 * The function Callback which must be defined in the user code is called at the |
295 /** |
|
296 * @ingroup sdo |
|
297 * @brief Used to send a SDO request frame to write in a distant node dictionnary. |
|
298 * The function Callback which must be defined in the user code is called at the |
214 * end of the exchange. (on succes or abort). |
299 * end of the exchange. (on succes or abort). |
|
300 * @param *d Pointer on a CAN object data structure |
|
301 * @param nodeId In the dictionary of the slave whose node_id is nodeId |
|
302 * @param index At index indicated |
|
303 * @param subIndex At subIndex indicated |
|
304 * @param count number of bytes to write in the dictionnary. |
|
305 * @param dataType (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value. |
|
306 * @param *data Pointer on data |
|
307 * @param Callback Callback function |
|
308 * @return 0xFF if error, else return 0 |
215 */ |
309 */ |
216 UNS8 writeNetworkDictCallBack (CO_Data* d, UNS8 nodeId, UNS16 index, |
310 UNS8 writeNetworkDictCallBack (CO_Data* d, UNS8 nodeId, UNS16 index, |
217 UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback); |
311 UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback); |
218 /** Used to send a SDO request frame to write in a distant node dictionnary. |
312 |
|
313 /** |
|
314 * @ingroup sdo |
|
315 * @brief Used to send a SDO request frame to write in a distant node dictionnary. |
219 * The function Callback which must be defined in the user code is called at the |
316 * The function Callback which must be defined in the user code is called at the |
220 * end of the exchange. (on succes or abort). First free SDO client parameter is |
317 * end of the exchange. (on succes or abort). First free SDO client parameter is |
221 * automatically initialized for specific node if not already defined. |
318 * automatically initialized for specific node if not already defined. |
|
319 * @param *d Pointer on a CAN object data structure |
|
320 * @param nodeId In the dictionary of the slave whose node_id is nodeId |
|
321 * @param index At index indicated |
|
322 * @param subIndex At subIndex indicated |
|
323 * @param count number of bytes to write in the dictionnary. |
|
324 * @param dataType (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value. |
|
325 * @param *data Pointer on data |
|
326 * @param Callback Callback function |
|
327 * @param endianize |
|
328 * @return 0xFF if error, else return 0 |
222 */ |
329 */ |
223 UNS8 writeNetworkDictCallBackAI (CO_Data* d, UNS8 nodeId, UNS16 index, |
330 UNS8 writeNetworkDictCallBackAI (CO_Data* d, UNS8 nodeId, UNS16 index, |
224 UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize); |
331 UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize); |
225 /** Used by the application to send a SDO request frame to read |
332 |
226 * in the dictionary of a server node whose node_id is ID |
333 /** |
227 * at the index and subIndex indicated |
334 * @ingroup sdo |
228 * bus_id is hardware dependant |
335 * @brief Used by the application to send a SDO request frame to read |
229 * datatype (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value. |
336 * @param *d Pointer on a CAN object data structure |
230 * return 0xFF if error, else return 0 |
337 * @param nodeId In the dictionary of the slave whose node_id is nodeId |
231 */ |
338 * @param index At index indicated |
232 UNS8 readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, |
339 * @param subIndex At subIndex indicated |
233 UNS8 subIndex, UNS8 dataType); |
340 * @param dataType (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value. * bus_id is hardware dependant |
234 |
341 * @return 0xFF if error, else return 0 |
235 /** Used to send a SDO request frame to read in a distant node dictionnary. |
342 */ |
236 * The function Callback which must be defined in the user code is called at the |
343 UNS8 readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType); |
|
344 |
|
345 /** |
|
346 * @ingroup sdo |
|
347 * @brief Used to send a SDO request frame to read in a distant node dictionnary. |
|
348 * The function Callback which must be defined in the user code is called at the |
237 * end of the exchange. (on succes or abort). |
349 * end of the exchange. (on succes or abort). |
|
350 * @param *d Pointer on a CAN object data structure |
|
351 * @param nodeId In the dictionary of the slave whose node_id is nodeId |
|
352 * @param index At index indicated |
|
353 * @param subIndex At subIndex indicated |
|
354 * @param dataType (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value. |
|
355 * @param Callback Callback function |
|
356 * @return 0xFF if error, else return 0 |
238 */ |
357 */ |
239 UNS8 readNetworkDictCallback (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback); |
358 UNS8 readNetworkDictCallback (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback); |
240 |
359 |
241 /** Used to send a SDO request frame to read in a distant node dictionnary. |
360 /** |
|
361 * @ingroup sdo |
|
362 * @brief Used to send a SDO request frame to read in a distant node dictionnary. |
242 * The function Callback which must be defined in the user code is called at the |
363 * The function Callback which must be defined in the user code is called at the |
243 * end of the exchange. (on succes or abort). First free SDO client parameter is |
364 * end of the exchange. (on succes or abort). First free SDO client parameter is |
244 * automatically initialized for specific node if not already defined. |
365 * automatically initialized for specific node if not already defined. |
|
366 * @param *d Pointer on a CAN object data structure |
|
367 * @param nodeId In the dictionary of the slave whose node_id is nodeId |
|
368 * @param index At index indicated |
|
369 * @param subIndex At subIndex indicated |
|
370 * @param dataType (defined in objdictdef.h) : put "visible_string" for strings, 0 for integers or reals or other value. |
|
371 * @param Callback Callback function |
|
372 * @return 0xFF if error, else return 0 |
245 */ |
373 */ |
246 UNS8 readNetworkDictCallbackAI (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback); |
374 UNS8 readNetworkDictCallbackAI (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback); |
247 |
375 |
248 /** Use this function after a readNetworkDict to get the result. |
376 /** |
249 Returns : SDO_FINISHED // data is available |
377 * @ingroup sdo |
250 SDO_ABORTED_RCV // Transfert failed. (abort SDO received) |
378 * @brief Use this function after a readNetworkDict to get the result. |
251 SDO_ABORTED_INTERNAL // Transfert failed. Internal abort. |
379 * @param *d Pointer on a CAN object data structure |
252 SDO_UPLOAD_IN_PROGRESS // Data not yet available |
380 * @param nodeId In the dictionary of the slave whose node_id is nodeId |
253 SDO_DOWNLOAD_IN_PROGRESS // Should not arrive ! |
381 * @param *data Pointer on data |
254 |
382 * @param *size Pointer on size |
255 dataType (defined in objdictdef.h) : type expected. put "visible_string" for strings, 0 for integers or reals. |
383 * @param *abortCode Pointer on the abortcode. 0 = not available. Else : SDO abort code. (received if return SDO_ABORTED_RCV) |
256 abortCode : 0 = not available. Else : SDO abort code. (received if return SDO_ABORTED_RCV) |
384 * |
257 example : |
385 * |
258 UNS32 data; |
386 * @return |
259 UNS8 size; |
387 * - SDO_FINISHED // data is available |
260 readNetworkDict(0, 0x05, 0x1016, 1, 0) // get the data index 1016 subindex 1 of node 5 |
388 * - SDO_ABORTED_RCV // Transfert failed. (abort SDO received) |
261 while (getReadResultNetworkDict (0, 0x05, &data, &size) != SDO_UPLOAD_IN_PROGRESS); |
389 * - SDO_ABORTED_INTERNAL // Transfert failed. Internal abort. |
|
390 * - SDO_UPLOAD_IN_PROGRESS // Data not yet available |
|
391 * - SDO_DOWNLOAD_IN_PROGRESS // Should not arrive ! |
|
392 * |
|
393 * example : |
|
394 * UNS32 data; |
|
395 * UNS8 size; |
|
396 * readNetworkDict(0, 0x05, 0x1016, 1, 0) // get the data index 1016 subindex 1 of node 5 |
|
397 * while (getReadResultNetworkDict (0, 0x05, &data, &size) != SDO_UPLOAD_IN_PROGRESS); |
262 */ |
398 */ |
263 UNS8 getReadResultNetworkDict (CO_Data* d, UNS8 nodeId, void* data, |
399 UNS8 getReadResultNetworkDict (CO_Data* d, UNS8 nodeId, void* data, UNS8 *size, UNS32 * abortCode); |
264 UNS8 *size, UNS32 * abortCode); |
|
265 |
400 |
266 /** |
401 /** |
267 Use this function after a writeNetworkDict to get the result of the write |
402 * @brief Use this function after a writeNetworkDict to get the result of the write |
268 It is mandatory to call this function because it is releasing the line used for the transfer. |
403 * It is mandatory to call this function because it is releasing the line used for the transfer. |
269 Returns : SDO_FINISHED // data is available |
404 * @param *d Pointer on a CAN object data structure |
270 SDO_ABORTED_RCV // Transfert failed. (abort SDO received) |
405 * @param nodeId In the dictionary of the slave whose node_id is nodeId |
271 SDO_ABORTED_INTERNAL // Transfert failed. Internal abort. |
406 * @param *abortCode Pointer on the abortcode. 0 = not available. Else : SDO abort code. (received if return SDO_ABORTED_RCV) |
272 SDO_DOWNLOAD_IN_PROGRESS // Data not yet available |
407 * |
273 SDO_UPLOAD_IN_PROGRESS // Should not arrive ! |
408 * @return : |
274 abortCode : 0 = not available. Else : SDO abort code. (received if return SDO_ABORTED_RCV) |
409 * - SDO_FINISHED // data is available |
275 example : |
410 * - SDO_ABORTED_RCV // Transfert failed. (abort SDO received) |
276 UNS32 data = 0x50; |
411 * - SDO_ABORTED_INTERNAL // Transfert failed. Internal abort. |
277 UNS8 size; |
412 * - SDO_DOWNLOAD_IN_PROGRESS // Data not yet available |
278 UNS32 abortCode; |
413 * - SDO_UPLOAD_IN_PROGRESS // Should not arrive ! |
279 writeNetworkDict(0, 0x05, 0x1016, 1, size, &data) // write the data index 1016 subindex 1 of node 5 |
414 * |
280 while ( getWriteResultNetworkDict (0, 0x05, &abortCode) != SDO_DOWNLOAD_IN_PROGRESS); |
415 * example : |
|
416 * UNS32 data = 0x50; |
|
417 * UNS8 size; |
|
418 * UNS32 abortCode; |
|
419 * writeNetworkDict(0, 0x05, 0x1016, 1, size, &data) // write the data index 1016 subindex 1 of node 5 |
|
420 * while (getWriteResultNetworkDict (0, 0x05, &abortCode) != SDO_DOWNLOAD_IN_PROGRESS); |
281 */ |
421 */ |
282 UNS8 getWriteResultNetworkDict (CO_Data* d, UNS8 nodeId, UNS32 * abortCode); |
422 UNS8 getWriteResultNetworkDict (CO_Data* d, UNS8 nodeId, UNS32 * abortCode); |
283 |
423 |
284 |
|
285 |
|
286 |
|
287 #endif |
424 #endif |