author | Christian Taedcke |
Thu, 09 Sep 2010 15:56:06 +0200 | |
changeset 636 | 033fe6f1ec3c |
parent 627 | 4939452b1bf1 |
child 651 | 2a36570aa68c |
permissions | -rw-r--r-- |
0 | 1 |
/* |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
2 |
This file is part of CanFestival, a library implementing CanOpen Stack. |
0 | 3 |
|
4 |
Copyright (C): Edouard TISSERANT and Francis DUPIN |
|
5 |
||
6 |
See COPYING file for copyrights details. |
|
7 |
||
8 |
This library is free software; you can redistribute it and/or |
|
9 |
modify it under the terms of the GNU Lesser General Public |
|
10 |
License as published by the Free Software Foundation; either |
|
11 |
version 2.1 of the License, or (at your option) any later version. |
|
12 |
||
13 |
This library is distributed in the hope that it will be useful, |
|
14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
16 |
Lesser General Public License for more details. |
|
17 |
||
18 |
You should have received a copy of the GNU Lesser General Public |
|
19 |
License along with this library; if not, write to the Free Software |
|
20 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
21 |
*/ |
|
208 | 22 |
/*! |
23 |
** @file sdo.c |
|
24 |
** @author Edouard TISSERANT and Francis DUPIN |
|
25 |
** @date Tue Jun 5 09:32:32 2007 |
|
26 |
** |
|
27 |
** @brief |
|
28 |
** |
|
29 |
** |
|
30 |
*/ |
|
0 | 31 |
|
84 | 32 |
/* #define DEBUG_WAR_CONSOLE_ON */ |
33 |
/* #define DEBUG_ERR_CONSOLE_ON */ |
|
0 | 34 |
|
383 | 35 |
#include "canfestival.h" |
370
6fecf36df407
Fixed some endianization problems caused by switch to UNS16 for cob_id member in CAN messages. To be continued.
etisserant
parents:
365
diff
changeset
|
36 |
#include "sysdep.h" |
0 | 37 |
|
71 | 38 |
/* Uncomment if your compiler does not support inline functions */ |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
39 |
#define NO_INLINE |
71 | 40 |
|
41 |
#ifdef NO_INLINE |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
42 |
#define INLINE |
71 | 43 |
#else |
86 | 44 |
#define INLINE inline |
71 | 45 |
#endif |
46 |
||
53 | 47 |
/*Internals prototypes*/ |
48 |
||
208 | 49 |
/*! |
50 |
** Called by writeNetworkDict |
|
51 |
** |
|
52 |
** @param d |
|
53 |
** @param nodeId |
|
54 |
** @param index |
|
55 |
** @param subIndex |
|
56 |
** @param count |
|
57 |
** @param dataType |
|
58 |
** @param data |
|
59 |
** @param Callback |
|
60 |
** @param endianize |
|
61 |
** |
|
62 |
** @return |
|
63 |
**/ |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
64 |
INLINE UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, |
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
65 |
UNS8 subIndex, UNS32 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize); |
53 | 66 |
|
208 | 67 |
/*! |
68 |
** Called by readNetworkDict |
|
69 |
** |
|
70 |
** @param d |
|
71 |
** @param nodeId |
|
72 |
** @param index |
|
73 |
** @param subIndex |
|
74 |
** @param dataType |
|
75 |
** @param Callback |
|
76 |
** |
|
77 |
** @return |
|
78 |
**/ |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
79 |
INLINE UNS8 _readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, |
53 | 80 |
UNS8 dataType, SDOCallback_t Callback); |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
81 |
|
53 | 82 |
|
0 | 83 |
/***************************************************************************/ |
71 | 84 |
/* SDO (un)packing macros */ |
0 | 85 |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
86 |
/** Returns the command specifier (cs, ccs, scs) from the first byte of the SDO |
0 | 87 |
*/ |
88 |
#define getSDOcs(byte) (byte >> 5) |
|
89 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
90 |
/** Returns the number of bytes without data from the first byte of the SDO. Coded in 2 bits |
0 | 91 |
*/ |
92 |
#define getSDOn2(byte) ((byte >> 2) & 3) |
|
93 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
94 |
/** Returns the number of bytes without data from the first byte of the SDO. Coded in 3 bits |
0 | 95 |
*/ |
96 |
#define getSDOn3(byte) ((byte >> 1) & 7) |
|
97 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
98 |
/** Returns the transfer type from the first byte of the SDO |
0 | 99 |
*/ |
100 |
#define getSDOe(byte) ((byte >> 1) & 1) |
|
101 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
102 |
/** Returns the size indicator from the first byte of the SDO |
0 | 103 |
*/ |
104 |
#define getSDOs(byte) (byte & 1) |
|
105 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
106 |
/** Returns the indicator of end transmission from the first byte of the SDO |
0 | 107 |
*/ |
108 |
#define getSDOc(byte) (byte & 1) |
|
109 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
110 |
/** Returns the toggle from the first byte of the SDO |
0 | 111 |
*/ |
112 |
#define getSDOt(byte) ((byte >> 4) & 1) |
|
113 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
114 |
/** Returns the index from the bytes 1 and 2 of the SDO |
0 | 115 |
*/ |
604 | 116 |
#define getSDOindex(byte1, byte2) (((UNS16)byte2 << 8) | ((UNS16)byte1)) |
0 | 117 |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
118 |
/** Returns the subIndex from the byte 3 of the SDO |
0 | 119 |
*/ |
120 |
#define getSDOsubIndex(byte3) (byte3) |
|
121 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
122 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
123 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
124 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
125 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
126 |
** @param id |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
127 |
**/ |
0 | 128 |
void SDOTimeoutAlarm(CO_Data* d, UNS32 id) |
129 |
{ |
|
130 |
MSG_ERR(0x1A01, "SDO timeout. SDO response not received.", 0); |
|
131 |
MSG_WAR(0x2A02, "server node : ", d->transfers[id].nodeId); |
|
132 |
MSG_WAR(0x2A02, " index : ", d->transfers[id].index); |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
133 |
MSG_WAR(0x2A02, " subIndex : ", d->transfers[id].subIndex); |
71 | 134 |
/* Reset timer handler */ |
0 | 135 |
d->transfers[id].timer = TIMER_NONE; |
172
0248c2b148bb
Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents:
166
diff
changeset
|
136 |
/*Set aborted state*/ |
0248c2b148bb
Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents:
166
diff
changeset
|
137 |
d->transfers[id].state = SDO_ABORTED_INTERNAL; |
71 | 138 |
/* Sending a SDO abort */ |
499
061f12bd838b
getReadResultNetworkDict now returns abortcode. Now, abort message should be sent correctly from client.
etisserant
parents:
495
diff
changeset
|
139 |
sendSDOabort(d, d->transfers[id].whoami, d->transfers[id].nodeId, |
0 | 140 |
d->transfers[id].index, d->transfers[id].subIndex, SDOABT_TIMED_OUT); |
172
0248c2b148bb
Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents:
166
diff
changeset
|
141 |
d->transfers[id].abortCode = SDOABT_TIMED_OUT; |
0248c2b148bb
Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents:
166
diff
changeset
|
142 |
/* Call the user function to inform of the problem.*/ |
0248c2b148bb
Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents:
166
diff
changeset
|
143 |
if(d->transfers[id].Callback) |
0248c2b148bb
Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents:
166
diff
changeset
|
144 |
/*If ther is a callback, it is responsible to close SDO transfer (client)*/ |
0248c2b148bb
Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents:
166
diff
changeset
|
145 |
(*d->transfers[id].Callback)(d,d->transfers[id].nodeId); |
0248c2b148bb
Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents:
166
diff
changeset
|
146 |
else if(d->transfers[id].whoami == SDO_SERVER) |
0248c2b148bb
Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents:
166
diff
changeset
|
147 |
/*Else, if server, reset the line*/ |
0248c2b148bb
Removed SDOTimeout application callback.Please use SDO callbacks instead.
etisserant
parents:
166
diff
changeset
|
148 |
resetSDOline(d, (UNS8)id); |
0 | 149 |
} |
150 |
||
151 |
#define StopSDO_TIMER(id) \ |
|
152 |
MSG_WAR(0x3A05, "StopSDO_TIMER for line : ", line);\ |
|
153 |
d->transfers[id].timer = DelAlarm(d->transfers[id].timer); |
|
154 |
||
155 |
#define StartSDO_TIMER(id) \ |
|
156 |
MSG_WAR(0x3A06, "StartSDO_TIMER for line : ", line);\ |
|
157 |
d->transfers[id].timer = SetAlarm(d,id,&SDOTimeoutAlarm,MS_TO_TIMEVAL(SDO_TIMEOUT_MS),0); |
|
158 |
||
159 |
#define RestartSDO_TIMER(id) \ |
|
160 |
MSG_WAR(0x3A07, "restartSDO_TIMER for line : ", line);\ |
|
161 |
if(d->transfers[id].timer != TIMER_NONE) { StopSDO_TIMER(id) StartSDO_TIMER(id) } |
|
162 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
163 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
164 |
** Reset all sdo buffers |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
165 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
166 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
167 |
**/ |
0 | 168 |
void resetSDO (CO_Data* d) |
169 |
{ |
|
170 |
UNS8 j; |
|
171 |
||
215 | 172 |
/* transfer structure initialization */ |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
173 |
for (j = 0 ; j < SDO_MAX_SIMULTANEOUS_TRANSFERTS ; j++) |
0 | 174 |
resetSDOline(d, j); |
175 |
} |
|
176 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
177 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
178 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
179 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
180 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
181 |
** @param line |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
182 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
183 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
184 |
**/ |
0 | 185 |
UNS32 SDOlineToObjdict (CO_Data* d, UNS8 line) |
186 |
{ |
|
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
187 |
UNS32 size; |
0 | 188 |
UNS32 errorCode; |
1
b3dc740b4b04
Commit some Fix from Francis on sdo.c and abjacces.c. Fix endianisation problems while accessing OD. Also fix SDO abord handling bug.
etisserant
parents:
0
diff
changeset
|
189 |
MSG_WAR(0x3A08, "Enter in SDOlineToObjdict ", line); |
544
7620872e153c
Fixed bugs in SDO caused by UNS8->UNS32 size patch.
etisserant
parents:
539
diff
changeset
|
190 |
/* if SDO initiated with e=0 and s=0 count is null, offset carry effective size*/ |
7620872e153c
Fixed bugs in SDO caused by UNS8->UNS32 size patch.
etisserant
parents:
539
diff
changeset
|
191 |
if( d->transfers[line].count == 0) |
7620872e153c
Fixed bugs in SDO caused by UNS8->UNS32 size patch.
etisserant
parents:
539
diff
changeset
|
192 |
d->transfers[line].count = d->transfers[line].offset; |
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
193 |
size = d->transfers[line].count; |
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
194 |
|
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
195 |
#ifdef SDO_DYNAMIC_BUFFER_ALLOCATION |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
196 |
if (size > SDO_MAX_LENGTH_TRANSFERT) |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
197 |
{ |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
198 |
errorCode = setODentry(d, d->transfers[line].index, d->transfers[line].subIndex, |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
199 |
(void *) d->transfers[line].dynamicData, &size, 1); |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
200 |
} |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
201 |
else |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
202 |
{ |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
203 |
errorCode = setODentry(d, d->transfers[line].index, d->transfers[line].subIndex, |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
204 |
(void *) d->transfers[line].data, &size, 1); |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
205 |
} |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
206 |
#else //SDO_DYNAMIC_BUFFER_ALLOCATION |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
207 |
errorCode = setODentry(d, d->transfers[line].index, d->transfers[line].subIndex, |
0 | 208 |
(void *) d->transfers[line].data, &size, 1); |
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
209 |
#endif //SDO_DYNAMIC_BUFFER_ALLOCATION |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
210 |
|
0 | 211 |
if (errorCode != OD_SUCCESSFUL) |
212 |
return errorCode; |
|
1
b3dc740b4b04
Commit some Fix from Francis on sdo.c and abjacces.c. Fix endianisation problems while accessing OD. Also fix SDO abord handling bug.
etisserant
parents:
0
diff
changeset
|
213 |
MSG_WAR(0x3A08, "exit of SDOlineToObjdict ", line); |
0 | 214 |
return 0; |
215 |
||
216 |
} |
|
217 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
218 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
219 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
220 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
221 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
222 |
** @param line |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
223 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
224 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
225 |
**/ |
0 | 226 |
UNS32 objdictToSDOline (CO_Data* d, UNS8 line) |
227 |
{ |
|
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
228 |
UNS32 size = 0; |
0 | 229 |
UNS8 dataType; |
230 |
UNS32 errorCode; |
|
231 |
||
12 | 232 |
MSG_WAR(0x3A05, "objdict->line index : ", d->transfers[line].index); |
233 |
MSG_WAR(0x3A06, " subIndex : ", d->transfers[line].subIndex); |
|
0 | 234 |
|
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
235 |
#ifdef SDO_DYNAMIC_BUFFER_ALLOCATION |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
236 |
//TODO: Read the size of the object. Depending o it put data into data or dynamicData |
0 | 237 |
errorCode = getODentry(d, d->transfers[line].index, |
238 |
d->transfers[line].subIndex, |
|
239 |
(void *)d->transfers[line].data, |
|
402
77f875d45250
Fixed faulty read access checking on OD access. Added read acces s checking in SDO (was disabled)
etisserant
parents:
383
diff
changeset
|
240 |
&size, &dataType, 1); |
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
241 |
#else //SDO_DYNAMIC_BUFFER_ALLOCATION |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
242 |
errorCode = getODentry(d, d->transfers[line].index, |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
243 |
d->transfers[line].subIndex, |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
244 |
(void *)d->transfers[line].data, |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
245 |
&size, &dataType, 1); |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
246 |
#endif //SDO_DYNAMIC_BUFFER_ALLOCATION |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
247 |
|
0 | 248 |
if (errorCode != OD_SUCCESSFUL) |
249 |
return errorCode; |
|
250 |
||
251 |
d->transfers[line].count = size; |
|
252 |
d->transfers[line].offset = 0; |
|
402
77f875d45250
Fixed faulty read access checking on OD access. Added read acces s checking in SDO (was disabled)
etisserant
parents:
383
diff
changeset
|
253 |
|
0 | 254 |
return 0; |
255 |
} |
|
256 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
257 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
258 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
259 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
260 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
261 |
** @param line |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
262 |
** @param nbBytes |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
263 |
** @param data |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
264 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
265 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
266 |
**/ |
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
267 |
UNS8 lineToSDO (CO_Data* d, UNS8 line, UNS32 nbBytes, UNS8* data) { |
0 | 268 |
UNS8 i; |
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
269 |
UNS32 offset; |
0 | 270 |
|
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
271 |
#ifndef SDO_DYNAMIC_BUFFER_ALLOCATION |
0 | 272 |
if ((d->transfers[line].offset + nbBytes) > SDO_MAX_LENGTH_TRANSFERT) { |
273 |
MSG_ERR(0x1A10,"SDO Size of data too large. Exceed SDO_MAX_LENGTH_TRANSFERT", nbBytes); |
|
274 |
return 0xFF; |
|
275 |
} |
|
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
276 |
#endif //SDO_DYNAMIC_BUFFER_ALLOCATION |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
277 |
|
0 | 278 |
if ((d->transfers[line].offset + nbBytes) > d->transfers[line].count) { |
279 |
MSG_ERR(0x1A11,"SDO Size of data too large. Exceed count", nbBytes); |
|
280 |
return 0xFF; |
|
281 |
} |
|
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
282 |
offset = d->transfers[line].offset; |
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
283 |
#ifdef SDO_DYNAMIC_BUFFER_ALLOCATION |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
284 |
if (d->transfers[line].count <= SDO_MAX_LENGTH_TRANSFERT) |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
285 |
{ |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
286 |
for (i = 0 ; i < nbBytes ; i++) |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
287 |
* (data + i) = d->transfers[line].data[offset + i]; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
288 |
} |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
289 |
else |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
290 |
{ |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
291 |
if (d->transfers[line].dynamicData == NULL) |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
292 |
{ |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
293 |
MSG_ERR(0x1A11,"SDO's dynamic buffer not allocated. Line", line); |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
294 |
return 0xFF; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
295 |
} |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
296 |
for (i = 0 ; i < nbBytes ; i++) |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
297 |
* (data + i) = d->transfers[line].dynamicData[offset + i]; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
298 |
} |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
299 |
#else //SDO_DYNAMIC_BUFFER_ALLOCATION |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
300 |
for (i = 0 ; i < nbBytes ; i++) |
0 | 301 |
* (data + i) = d->transfers[line].data[offset + i]; |
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
302 |
#endif //SDO_DYNAMIC_BUFFER_ALLOCATION |
0 | 303 |
d->transfers[line].offset = d->transfers[line].offset + nbBytes; |
304 |
return 0; |
|
305 |
} |
|
306 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
307 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
308 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
309 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
310 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
311 |
** @param line |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
312 |
** @param nbBytes |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
313 |
** @param data |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
314 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
315 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
316 |
**/ |
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
317 |
UNS8 SDOtoLine (CO_Data* d, UNS8 line, UNS32 nbBytes, UNS8* data) |
0 | 318 |
{ |
319 |
UNS8 i; |
|
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
320 |
UNS32 offset; |
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
321 |
#ifndef SDO_DYNAMIC_BUFFER_ALLOCATION |
0 | 322 |
if ((d->transfers[line].offset + nbBytes) > SDO_MAX_LENGTH_TRANSFERT) { |
323 |
MSG_ERR(0x1A15,"SDO Size of data too large. Exceed SDO_MAX_LENGTH_TRANSFERT", nbBytes); |
|
324 |
return 0xFF; |
|
325 |
} |
|
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
326 |
#endif //SDO_DYNAMIC_BUFFER_ALLOCATION |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
327 |
|
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
328 |
offset = d->transfers[line].offset; |
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
329 |
#ifdef SDO_DYNAMIC_BUFFER_ALLOCATION |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
330 |
{ |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
331 |
UNS8* lineData = d->transfers[line].data; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
332 |
if ((d->transfers[line].offset + nbBytes) > SDO_MAX_LENGTH_TRANSFERT) { |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
333 |
if (d->transfers[line].dynamicData == NULL) { |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
334 |
d->transfers[line].dynamicData = (UNS8*) malloc(SDO_DYNAMIC_BUFFER_ALLOCATION_SIZE); |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
335 |
d->transfers[line].dynamicDataSize = SDO_DYNAMIC_BUFFER_ALLOCATION_SIZE; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
336 |
|
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
337 |
if (d->transfers[line].dynamicData == NULL) { |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
338 |
MSG_ERR(0x1A15,"SDO allocating dynamic buffer failed, size", SDO_DYNAMIC_BUFFER_ALLOCATION_SIZE); |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
339 |
return 0xFF; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
340 |
} |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
341 |
//Copy present data |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
342 |
memcpy(d->transfers[line].dynamicData, d->transfers[line].data, offset); |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
343 |
} |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
344 |
else if ((d->transfers[line].offset + nbBytes) > d->transfers[line].dynamicDataSize) |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
345 |
{ |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
346 |
UNS8* newDynamicBuffer = (UNS8*) realloc(d->transfers[line].dynamicData, d->transfers[line].dynamicDataSize + SDO_DYNAMIC_BUFFER_ALLOCATION_SIZE); |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
347 |
if (newDynamicBuffer == NULL) { |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
348 |
MSG_ERR(0x1A15,"SDO reallocating dynamic buffer failed, size", d->transfers[line].dynamicDataSize + SDO_DYNAMIC_BUFFER_ALLOCATION_SIZE); |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
349 |
return 0xFF; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
350 |
} |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
351 |
d->transfers[line].dynamicData = newDynamicBuffer; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
352 |
d->transfers[line].dynamicDataSize += SDO_DYNAMIC_BUFFER_ALLOCATION_SIZE; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
353 |
} |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
354 |
lineData = d->transfers[line].dynamicData; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
355 |
} |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
356 |
|
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
357 |
for (i = 0 ; i < nbBytes ; i++) |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
358 |
lineData[offset + i] = * (data + i); |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
359 |
} |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
360 |
#else //SDO_DYNAMIC_BUFFER_ALLOCATION |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
361 |
for (i = 0 ; i < nbBytes ; i++) |
0 | 362 |
d->transfers[line].data[offset + i] = * (data + i); |
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
363 |
#endif //SDO_DYNAMIC_BUFFER_ALLOCATION |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
364 |
|
0 | 365 |
d->transfers[line].offset = d->transfers[line].offset + nbBytes; |
366 |
return 0; |
|
367 |
} |
|
368 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
369 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
370 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
371 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
372 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
373 |
** @param nodeId |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
374 |
** @param whoami |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
375 |
** @param index |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
376 |
** @param subIndex |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
377 |
** @param abortCode |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
378 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
379 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
380 |
**/ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
381 |
UNS8 failedSDO (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS16 index, |
0 | 382 |
UNS8 subIndex, UNS32 abortCode) |
383 |
{ |
|
384 |
UNS8 err; |
|
385 |
UNS8 line; |
|
386 |
err = getSDOlineOnUse( d, nodeId, whoami, &line ); |
|
71 | 387 |
if (!err) /* If a line on use have been found.*/ |
0 | 388 |
MSG_WAR(0x3A20, "FailedSDO : line found : ", line); |
389 |
if ((! err) && (whoami == SDO_SERVER)) { |
|
390 |
resetSDOline( d, line ); |
|
391 |
MSG_WAR(0x3A21, "FailedSDO : line released : ", line); |
|
392 |
} |
|
1
b3dc740b4b04
Commit some Fix from Francis on sdo.c and abjacces.c. Fix endianisation problems while accessing OD. Also fix SDO abord handling bug.
etisserant
parents:
0
diff
changeset
|
393 |
if ((! err) && (whoami == SDO_CLIENT)) { |
b3dc740b4b04
Commit some Fix from Francis on sdo.c and abjacces.c. Fix endianisation problems while accessing OD. Also fix SDO abord handling bug.
etisserant
parents:
0
diff
changeset
|
394 |
StopSDO_TIMER(line); |
0 | 395 |
d->transfers[line].state = SDO_ABORTED_INTERNAL; |
1
b3dc740b4b04
Commit some Fix from Francis on sdo.c and abjacces.c. Fix endianisation problems while accessing OD. Also fix SDO abord handling bug.
etisserant
parents:
0
diff
changeset
|
396 |
} |
0 | 397 |
MSG_WAR(0x3A22, "Sending SDO abort ", 0); |
499
061f12bd838b
getReadResultNetworkDict now returns abortcode. Now, abort message should be sent correctly from client.
etisserant
parents:
495
diff
changeset
|
398 |
err = sendSDOabort(d, whoami, nodeId, index, subIndex, abortCode); |
0 | 399 |
if (err) { |
400 |
MSG_WAR(0x3A23, "Unable to send the SDO abort", 0); |
|
401 |
return 0xFF; |
|
402 |
} |
|
403 |
return 0; |
|
404 |
} |
|
405 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
406 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
407 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
408 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
409 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
410 |
** @param line |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
411 |
**/ |
0 | 412 |
void resetSDOline ( CO_Data* d, UNS8 line ) |
413 |
{ |
|
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
414 |
UNS32 i; |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
415 |
MSG_WAR(0x3A25, "reset SDO line nb : ", line); |
0 | 416 |
initSDOline(d, line, 0, 0, 0, SDO_RESET); |
417 |
for (i = 0 ; i < SDO_MAX_LENGTH_TRANSFERT ; i++) |
|
418 |
d->transfers[line].data[i] = 0; |
|
501 | 419 |
d->transfers[line].whoami = 0; |
420 |
d->transfers[line].abortCode = 0; |
|
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
421 |
#ifdef SDO_DYNAMIC_BUFFER_ALLOCATION |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
422 |
free(d->transfers[line].dynamicData); |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
423 |
d->transfers[line].dynamicData = 0; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
424 |
d->transfers[line].dynamicDataSize = 0; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
425 |
#endif //SDO_DYNAMIC_BUFFER_ALLOCATION |
0 | 426 |
} |
427 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
428 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
429 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
430 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
431 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
432 |
** @param line |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
433 |
** @param nodeId |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
434 |
** @param index |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
435 |
** @param subIndex |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
436 |
** @param state |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
437 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
438 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
439 |
**/ |
0 | 440 |
UNS8 initSDOline (CO_Data* d, UNS8 line, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 state) |
441 |
{ |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
442 |
MSG_WAR(0x3A25, "init SDO line nb : ", line); |
0 | 443 |
if (state == SDO_DOWNLOAD_IN_PROGRESS || state == SDO_UPLOAD_IN_PROGRESS){ |
444 |
StartSDO_TIMER(line) |
|
445 |
}else{ |
|
446 |
StopSDO_TIMER(line) |
|
447 |
} |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
448 |
d->transfers[line].nodeId = nodeId; |
0 | 449 |
d->transfers[line].index = index; |
450 |
d->transfers[line].subIndex = subIndex; |
|
451 |
d->transfers[line].state = state; |
|
452 |
d->transfers[line].toggle = 0; |
|
453 |
d->transfers[line].count = 0; |
|
454 |
d->transfers[line].offset = 0; |
|
455 |
d->transfers[line].dataType = 0; |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
456 |
d->transfers[line].Callback = NULL; |
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
457 |
#ifdef SDO_DYNAMIC_BUFFER_ALLOCATION |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
458 |
free(d->transfers[line].dynamicData); |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
459 |
d->transfers[line].dynamicData = 0; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
460 |
d->transfers[line].dynamicDataSize = 0; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
461 |
#endif //SDO_DYNAMIC_BUFFER_ALLOCATION |
0 | 462 |
return 0; |
463 |
} |
|
464 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
465 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
466 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
467 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
468 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
469 |
** @param whoami |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
470 |
** @param line |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
471 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
472 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
473 |
**/ |
0 | 474 |
UNS8 getSDOfreeLine ( CO_Data* d, UNS8 whoami, UNS8 *line ) |
475 |
{ |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
476 |
|
0 | 477 |
UNS8 i; |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
478 |
|
0 | 479 |
for (i = 0 ; i < SDO_MAX_SIMULTANEOUS_TRANSFERTS ; i++){ |
480 |
if ( d->transfers[i].state == SDO_RESET ) { |
|
481 |
*line = i; |
|
482 |
d->transfers[i].whoami = whoami; |
|
483 |
return 0; |
|
71 | 484 |
} /* end if */ |
485 |
} /* end for */ |
|
0 | 486 |
MSG_ERR(0x1A25, "Too many SDO in progress. Aborted.", i); |
487 |
return 0xFF; |
|
488 |
} |
|
489 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
490 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
491 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
492 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
493 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
494 |
** @param nodeId |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
495 |
** @param whoami |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
496 |
** @param line |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
497 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
498 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
499 |
**/ |
0 | 500 |
UNS8 getSDOlineOnUse (CO_Data* d, UNS8 nodeId, UNS8 whoami, UNS8 *line) |
501 |
{ |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
502 |
|
0 | 503 |
UNS8 i; |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
504 |
|
0 | 505 |
for (i = 0 ; i < SDO_MAX_SIMULTANEOUS_TRANSFERTS ; i++){ |
506 |
if ( (d->transfers[i].state != SDO_RESET) && |
|
627 | 507 |
(d->transfers[i].state != SDO_ABORTED_INTERNAL) && |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
508 |
(d->transfers[i].nodeId == nodeId) && |
0 | 509 |
(d->transfers[i].whoami == whoami) ) { |
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
510 |
if (line) *line = i; |
0 | 511 |
return 0; |
512 |
} |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
513 |
} |
0 | 514 |
return 0xFF; |
515 |
} |
|
516 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
517 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
518 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
519 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
520 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
521 |
** @param nodeId |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
522 |
** @param whoami |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
523 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
524 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
525 |
**/ |
0 | 526 |
UNS8 closeSDOtransfer (CO_Data* d, UNS8 nodeId, UNS8 whoami) |
527 |
{ |
|
528 |
UNS8 err; |
|
529 |
UNS8 line; |
|
530 |
err = getSDOlineOnUse(d, nodeId, whoami, &line); |
|
531 |
if (err) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
532 |
MSG_WAR(0x2A30, "No SDO communication to close for node : ", nodeId); |
0 | 533 |
return 0xFF; |
534 |
} |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
535 |
resetSDOline(d, line); |
0 | 536 |
return 0; |
537 |
} |
|
538 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
539 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
540 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
541 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
542 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
543 |
** @param line |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
544 |
** @param nbBytes |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
545 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
546 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
547 |
**/ |
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
548 |
UNS8 getSDOlineRestBytes (CO_Data* d, UNS8 line, UNS32 * nbBytes) |
0 | 549 |
{ |
544
7620872e153c
Fixed bugs in SDO caused by UNS8->UNS32 size patch.
etisserant
parents:
539
diff
changeset
|
550 |
/* SDO initiated with e=0 and s=0 have count set to null */ |
7620872e153c
Fixed bugs in SDO caused by UNS8->UNS32 size patch.
etisserant
parents:
539
diff
changeset
|
551 |
if (d->transfers[line].count == 0) |
0 | 552 |
* nbBytes = 0; |
553 |
else |
|
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
554 |
* nbBytes = d->transfers[line].count - d->transfers[line].offset; |
0 | 555 |
return 0; |
556 |
} |
|
557 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
558 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
559 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
560 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
561 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
562 |
** @param line |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
563 |
** @param nbBytes |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
564 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
565 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
566 |
**/ |
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
567 |
UNS8 setSDOlineRestBytes (CO_Data* d, UNS8 line, UNS32 nbBytes) |
0 | 568 |
{ |
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
569 |
#ifndef SDO_DYNAMIC_BUFFER_ALLOCATION |
0 | 570 |
if (nbBytes > SDO_MAX_LENGTH_TRANSFERT) { |
571 |
MSG_ERR(0x1A35,"SDO Size of data too large. Exceed SDO_MAX_LENGTH_TRANSFERT", nbBytes); |
|
572 |
return 0xFF; |
|
573 |
} |
|
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
574 |
#endif //SDO_DYNAMIC_BUFFER_ALLOCATION |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
575 |
|
0 | 576 |
d->transfers[line].count = nbBytes; |
577 |
return 0; |
|
578 |
} |
|
579 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
580 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
581 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
582 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
583 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
584 |
** @param whoami |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
585 |
** @param sdo |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
586 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
587 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
588 |
**/ |
0 | 589 |
UNS8 sendSDO (CO_Data* d, UNS8 whoami, s_SDO sdo) |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
590 |
{ |
0 | 591 |
UNS16 offset; |
592 |
UNS16 lastIndex; |
|
593 |
UNS8 found = 0; |
|
594 |
Message m; |
|
595 |
UNS8 i; |
|
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
435
diff
changeset
|
596 |
UNS32 * pwCobId = NULL; |
306
3586cfa84705
Fixed incoherency with idx 0x1280+n sidx 3 in sdo.c against newly generated objectditcs (UNS32*->UNS8*).
etisserant
parents:
217
diff
changeset
|
597 |
UNS8 * pwNodeId = NULL; |
0 | 598 |
|
599 |
MSG_WAR(0x3A38, "sendSDO",0); |
|
600 |
if( !((d->nodeState == Operational) || (d->nodeState == Pre_operational ))) { |
|
601 |
MSG_WAR(0x2A39, "unable to send the SDO (not in op or pre-op mode", d->nodeState); |
|
602 |
return 0xFF; |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
603 |
} |
0 | 604 |
|
215 | 605 |
/*get the server->client cobid*/ |
481 | 606 |
if ( whoami == SDO_SERVER ) {/*case server. only one SDO server*/ |
0 | 607 |
offset = d->firstIndex->SDO_SVR; |
608 |
if (offset == 0) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
609 |
MSG_ERR(0x1A42, "SendSDO : No SDO server found", 0); |
0 | 610 |
return 0xFF; |
611 |
} |
|
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
435
diff
changeset
|
612 |
pwCobId = (UNS32*) d->objdict[offset].pSubindex[2].pObject; |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
613 |
MSG_WAR(0x3A41, "I am server. cobId : ", *pwCobId); |
0 | 614 |
} |
215 | 615 |
else { /*case client*/ |
616 |
/* Get the client->server cobid.*/ |
|
0 | 617 |
UNS16 sdoNum = 0; |
618 |
offset = d->firstIndex->SDO_CLT; |
|
619 |
lastIndex = d->lastIndex->SDO_CLT; |
|
620 |
if (offset == 0) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
621 |
MSG_ERR(0x1A42, "SendSDO : No SDO client index found", 0); |
0 | 622 |
return 0xFF; |
623 |
} |
|
481 | 624 |
/* find index for communication server node */ |
0 | 625 |
while (offset <= lastIndex){ |
626 |
MSG_WAR(0x3A43,"Reading index : ", 0x1280 + sdoNum); |
|
627 |
if (d->objdict[offset].bSubCount <= 3) { |
|
628 |
MSG_ERR(0x1A28, "Subindex 3 not found at index ", 0x1280 + sdoNum); |
|
629 |
return 0xFF; |
|
630 |
} |
|
306
3586cfa84705
Fixed incoherency with idx 0x1280+n sidx 3 in sdo.c against newly generated objectditcs (UNS32*->UNS8*).
etisserant
parents:
217
diff
changeset
|
631 |
pwNodeId = (UNS8*) d->objdict[offset].pSubindex[3].pObject; |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
632 |
MSG_WAR(0x3A44, "Found nodeId server = ", *pwNodeId); |
0 | 633 |
if(*pwNodeId == sdo.nodeId) { |
634 |
found = 1; |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
635 |
break; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
636 |
} |
0 | 637 |
offset ++; |
638 |
sdoNum ++; |
|
639 |
} |
|
640 |
if (! found){ |
|
641 |
MSG_WAR (0x2A45, "No SDO client corresponds to the mesage to send to node ", sdo.nodeId); |
|
642 |
return 0xFF; |
|
643 |
} |
|
481 | 644 |
/* read the client->server cobid */ |
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
435
diff
changeset
|
645 |
pwCobId = (UNS32*) d->objdict[offset].pSubindex[1].pObject; |
0 | 646 |
} |
215 | 647 |
/* message copy for sending */ |
597
ea32aa303987
Fixed wrong cast in sdo.c and wrong message length in nodeguarding
edouard
parents:
587
diff
changeset
|
648 |
m.cob_id = (UNS16)UNS16_LE(*pwCobId); |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
649 |
m.rtr = NOT_A_REQUEST; |
215 | 650 |
/* the length of SDO must be 8 */ |
0 | 651 |
m.len = 8; |
652 |
for (i = 0 ; i < 8 ; i++) { |
|
653 |
m.data[i] = sdo.body.data[i]; |
|
654 |
} |
|
149 | 655 |
return canSend(d->canHandle,&m); |
0 | 656 |
} |
657 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
658 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
659 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
660 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
661 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
662 |
** @param whoami |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
663 |
** @param index |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
664 |
** @param subIndex |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
665 |
** @param abortCode |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
666 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
667 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
668 |
**/ |
499
061f12bd838b
getReadResultNetworkDict now returns abortcode. Now, abort message should be sent correctly from client.
etisserant
parents:
495
diff
changeset
|
669 |
UNS8 sendSDOabort (CO_Data* d, UNS8 whoami, UNS8 nodeID, UNS16 index, UNS8 subIndex, UNS32 abortCode) |
0 | 670 |
{ |
671 |
s_SDO sdo; |
|
672 |
UNS8 ret; |
|
587 | 673 |
|
1
b3dc740b4b04
Commit some Fix from Francis on sdo.c and abjacces.c. Fix endianisation problems while accessing OD. Also fix SDO abord handling bug.
etisserant
parents:
0
diff
changeset
|
674 |
MSG_WAR(0x2A50,"Sending SDO abort ", abortCode); |
499
061f12bd838b
getReadResultNetworkDict now returns abortcode. Now, abort message should be sent correctly from client.
etisserant
parents:
495
diff
changeset
|
675 |
if(whoami == SDO_SERVER) |
061f12bd838b
getReadResultNetworkDict now returns abortcode. Now, abort message should be sent correctly from client.
etisserant
parents:
495
diff
changeset
|
676 |
{ |
061f12bd838b
getReadResultNetworkDict now returns abortcode. Now, abort message should be sent correctly from client.
etisserant
parents:
495
diff
changeset
|
677 |
sdo.nodeId = *d->bDeviceNodeId; |
061f12bd838b
getReadResultNetworkDict now returns abortcode. Now, abort message should be sent correctly from client.
etisserant
parents:
495
diff
changeset
|
678 |
} |
061f12bd838b
getReadResultNetworkDict now returns abortcode. Now, abort message should be sent correctly from client.
etisserant
parents:
495
diff
changeset
|
679 |
else |
061f12bd838b
getReadResultNetworkDict now returns abortcode. Now, abort message should be sent correctly from client.
etisserant
parents:
495
diff
changeset
|
680 |
{ |
061f12bd838b
getReadResultNetworkDict now returns abortcode. Now, abort message should be sent correctly from client.
etisserant
parents:
495
diff
changeset
|
681 |
sdo.nodeId = nodeID; |
061f12bd838b
getReadResultNetworkDict now returns abortcode. Now, abort message should be sent correctly from client.
etisserant
parents:
495
diff
changeset
|
682 |
} |
0 | 683 |
sdo.body.data[0] = 0x80; |
71 | 684 |
/* Index */ |
685 |
sdo.body.data[1] = index & 0xFF; /* LSB */ |
|
686 |
sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */ |
|
687 |
/* Subindex */ |
|
0 | 688 |
sdo.body.data[3] = subIndex; |
71 | 689 |
/* Data */ |
0 | 690 |
sdo.body.data[4] = (UNS8)(abortCode & 0xFF); |
691 |
sdo.body.data[5] = (UNS8)((abortCode >> 8) & 0xFF); |
|
692 |
sdo.body.data[6] = (UNS8)((abortCode >> 16) & 0xFF); |
|
693 |
sdo.body.data[7] = (UNS8)((abortCode >> 24) & 0xFF); |
|
694 |
ret = sendSDO(d, whoami, sdo); |
|
695 |
||
696 |
return ret; |
|
697 |
} |
|
698 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
699 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
700 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
701 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
702 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
703 |
** @param m |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
704 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
705 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
706 |
**/ |
0 | 707 |
UNS8 proceedSDO (CO_Data* d, Message *m) |
708 |
{ |
|
709 |
UNS8 err; |
|
710 |
UNS8 line; |
|
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
711 |
UNS32 nbBytes; /* received or to be transmited. */ |
215 | 712 |
UNS8 nodeId = 0; /* The node from which the SDO is received */ |
311 | 713 |
UNS8 *pNodeId = NULL; |
215 | 714 |
UNS8 whoami = SDO_UNKNOWN; /* SDO_SERVER or SDO_CLIENT.*/ |
715 |
UNS32 errorCode; /* while reading or writing in the local object dictionary.*/ |
|
716 |
s_SDO sdo; /* SDO to transmit */ |
|
0 | 717 |
UNS16 index; |
718 |
UNS8 subIndex; |
|
719 |
UNS32 abortCode; |
|
587 | 720 |
UNS32 i; |
721 |
UNS8 j; |
|
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
435
diff
changeset
|
722 |
UNS32 *pCobId = NULL; |
0 | 723 |
UNS16 offset; |
724 |
UNS16 lastIndex; |
|
725 |
||
726 |
MSG_WAR(0x3A60, "proceedSDO ", 0); |
|
727 |
whoami = SDO_UNKNOWN; |
|
215 | 728 |
/* Looking for the cobId in the object dictionary. */ |
729 |
/* Am-I a server ? */ |
|
0 | 730 |
offset = d->firstIndex->SDO_SVR; |
731 |
lastIndex = d->lastIndex->SDO_SVR; |
|
732 |
j = 0; |
|
733 |
if(offset) while (offset <= lastIndex) { |
|
734 |
if (d->objdict[offset].bSubCount <= 1) { |
|
735 |
MSG_ERR(0x1A61, "Subindex 1 not found at index ", 0x1200 + j); |
|
736 |
return 0xFF; |
|
737 |
} |
|
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
435
diff
changeset
|
738 |
pCobId = (UNS32*) d->objdict[offset].pSubindex[1].pObject; |
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
435
diff
changeset
|
739 |
if ( *pCobId == UNS16_LE(m->cob_id) ) { |
0 | 740 |
whoami = SDO_SERVER; |
741 |
MSG_WAR(0x3A62, "proceedSDO. I am server. index : ", 0x1200 + j); |
|
215 | 742 |
/* In case of server, the node id of the client may be unknown. So we put the index minus offset */ |
743 |
/* 0x1200 where the cobid received is defined. */ |
|
0 | 744 |
nodeId = j; |
745 |
break; |
|
746 |
} |
|
747 |
j++; |
|
748 |
offset++; |
|
215 | 749 |
} /* end while */ |
0 | 750 |
if (whoami == SDO_UNKNOWN) { |
215 | 751 |
/* Am-I client ? */ |
0 | 752 |
offset = d->firstIndex->SDO_CLT; |
753 |
lastIndex = d->lastIndex->SDO_CLT; |
|
754 |
j = 0; |
|
755 |
if(offset) while (offset <= lastIndex) { |
|
756 |
if (d->objdict[offset].bSubCount <= 3) { |
|
757 |
MSG_ERR(0x1A63, "Subindex 3 not found at index ", 0x1280 + j); |
|
758 |
return 0xFF; |
|
759 |
} |
|
215 | 760 |
/* a) Looking for the cobid received. */ |
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
435
diff
changeset
|
761 |
pCobId = (UNS32*) d->objdict[offset].pSubindex[2].pObject; |
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
435
diff
changeset
|
762 |
if (*pCobId == UNS16_LE(m->cob_id) ) { |
215 | 763 |
/* b) cobid found, so reading the node id of the server. */ |
311 | 764 |
pNodeId = (UNS8*) d->objdict[offset].pSubindex[3].pObject; |
0 | 765 |
whoami = SDO_CLIENT; |
311 | 766 |
nodeId = *pNodeId; |
0 | 767 |
MSG_WAR(0x3A64, "proceedSDO. I am server. index : ", 0x1280 + j); |
768 |
MSG_WAR(0x3A65, " Server nodeId : ", nodeId); |
|
769 |
break; |
|
770 |
} |
|
771 |
j++; |
|
772 |
offset++; |
|
71 | 773 |
} /* end while */ |
0 | 774 |
} |
775 |
if (whoami == SDO_UNKNOWN) { |
|
215 | 776 |
return 0xFF;/* This SDO was not for us ! */ |
777 |
} |
|
778 |
||
779 |
/* Test if the size of the SDO is ok */ |
|
0 | 780 |
if ( (*m).len != 8) { |
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
435
diff
changeset
|
781 |
MSG_ERR(0x1A67, "Error size SDO. CobId : ", UNS16_LE(m->cob_id)); |
0 | 782 |
failedSDO(d, nodeId, whoami, 0, 0, SDOABT_GENERAL_ERROR); |
783 |
return 0xFF; |
|
784 |
} |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
785 |
|
0 | 786 |
if (whoami == SDO_CLIENT) { |
787 |
MSG_WAR(0x3A68, "I am CLIENT. Received SDO from nodeId : ", nodeId); |
|
788 |
} |
|
789 |
else { |
|
447
c9d01296d6d9
Endianess patch from Edward Karpicz, Lithuania :-)
etisserant
parents:
435
diff
changeset
|
790 |
MSG_WAR(0x3A69, "I am SERVER. Received SDO cobId : ", UNS16_LE(m->cob_id)); |
0 | 791 |
} |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
792 |
|
215 | 793 |
/* Testing the command specifier */ |
794 |
/* Allowed : cs = 0, 1, 2, 3, 4. (= all except those for block tranfert). */ |
|
795 |
/* cs = other : Not allowed -> abort. */ |
|
0 | 796 |
switch (getSDOcs(m->data[0])) { |
797 |
||
798 |
case 0: |
|
215 | 799 |
/* I am SERVER */ |
0 | 800 |
if (whoami == SDO_SERVER) { |
215 | 801 |
/* Receiving a download segment data. */ |
802 |
/* A SDO transfert should have been yet initiated. */ |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
803 |
err = getSDOlineOnUse( d, nodeId, whoami, &line ); |
0 | 804 |
if (!err) |
805 |
err = d->transfers[line].state != SDO_DOWNLOAD_IN_PROGRESS; |
|
806 |
if (err) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
807 |
MSG_ERR(0x1A70, "SDO error : Received download segment for unstarted trans. index 0x1200 + ", |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
808 |
nodeId); |
0 | 809 |
failedSDO(d, nodeId, whoami, 0, 0, SDOABT_LOCAL_CTRL_ERROR); |
810 |
return 0xFF; |
|
811 |
} |
|
215 | 812 |
/* Reset the wathdog */ |
0 | 813 |
RestartSDO_TIMER(line) |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
814 |
MSG_WAR(0x3A71, "Received SDO download segment defined at index 0x1200 + ", nodeId); |
0 | 815 |
index = d->transfers[line].index; |
816 |
subIndex = d->transfers[line].subIndex; |
|
215 | 817 |
/* Toggle test. */ |
0 | 818 |
if (d->transfers[line].toggle != getSDOt(m->data[0])) { |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
819 |
MSG_ERR(0x1A72, "SDO error : Toggle error : ", getSDOt(m->data[0])); |
0 | 820 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_TOGGLE_NOT_ALTERNED); |
821 |
return 0xFF; |
|
822 |
} |
|
215 | 823 |
/* Nb of data to be downloaded */ |
0 | 824 |
nbBytes = 7 - getSDOn3(m->data[0]); |
215 | 825 |
/* Store the data in the transfert structure. */ |
0 | 826 |
err = SDOtoLine(d, line, nbBytes, (*m).data + 1); |
827 |
if (err) { |
|
828 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR); |
|
829 |
return 0xFF; |
|
830 |
} |
|
215 | 831 |
/* Sending the SDO response, CS = 1 */ |
832 |
sdo.nodeId = *d->bDeviceNodeId; /* The node id of the server, (here it is the sender). */ |
|
0 | 833 |
sdo.body.data[0] = (1 << 5) | (d->transfers[line].toggle << 4); |
834 |
for (i = 1 ; i < 8 ; i++) |
|
835 |
sdo.body.data[i] = 0; |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
836 |
MSG_WAR(0x3A73, "SDO. Send response to download request defined at index 0x1200 + ", nodeId); |
0 | 837 |
sendSDO(d, whoami, sdo); |
215 | 838 |
/* Inverting the toggle for the next segment. */ |
0 | 839 |
d->transfers[line].toggle = ! d->transfers[line].toggle & 1; |
215 | 840 |
/* If it was the last segment, */ |
0 | 841 |
if (getSDOc(m->data[0])) { |
215 | 842 |
/* Transfering line data to object dictionary. */ |
843 |
/* The code does not use the "d" of initiate frame. So it is safe if e=s=0 */ |
|
0 | 844 |
errorCode = SDOlineToObjdict(d, line); |
845 |
if (errorCode) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
846 |
MSG_ERR(0x1A54, "SDO error : Unable to copy the data in the object dictionary", 0); |
0 | 847 |
failedSDO(d, nodeId, whoami, index, subIndex, errorCode); |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
848 |
return 0xFF; |
0 | 849 |
} |
215 | 850 |
/* Release of the line */ |
0 | 851 |
resetSDOline(d, line); |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
852 |
MSG_WAR(0x3A74, "SDO. End of download defined at index 0x1200 + ", nodeId); |
0 | 853 |
} |
71 | 854 |
} /* end if SERVER */ |
855 |
else { /* if CLIENT */ |
|
215 | 856 |
/* I am CLIENT */ |
857 |
/* It is a request for a previous upload segment. We should find a line opened for this.*/ |
|
0 | 858 |
err = getSDOlineOnUse( d, nodeId, whoami, &line); |
859 |
if (!err) |
|
860 |
err = d->transfers[line].state != SDO_UPLOAD_IN_PROGRESS; |
|
861 |
if (err) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
862 |
MSG_ERR(0x1A75, "SDO error : Received segment response for unknown trans. from nodeId", nodeId); |
0 | 863 |
failedSDO(d, nodeId, whoami, 0, 0, SDOABT_LOCAL_CTRL_ERROR); |
864 |
return 0xFF; |
|
865 |
} |
|
215 | 866 |
/* Reset the wathdog */ |
0 | 867 |
RestartSDO_TIMER(line) |
868 |
index = d->transfers[line].index; |
|
869 |
subIndex = d->transfers[line].subIndex; |
|
215 | 870 |
/* test of the toggle; */ |
0 | 871 |
if (d->transfers[line].toggle != getSDOt(m->data[0])) { |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
872 |
MSG_ERR(0x1A76, "SDO error : Received segment response Toggle error. from nodeId", nodeId); |
0 | 873 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_TOGGLE_NOT_ALTERNED); |
874 |
return 0xFF; |
|
875 |
} |
|
215 | 876 |
/* nb of data to be uploaded */ |
0 | 877 |
nbBytes = 7 - getSDOn3(m->data[0]); |
215 | 878 |
/* Storing the data in the line structure. */ |
0 | 879 |
err = SDOtoLine(d, line, nbBytes, (*m).data + 1); |
880 |
if (err) { |
|
881 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR); |
|
882 |
return 0xFF; |
|
883 |
} |
|
215 | 884 |
/* Inverting the toggle for the next segment. */ |
0 | 885 |
d->transfers[line].toggle = ! d->transfers[line].toggle & 1; |
215 | 886 |
/* If it was the last segment,*/ |
0 | 887 |
if ( getSDOc(m->data[0])) { |
215 | 888 |
/* Put in state finished */ |
889 |
/* The code is safe for the case e=s=0 in initiate frame. */ |
|
0 | 890 |
StopSDO_TIMER(line) |
891 |
d->transfers[line].state = SDO_FINISHED; |
|
32 | 892 |
if(d->transfers[line].Callback) (*d->transfers[line].Callback)(d,nodeId); |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
893 |
|
0 | 894 |
MSG_WAR(0x3A77, "SDO. End of upload from node : ", nodeId); |
895 |
} |
|
215 | 896 |
else { /* more segments to receive */ |
897 |
/* Sending the request for the next segment. */ |
|
0 | 898 |
sdo.nodeId = nodeId; |
899 |
sdo.body.data[0] = (3 << 5) | (d->transfers[line].toggle << 4); |
|
900 |
for (i = 1 ; i < 8 ; i++) |
|
901 |
sdo.body.data[i] = 0; |
|
902 |
sendSDO(d, whoami, sdo); |
|
903 |
MSG_WAR(0x3A78, "SDO send upload segment request to nodeId", nodeId); |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
904 |
} |
71 | 905 |
} /* End if CLIENT */ |
0 | 906 |
break; |
907 |
||
908 |
case 1: |
|
215 | 909 |
/* I am SERVER */ |
910 |
/* Receive of an initiate download */ |
|
0 | 911 |
if (whoami == SDO_SERVER) { |
912 |
index = getSDOindex(m->data[1],m->data[2]); |
|
913 |
subIndex = getSDOsubIndex(m->data[3]); |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
914 |
MSG_WAR(0x3A79, "Received SDO Initiate Download (to store data) defined at index 0x1200 + ", |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
915 |
nodeId); |
0 | 916 |
MSG_WAR(0x3A80, "Writing at index : ", index); |
917 |
MSG_WAR(0x3A80, "Writing at subIndex : ", subIndex); |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
918 |
|
215 | 919 |
/* Search if a SDO transfert have been yet initiated */ |
0 | 920 |
err = getSDOlineOnUse( d, nodeId, whoami, &line ); |
921 |
if (! err) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
922 |
MSG_ERR(0x1A81, "SDO error : Transmission yet started.", 0); |
0 | 923 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_LOCAL_CTRL_ERROR); |
924 |
return 0xFF; |
|
925 |
} |
|
215 | 926 |
/* No line on use. Great ! */ |
927 |
/* Try to open a new line. */ |
|
0 | 928 |
err = getSDOfreeLine( d, whoami, &line ); |
929 |
if (err) { |
|
930 |
MSG_ERR(0x1A82, "SDO error : No line free, too many SDO in progress. Aborted.", 0); |
|
931 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_LOCAL_CTRL_ERROR); |
|
932 |
return 0xFF; |
|
933 |
} |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
934 |
initSDOline(d, line, nodeId, index, subIndex, SDO_DOWNLOAD_IN_PROGRESS); |
0 | 935 |
|
215 | 936 |
if (getSDOe(m->data[0])) { /* If SDO expedited */ |
937 |
/* nb of data to be downloaded */ |
|
0 | 938 |
nbBytes = 4 - getSDOn2(m->data[0]); |
215 | 939 |
/* Storing the data in the line structure. */ |
0 | 940 |
d->transfers[line].count = nbBytes; |
941 |
err = SDOtoLine(d, line, nbBytes, (*m).data + 4); |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
942 |
|
0 | 943 |
if (err) { |
944 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR); |
|
945 |
return 0xFF; |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
946 |
} |
0 | 947 |
|
215 | 948 |
/* SDO expedited -> transfert finished. Data can be stored in the dictionary. */ |
949 |
/*The line will be reseted when it is downloading in the dictionary. */ |
|
0 | 950 |
MSG_WAR(0x3A83, "SDO Initiate Download is an expedited transfert. Finished.: ", nodeId); |
215 | 951 |
/* Transfering line data to object dictionary. */ |
0 | 952 |
errorCode = SDOlineToObjdict(d, line); |
953 |
if (errorCode) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
954 |
MSG_ERR(0x1A84, "SDO error : Unable to copy the data in the object dictionary", 0); |
0 | 955 |
failedSDO(d, nodeId, whoami, index, subIndex, errorCode); |
956 |
return 0xFF; |
|
957 |
} |
|
215 | 958 |
/* Release of the line. */ |
0 | 959 |
resetSDOline(d, line); |
960 |
} |
|
215 | 961 |
else {/* So, if it is not an expedited transfert */ |
0 | 962 |
if (getSDOs(m->data[0])) { |
604 | 963 |
nbBytes = (m->data[4]) + ((UNS32)(m->data[5])<<8) + ((UNS32)(m->data[6])<<16) + ((UNS32)(m->data[7])<<24); |
0 | 964 |
err = setSDOlineRestBytes(d, nodeId, nbBytes); |
965 |
if (err) { |
|
966 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR); |
|
967 |
return 0xFF; |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
968 |
} |
0 | 969 |
} |
970 |
} |
|
215 | 971 |
/*Sending a SDO, cs=3*/ |
972 |
sdo.nodeId = *d->bDeviceNodeId; /* The node id of the server, (here it is the sender).*/ |
|
0 | 973 |
sdo.body.data[0] = 3 << 5; |
71 | 974 |
sdo.body.data[1] = index & 0xFF; /* LSB */ |
975 |
sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */ |
|
0 | 976 |
sdo.body.data[3] = subIndex; |
977 |
for (i = 4 ; i < 8 ; i++) |
|
978 |
sdo.body.data[i] = 0; |
|
979 |
sendSDO(d, whoami, sdo); |
|
71 | 980 |
} /* end if I am SERVER */ |
0 | 981 |
else { |
215 | 982 |
/* I am CLIENT */ |
983 |
/* It is a response for a previous download segment. We should find a line opened for this. */ |
|
0 | 984 |
err = getSDOlineOnUse( d, nodeId, whoami, &line); |
985 |
if (!err) |
|
986 |
err = d->transfers[line].state != SDO_DOWNLOAD_IN_PROGRESS; |
|
987 |
if (err) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
988 |
MSG_ERR(0x1A85, "SDO error : Received segment response for unknown trans. from nodeId", nodeId); |
0 | 989 |
failedSDO(d, nodeId, whoami, 0, 0, SDOABT_LOCAL_CTRL_ERROR); |
990 |
return 0xFF; |
|
991 |
} |
|
215 | 992 |
/* Reset the wathdog */ |
0 | 993 |
RestartSDO_TIMER(line) |
994 |
index = d->transfers[line].index; |
|
995 |
subIndex = d->transfers[line].subIndex; |
|
215 | 996 |
/* test of the toggle; */ |
0 | 997 |
if (d->transfers[line].toggle != getSDOt(m->data[0])) { |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
998 |
MSG_ERR(0x1A86, "SDO error : Received segment response Toggle error. from nodeId", nodeId); |
0 | 999 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_TOGGLE_NOT_ALTERNED); |
1000 |
return 0xFF; |
|
1001 |
} |
|
1002 |
||
215 | 1003 |
/* End transmission or downloading next segment. We need to know if it will be the last one. */ |
0 | 1004 |
getSDOlineRestBytes(d, line, &nbBytes); |
1005 |
if (nbBytes == 0) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1006 |
MSG_WAR(0x3A87, "SDO End download. segment response received. OK. from nodeId", nodeId); |
0 | 1007 |
StopSDO_TIMER(line) |
1008 |
d->transfers[line].state = SDO_FINISHED; |
|
32 | 1009 |
if(d->transfers[line].Callback) (*d->transfers[line].Callback)(d,nodeId); |
0 | 1010 |
return 0x00; |
1011 |
} |
|
215 | 1012 |
/* At least one transfer to send. */ |
0 | 1013 |
if (nbBytes > 7) { |
215 | 1014 |
/* several segments to download.*/ |
1015 |
/* code to send the next segment. (cs = 0; c = 0) */ |
|
0 | 1016 |
d->transfers[line].toggle = ! d->transfers[line].toggle & 1; |
71 | 1017 |
sdo.nodeId = nodeId; /* The server node Id; */ |
0 | 1018 |
sdo.body.data[0] = (d->transfers[line].toggle << 4); |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1019 |
err = lineToSDO(d, line, 7, sdo.body.data + 1); |
0 | 1020 |
if (err) { |
1021 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR); |
|
1022 |
return 0xFF; |
|
1023 |
} |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1024 |
} |
0 | 1025 |
else { |
215 | 1026 |
/* Last segment. */ |
1027 |
/* code to send the last segment. (cs = 0; c = 1)*/ |
|
0 | 1028 |
d->transfers[line].toggle = ! d->transfers[line].toggle & 1; |
71 | 1029 |
sdo.nodeId = nodeId; /* The server node Id; */ |
587 | 1030 |
sdo.body.data[0] = (UNS8)((d->transfers[line].toggle << 4) | ((7 - nbBytes) << 1) | 1); |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1031 |
err = lineToSDO(d, line, nbBytes, sdo.body.data + 1); |
0 | 1032 |
if (err) { |
1033 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR); |
|
1034 |
return 0xFF; |
|
1035 |
} |
|
1036 |
for (i = nbBytes + 1 ; i < 8 ; i++) |
|
1037 |
sdo.body.data[i] = 0; |
|
1038 |
} |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1039 |
MSG_WAR(0x3A88, "SDO sending download segment to nodeId", nodeId); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1040 |
sendSDO(d, whoami, sdo); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1041 |
} /* end if I am a CLIENT */ |
0 | 1042 |
break; |
1043 |
||
1044 |
case 2: |
|
215 | 1045 |
/* I am SERVER */ |
1046 |
/* Receive of an initiate upload.*/ |
|
0 | 1047 |
if (whoami == SDO_SERVER) { |
1048 |
index = getSDOindex(m->data[1],m->data[2]); |
|
1049 |
subIndex = getSDOsubIndex(m->data[3]); |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1050 |
MSG_WAR(0x3A89, "Received SDO Initiate upload (to send data) defined at index 0x1200 + ", |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1051 |
nodeId); |
0 | 1052 |
MSG_WAR(0x3A90, "Reading at index : ", index); |
1053 |
MSG_WAR(0x3A91, "Reading at subIndex : ", subIndex); |
|
215 | 1054 |
/* Search if a SDO transfert have been yet initiated*/ |
0 | 1055 |
err = getSDOlineOnUse( d, nodeId, whoami, &line ); |
1056 |
if (! err) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1057 |
MSG_ERR(0x1A92, "SDO error : Transmission yet started at line : ", line); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1058 |
MSG_WAR(0x3A93, "nodeId = ", nodeId); |
12 | 1059 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_LOCAL_CTRL_ERROR); |
1060 |
return 0xFF; |
|
0 | 1061 |
} |
215 | 1062 |
/* No line on use. Great !*/ |
1063 |
/* Try to open a new line.*/ |
|
0 | 1064 |
err = getSDOfreeLine( d, whoami, &line ); |
1065 |
if (err) { |
|
1066 |
MSG_ERR(0x1A71, "SDO error : No line free, too many SDO in progress. Aborted.", 0); |
|
1067 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_LOCAL_CTRL_ERROR); |
|
1068 |
return 0xFF; |
|
1069 |
} |
|
1070 |
initSDOline(d, line, nodeId, index, subIndex, SDO_UPLOAD_IN_PROGRESS); |
|
215 | 1071 |
/* Transfer data from dictionary to the line structure. */ |
0 | 1072 |
errorCode = objdictToSDOline(d, line); |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1073 |
|
0 | 1074 |
if (errorCode) { |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1075 |
MSG_ERR(0x1A94, "SDO error : Unable to copy the data from object dictionary. Err code : ", |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1076 |
errorCode); |
0 | 1077 |
failedSDO(d, nodeId, whoami, index, subIndex, errorCode); |
1078 |
return 0xFF; |
|
1079 |
} |
|
215 | 1080 |
/* Preparing the response.*/ |
1081 |
getSDOlineRestBytes(d, line, &nbBytes); /* Nb bytes to transfer ? */ |
|
1082 |
sdo.nodeId = nodeId; /* The server node Id; */ |
|
0 | 1083 |
if (nbBytes > 4) { |
215 | 1084 |
/* normal transfert. (segmented). */ |
1085 |
/* code to send the initiate upload response. (cs = 2) */ |
|
0 | 1086 |
sdo.body.data[0] = (2 << 5) | 1; |
71 | 1087 |
sdo.body.data[1] = index & 0xFF; /* LSB */ |
1088 |
sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */ |
|
0 | 1089 |
sdo.body.data[3] = subIndex; |
587 | 1090 |
sdo.body.data[4] = (UNS8)nbBytes; /* Limitation of canfestival2 : Max tranfert is 256 bytes.*/ |
215 | 1091 |
/* It takes too much memory to upgrate to 2^32 because the size of data is also coded */ |
1092 |
/* in the object dictionary, at every index and subindex. */ |
|
0 | 1093 |
for (i = 5 ; i < 8 ; i++) |
1094 |
sdo.body.data[i] = 0; |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1095 |
MSG_WAR(0x3A95, "SDO. Sending normal upload initiate response defined at index 0x1200 + ", nodeId); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1096 |
sendSDO(d, whoami, sdo); |
0 | 1097 |
} |
1098 |
else { |
|
215 | 1099 |
/* Expedited upload. (cs = 2 ; e = 1) */ |
587 | 1100 |
sdo.body.data[0] = (UNS8)((2 << 5) | ((4 - nbBytes) << 2) | 3); |
71 | 1101 |
sdo.body.data[1] = index & 0xFF; /* LSB */ |
1102 |
sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */ |
|
0 | 1103 |
sdo.body.data[3] = subIndex; |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1104 |
err = lineToSDO(d, line, nbBytes, sdo.body.data + 4); |
0 | 1105 |
if (err) { |
1106 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR); |
|
1107 |
return 0xFF; |
|
1108 |
} |
|
1109 |
for (i = 4 + nbBytes ; i < 8 ; i++) |
|
1110 |
sdo.body.data[i] = 0; |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1111 |
MSG_WAR(0x3A96, "SDO. Sending expedited upload initiate response defined at index 0x1200 + ", |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1112 |
nodeId); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1113 |
sendSDO(d, whoami, sdo); |
215 | 1114 |
/* Release the line.*/ |
0 | 1115 |
resetSDOline(d, line); |
1116 |
} |
|
215 | 1117 |
} /* end if I am SERVER*/ |
0 | 1118 |
else { |
215 | 1119 |
/* I am CLIENT */ |
1120 |
/* It is the response for the previous initiate upload request.*/ |
|
1121 |
/* We should find a line opened for this. */ |
|
0 | 1122 |
err = getSDOlineOnUse( d, nodeId, whoami, &line); |
1123 |
if (!err) |
|
1124 |
err = d->transfers[line].state != SDO_UPLOAD_IN_PROGRESS; |
|
1125 |
if (err) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1126 |
MSG_ERR(0x1A97, "SDO error : Received response for unknown upload request from nodeId", nodeId); |
0 | 1127 |
failedSDO(d, nodeId, whoami, 0, 0, SDOABT_LOCAL_CTRL_ERROR); |
1128 |
return 0xFF; |
|
1129 |
} |
|
215 | 1130 |
/* Reset the wathdog */ |
0 | 1131 |
RestartSDO_TIMER(line) |
1132 |
index = d->transfers[line].index; |
|
1133 |
subIndex = d->transfers[line].subIndex; |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1134 |
|
71 | 1135 |
if (getSDOe(m->data[0])) { /* If SDO expedited */ |
215 | 1136 |
/* nb of data to be uploaded */ |
0 | 1137 |
nbBytes = 4 - getSDOn2(m->data[0]); |
215 | 1138 |
/* Storing the data in the line structure. */ |
0 | 1139 |
err = SDOtoLine(d, line, nbBytes, (*m).data + 4); |
1140 |
if (err) { |
|
1141 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR); |
|
1142 |
return 0xFF; |
|
1143 |
} |
|
215 | 1144 |
/* SDO expedited -> transfert finished. data are available via getReadResultNetworkDict(). */ |
0 | 1145 |
MSG_WAR(0x3A98, "SDO expedited upload finished. Response received from node : ", nodeId); |
1146 |
StopSDO_TIMER(line) |
|
1147 |
d->transfers[line].count = nbBytes; |
|
1148 |
d->transfers[line].state = SDO_FINISHED; |
|
32 | 1149 |
if(d->transfers[line].Callback) (*d->transfers[line].Callback)(d,nodeId); |
0 | 1150 |
return 0; |
1151 |
} |
|
215 | 1152 |
else { /* So, if it is not an expedited transfert */ |
1153 |
/* Storing the nb of data to receive. */ |
|
0 | 1154 |
if (getSDOs(m->data[0])) { |
604 | 1155 |
nbBytes = m->data[4] + ((UNS32)(m->data[5])<<8) + ((UNS32)(m->data[6])<<16) + ((UNS32)(m->data[7])<<24); |
0 | 1156 |
err = setSDOlineRestBytes(d, line, nbBytes); |
1157 |
if (err) { |
|
1158 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR); |
|
1159 |
return 0xFF; |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1160 |
} |
0 | 1161 |
} |
215 | 1162 |
/* Requesting next segment. (cs = 3) */ |
0 | 1163 |
sdo.nodeId = nodeId; |
1164 |
sdo.body.data[0] = 3 << 5; |
|
1165 |
for (i = 1 ; i < 8 ; i++) |
|
1166 |
sdo.body.data[i] = 0; |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1167 |
MSG_WAR(0x3A99, "SDO. Sending upload segment request to node : ", nodeId); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1168 |
sendSDO(d, whoami, sdo); |
0 | 1169 |
} |
215 | 1170 |
} /* End if CLIENT */ |
0 | 1171 |
break; |
1172 |
||
1173 |
case 3: |
|
215 | 1174 |
/* I am SERVER */ |
0 | 1175 |
if (whoami == SDO_SERVER) { |
215 | 1176 |
/* Receiving a upload segment. */ |
1177 |
/* A SDO transfert should have been yet initiated. */ |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1178 |
err = getSDOlineOnUse( d, nodeId, whoami, &line ); |
0 | 1179 |
if (!err) |
1180 |
err = d->transfers[line].state != SDO_UPLOAD_IN_PROGRESS; |
|
1181 |
if (err) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1182 |
MSG_ERR(0x1AA0, "SDO error : Received upload segment for unstarted trans. index 0x1200 + ", |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1183 |
nodeId); |
0 | 1184 |
failedSDO(d, nodeId, whoami, 0, 0, SDOABT_LOCAL_CTRL_ERROR); |
1185 |
return 0xFF; |
|
1186 |
} |
|
215 | 1187 |
/* Reset the wathdog */ |
0 | 1188 |
RestartSDO_TIMER(line) |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1189 |
MSG_WAR(0x3AA1, "Received SDO upload segment defined at index 0x1200 + ", nodeId); |
0 | 1190 |
index = d->transfers[line].index; |
1191 |
subIndex = d->transfers[line].subIndex; |
|
215 | 1192 |
/* Toggle test.*/ |
0 | 1193 |
if (d->transfers[line].toggle != getSDOt(m->data[0])) { |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1194 |
MSG_ERR(0x1AA2, "SDO error : Toggle error : ", getSDOt(m->data[0])); |
0 | 1195 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_TOGGLE_NOT_ALTERNED); |
1196 |
return 0xFF; |
|
1197 |
} |
|
215 | 1198 |
/* Uploading next segment. We need to know if it will be the last one. */ |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1199 |
getSDOlineRestBytes(d, line, &nbBytes); |
0 | 1200 |
if (nbBytes > 7) { |
215 | 1201 |
/* The segment to transfer is not the last one.*/ |
1202 |
/* code to send the next segment. (cs = 0; c = 0) */ |
|
71 | 1203 |
sdo.nodeId = nodeId; /* The server node Id; */ |
0 | 1204 |
sdo.body.data[0] = (d->transfers[line].toggle << 4); |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1205 |
err = lineToSDO(d, line, 7, sdo.body.data + 1); |
0 | 1206 |
if (err) { |
1207 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR); |
|
1208 |
return 0xFF; |
|
1209 |
} |
|
215 | 1210 |
/* Inverting the toggle for the next tranfert. */ |
0 | 1211 |
d->transfers[line].toggle = ! d->transfers[line].toggle & 1; |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1212 |
MSG_WAR(0x3AA3, "SDO. Sending upload segment defined at index 0x1200 + ", nodeId); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1213 |
sendSDO(d, whoami, sdo); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1214 |
} |
0 | 1215 |
else { |
215 | 1216 |
/* Last segment. */ |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1217 |
/* code to send the last segment. (cs = 0; c = 1) */ |
208 | 1218 |
sdo.nodeId = nodeId; /** The server node Id; */ |
587 | 1219 |
sdo.body.data[0] = (UNS8)((d->transfers[line].toggle << 4) | ((7 - nbBytes) << 1) | 1); |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1220 |
err = lineToSDO(d, line, nbBytes, sdo.body.data + 1); |
0 | 1221 |
if (err) { |
1222 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR); |
|
1223 |
return 0xFF; |
|
1224 |
} |
|
1225 |
for (i = nbBytes + 1 ; i < 8 ; i++) |
|
1226 |
sdo.body.data[i] = 0; |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1227 |
MSG_WAR(0x3AA4, "SDO. Sending last upload segment defined at index 0x1200 + ", nodeId); |
0 | 1228 |
sendSDO(d, whoami, sdo); |
215 | 1229 |
/* Release the line */ |
0 | 1230 |
resetSDOline(d, line); |
1231 |
} |
|
71 | 1232 |
} /* end if SERVER*/ |
0 | 1233 |
else { |
215 | 1234 |
/* I am CLIENT */ |
1235 |
/* It is the response for the previous initiate download request. */ |
|
1236 |
/* We should find a line opened for this. */ |
|
0 | 1237 |
err = getSDOlineOnUse( d, nodeId, whoami, &line); |
1238 |
if (!err) |
|
1239 |
err = d->transfers[line].state != SDO_DOWNLOAD_IN_PROGRESS; |
|
1240 |
if (err) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1241 |
MSG_ERR(0x1AA5, "SDO error : Received response for unknown download request from nodeId", nodeId); |
0 | 1242 |
failedSDO(d, nodeId, whoami, 0, 0, SDOABT_LOCAL_CTRL_ERROR); |
1243 |
return 0xFF; |
|
1244 |
} |
|
215 | 1245 |
/* Reset the watchdog */ |
0 | 1246 |
RestartSDO_TIMER(line) |
1247 |
index = d->transfers[line].index; |
|
1248 |
subIndex = d->transfers[line].subIndex; |
|
71 | 1249 |
/* End transmission or requesting next segment. */ |
0 | 1250 |
getSDOlineRestBytes(d, line, &nbBytes); |
1251 |
if (nbBytes == 0) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1252 |
MSG_WAR(0x3AA6, "SDO End download expedited. Response received. from nodeId", nodeId); |
0 | 1253 |
StopSDO_TIMER(line) |
1254 |
d->transfers[line].state = SDO_FINISHED; |
|
32 | 1255 |
if(d->transfers[line].Callback) (*d->transfers[line].Callback)(d,nodeId); |
0 | 1256 |
return 0x00; |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1257 |
} |
0 | 1258 |
if (nbBytes > 7) { |
215 | 1259 |
/* more than one request to send */ |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1260 |
/* code to send the next segment. (cs = 0; c = 0) */ |
208 | 1261 |
sdo.nodeId = nodeId; /** The server node Id; */ |
0 | 1262 |
sdo.body.data[0] = (d->transfers[line].toggle << 4); |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1263 |
err = lineToSDO(d, line, 7, sdo.body.data + 1); |
0 | 1264 |
if (err) { |
1265 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR); |
|
1266 |
return 0xFF; |
|
1267 |
} |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1268 |
} |
0 | 1269 |
else { |
215 | 1270 |
/* Last segment.*/ |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1271 |
/* code to send the last segment. (cs = 0; c = 1) */ |
215 | 1272 |
sdo.nodeId = nodeId; /* The server node Id; */ |
587 | 1273 |
sdo.body.data[0] = (UNS8)((d->transfers[line].toggle << 4) | ((7 - nbBytes) << 1) | 1); |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1274 |
err = lineToSDO(d, line, nbBytes, sdo.body.data + 1); |
0 | 1275 |
if (err) { |
1276 |
failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR); |
|
1277 |
return 0xFF; |
|
1278 |
} |
|
1279 |
for (i = nbBytes + 1 ; i < 8 ; i++) |
|
1280 |
sdo.body.data[i] = 0; |
|
1281 |
} |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1282 |
MSG_WAR(0x3AA7, "SDO sending download segment to nodeId", nodeId); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1283 |
sendSDO(d, whoami, sdo); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1284 |
|
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1285 |
} /* end if I am a CLIENT */ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1286 |
break; |
0 | 1287 |
|
82 | 1288 |
case 4: |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1289 |
abortCode = |
435 | 1290 |
(UNS32)m->data[4] | |
82 | 1291 |
((UNS32)m->data[5] << 8) | |
1292 |
((UNS32)m->data[6] << 16) | |
|
1293 |
((UNS32)m->data[7] << 24); |
|
215 | 1294 |
/* Received SDO abort. */ |
1295 |
/* Looking for the line concerned. */ |
|
0 | 1296 |
if (whoami == SDO_SERVER) { |
1297 |
err = getSDOlineOnUse( d, nodeId, whoami, &line ); |
|
1298 |
if (!err) { |
|
1299 |
resetSDOline( d, line ); |
|
1300 |
MSG_WAR(0x3AA8, "SD0. Received SDO abort. Line released. Code : ", abortCode); |
|
1301 |
} |
|
1302 |
else |
|
1303 |
MSG_WAR(0x3AA9, "SD0. Received SDO abort. No line found. Code : ", abortCode); |
|
215 | 1304 |
/* Tips : The end user has no way to know that the server node has received an abort SDO. */ |
1305 |
/* Its is ok, I think.*/ |
|
0 | 1306 |
} |
215 | 1307 |
else { /* If I am CLIENT */ |
0 | 1308 |
err = getSDOlineOnUse( d, nodeId, whoami, &line ); |
1309 |
if (!err) { |
|
215 | 1310 |
/* The line *must* be released by the core program. */ |
0 | 1311 |
StopSDO_TIMER(line) |
1312 |
d->transfers[line].state = SDO_ABORTED_RCV; |
|
166
b6fbc1c59a44
Added a MicroMod Master sample in examples/TestMasterMicroMod. Fixed some SDO abort code and callback problem in sdo.c.
etisserant
parents:
163
diff
changeset
|
1313 |
d->transfers[line].abortCode = abortCode; |
0 | 1314 |
MSG_WAR(0x3AB0, "SD0. Received SDO abort. Line state ABORTED. Code : ", abortCode); |
163
212a9ea3b968
Added SDO network dictionnary access callback when aborded.
etisserant
parents:
154
diff
changeset
|
1315 |
if(d->transfers[line].Callback) (*d->transfers[line].Callback)(d,nodeId); |
0 | 1316 |
} |
1317 |
else |
|
1318 |
MSG_WAR(0x3AB1, "SD0. Received SDO abort. No line found. Code : ", abortCode); |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1319 |
} |
0 | 1320 |
break; |
1321 |
default: |
|
215 | 1322 |
/* Error : Unknown cs */ |
0 | 1323 |
MSG_ERR(0x1AB2, "SDO. Received unknown command specifier : ", getSDOcs(m->data[0])); |
1324 |
return 0xFF; |
|
1325 |
||
71 | 1326 |
} /* End switch */ |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1327 |
return 0; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1328 |
} |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1329 |
|
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1330 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1331 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1332 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1333 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1334 |
** @param nodeId |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1335 |
** @param index |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1336 |
** @param subIndex |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1337 |
** @param count |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1338 |
** @param dataType |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1339 |
** @param data |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1340 |
** @param Callback |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1341 |
** @param endianize |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1342 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1343 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1344 |
**/ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1345 |
INLINE UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, |
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
1346 |
UNS8 subIndex, UNS32 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize) |
0 | 1347 |
{ |
1348 |
UNS8 err; |
|
1349 |
UNS8 SDOfound = 0; |
|
1350 |
UNS8 line; |
|
71 | 1351 |
s_SDO sdo; /* SDO to transmit */ |
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
1352 |
UNS8 i; |
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
1353 |
UNS32 j; |
0 | 1354 |
UNS16 lastIndex; |
1355 |
UNS16 offset; |
|
311 | 1356 |
UNS8 *pNodeIdServer; |
1357 |
UNS8 nodeIdServer; |
|
0 | 1358 |
|
1359 |
MSG_WAR(0x3AC0, "Send SDO to write in the dictionary of node : ", nodeId); |
|
1360 |
MSG_WAR(0x3AC1, " At index : ", index); |
|
1361 |
MSG_WAR(0x3AC2, " subIndex : ", subIndex); |
|
1362 |
MSG_WAR(0x3AC3, " nb bytes : ", count); |
|
1363 |
||
215 | 1364 |
/* Verify that there is no SDO communication yet. */ |
0 | 1365 |
err = getSDOlineOnUse(d, nodeId, SDO_CLIENT, &line); |
1366 |
if (!err) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1367 |
MSG_ERR(0x1AC4, "SDO error : Communication yet established. with node : ", nodeId); |
0 | 1368 |
return 0xFF; |
1369 |
} |
|
215 | 1370 |
/* Taking the line ... */ |
0 | 1371 |
err = getSDOfreeLine( d, SDO_CLIENT, &line ); |
1372 |
if (err) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1373 |
MSG_ERR(0x1AC5, "SDO error : No line free, too many SDO in progress. Aborted for node : ", nodeId); |
0 | 1374 |
return (0xFF); |
1375 |
} |
|
215 | 1376 |
/* Check which SDO to use to communicate with the node */ |
0 | 1377 |
offset = d->firstIndex->SDO_CLT; |
1378 |
lastIndex = d->lastIndex->SDO_CLT; |
|
1379 |
if (offset == 0) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1380 |
MSG_ERR(0x1AC6, "writeNetworkDict : No SDO client index found", 0); |
0 | 1381 |
return 0xFF; |
1382 |
} |
|
1383 |
i = 0; |
|
1384 |
while (offset <= lastIndex) { |
|
1385 |
if (d->objdict[offset].bSubCount <= 3) { |
|
1386 |
MSG_ERR(0x1AC8, "Subindex 3 not found at index ", 0x1280 + i); |
|
1387 |
return 0xFF; |
|
1388 |
} |
|
215 | 1389 |
/* looking for the nodeId server */ |
311 | 1390 |
pNodeIdServer = (UNS8*) d->objdict[offset].pSubindex[3].pObject; |
0 | 1391 |
nodeIdServer = *pNodeIdServer; |
1392 |
MSG_WAR(0x1AD2, "index : ", 0x1280 + i); |
|
1393 |
MSG_WAR(0x1AD3, "nodeIdServer : ", nodeIdServer); |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1394 |
|
311 | 1395 |
if(nodeIdServer == nodeId) { |
0 | 1396 |
SDOfound = 1; |
1397 |
break; |
|
1398 |
} |
|
1399 |
offset++; |
|
1400 |
i++; |
|
71 | 1401 |
} /* end while */ |
0 | 1402 |
if (!SDOfound) { |
1403 |
MSG_ERR(0x1AC9, "SDO. Error. No client found to communicate with node : ", nodeId); |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1404 |
return 0xFE; |
0 | 1405 |
} |
1406 |
MSG_WAR(0x3AD0," SDO client defined at index : ", 0x1280 + i); |
|
1407 |
initSDOline(d, line, nodeId, index, subIndex, SDO_DOWNLOAD_IN_PROGRESS); |
|
1408 |
d->transfers[line].count = count; |
|
1409 |
d->transfers[line].dataType = dataType; |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1410 |
|
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1411 |
#ifdef SDO_DYNAMIC_BUFFER_ALLOCATION |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1412 |
{ |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1413 |
UNS8* lineData = d->transfers[line].data; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1414 |
if (count > SDO_MAX_LENGTH_TRANSFERT) |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1415 |
{ |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1416 |
d->transfers[line].dynamicData = (UNS8*) malloc(count); |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1417 |
d->transfers[line].dynamicDataSize = count; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1418 |
if (d->transfers[line].dynamicData == NULL) |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1419 |
{ |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1420 |
MSG_ERR(0x1AC9, "SDO. Error. Could not allocate enough bytes : ", count); |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1421 |
return 0xFE; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1422 |
} |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1423 |
lineData = d->transfers[line].dynamicData; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1424 |
} |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1425 |
#endif //SDO_DYNAMIC_BUFFER_ALLOCATION |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1426 |
|
215 | 1427 |
/* Copy data to transfers structure. */ |
0 | 1428 |
for (j = 0 ; j < count ; j++) { |
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1429 |
#ifdef SDO_DYNAMIC_BUFFER_ALLOCATION |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1430 |
# ifdef CANOPEN_BIG_ENDIAN |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1431 |
if (dataType == 0 && endianize) |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1432 |
lineData[count - 1 - j] = ((char *)data)[j]; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1433 |
else /* String of bytes. */ |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1434 |
lineData[j] = ((char *)data)[j]; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1435 |
# else |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1436 |
lineData[j] = ((char *)data)[j]; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1437 |
# endif |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1438 |
} |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1439 |
#else //SDO_DYNAMIC_BUFFER_ALLOCATION |
0 | 1440 |
# ifdef CANOPEN_BIG_ENDIAN |
174
cd1638bc0cb0
Added _writenetworkdictionary option to avoir endianiation
etisserant
parents:
172
diff
changeset
|
1441 |
if (dataType == 0 && endianize) |
0 | 1442 |
d->transfers[line].data[count - 1 - j] = ((char *)data)[j]; |
71 | 1443 |
else /* String of bytes. */ |
0 | 1444 |
d->transfers[line].data[j] = ((char *)data)[j]; |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1445 |
# else |
0 | 1446 |
d->transfers[line].data[j] = ((char *)data)[j]; |
1447 |
# endif |
|
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1448 |
#endif //SDO_DYNAMIC_BUFFER_ALLOCATION |
0 | 1449 |
} |
215 | 1450 |
/* Send the SDO to the server. Initiate download, cs=1. */ |
0 | 1451 |
sdo.nodeId = nodeId; |
215 | 1452 |
if (count <= 4) { /* Expedited transfert */ |
587 | 1453 |
sdo.body.data[0] = (UNS8)((1 << 5) | ((4 - count) << 2) | 3); |
0 | 1454 |
for (i = 4 ; i < 8 ; i++) |
1455 |
sdo.body.data[i] = d->transfers[line].data[i - 4]; |
|
1456 |
d->transfers[line].offset = count; |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1457 |
} |
208 | 1458 |
else { /** Normal transfert */ |
0 | 1459 |
sdo.body.data[0] = (1 << 5) | 1; |
544
7620872e153c
Fixed bugs in SDO caused by UNS8->UNS32 size patch.
etisserant
parents:
539
diff
changeset
|
1460 |
for (i = 0 ; i < 4 ; i++) |
587 | 1461 |
sdo.body.data[i+4] = (UNS8)((count << (i<<3))); /* i*8 */ |
0 | 1462 |
} |
71 | 1463 |
sdo.body.data[1] = index & 0xFF; /* LSB */ |
1464 |
sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */ |
|
0 | 1465 |
sdo.body.data[3] = subIndex; |
154
1b3165f2d17d
Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents:
149
diff
changeset
|
1466 |
|
1b3165f2d17d
Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents:
149
diff
changeset
|
1467 |
d->transfers[line].Callback = Callback; |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1468 |
|
0 | 1469 |
err = sendSDO(d, SDO_CLIENT, sdo); |
1470 |
if (err) { |
|
1471 |
MSG_ERR(0x1AD1, "SDO. Error while sending SDO to node : ", nodeId); |
|
215 | 1472 |
/* release the line */ |
0 | 1473 |
resetSDOline(d, line); |
1474 |
return 0xFF; |
|
32 | 1475 |
} |
154
1b3165f2d17d
Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents:
149
diff
changeset
|
1476 |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1477 |
|
0 | 1478 |
return 0; |
1479 |
} |
|
53 | 1480 |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1481 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1482 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1483 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1484 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1485 |
** @param nodeId |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1486 |
** @param index |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1487 |
** @param subIndex |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1488 |
** @param count |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1489 |
** @param dataType |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1490 |
** @param data |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1491 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1492 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1493 |
**/ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1494 |
UNS8 writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, |
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
1495 |
UNS8 subIndex, UNS32 count, UNS8 dataType, void *data) |
32 | 1496 |
{ |
174
cd1638bc0cb0
Added _writenetworkdictionary option to avoir endianiation
etisserant
parents:
172
diff
changeset
|
1497 |
return _writeNetworkDict (d, nodeId, index, subIndex, count, dataType, data, NULL, 1); |
32 | 1498 |
} |
1499 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1500 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1501 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1502 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1503 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1504 |
** @param nodeId |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1505 |
** @param index |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1506 |
** @param subIndex |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1507 |
** @param count |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1508 |
** @param dataType |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1509 |
** @param data |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1510 |
** @param Callback |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1511 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1512 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1513 |
**/ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1514 |
UNS8 writeNetworkDictCallBack (CO_Data* d, UNS8 nodeId, UNS16 index, |
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
1515 |
UNS8 subIndex, UNS32 count, UNS8 dataType, void *data, SDOCallback_t Callback) |
32 | 1516 |
{ |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1517 |
return _writeNetworkDict (d, nodeId, index, subIndex, count, dataType, data, Callback, 1); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1518 |
} |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1519 |
|
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1520 |
UNS8 writeNetworkDictCallBackAI (CO_Data* d, UNS8 nodeId, UNS16 index, |
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
1521 |
UNS8 subIndex, UNS32 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize) |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1522 |
{ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1523 |
UNS8 ret; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1524 |
UNS16 lastIndex; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1525 |
UNS16 offset; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1526 |
UNS8 nodeIdServer; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1527 |
UNS8 i; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1528 |
|
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1529 |
ret = _writeNetworkDict (d, nodeId, index, subIndex, count, dataType, data, Callback, endianize); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1530 |
if(ret == 0xFE) |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1531 |
{ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1532 |
offset = d->firstIndex->SDO_CLT; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1533 |
lastIndex = d->lastIndex->SDO_CLT; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1534 |
if (offset == 0) |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1535 |
{ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1536 |
MSG_ERR(0x1AC6, "writeNetworkDict : No SDO client index found", 0); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1537 |
return 0xFF; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1538 |
} |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1539 |
i = 0; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1540 |
while (offset <= lastIndex) |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1541 |
{ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1542 |
if (d->objdict[offset].bSubCount <= 3) |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1543 |
{ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1544 |
MSG_ERR(0x1AC8, "Subindex 3 not found at index ", 0x1280 + i); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1545 |
return 0xFF; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1546 |
} |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1547 |
nodeIdServer = *(UNS8*) d->objdict[offset].pSubindex[3].pObject; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1548 |
if(nodeIdServer == 0) |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1549 |
{ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1550 |
*(UNS32*)d->objdict[offset].pSubindex[1].pObject = (UNS32)(0x600 + nodeId); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1551 |
*(UNS32*)d->objdict[offset].pSubindex[2].pObject = (UNS32)(0x580 + nodeId); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1552 |
*(UNS8*) d->objdict[offset].pSubindex[3].pObject = nodeId; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1553 |
return _writeNetworkDict (d, nodeId, index, subIndex, count, dataType, data, Callback, 1); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1554 |
} |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1555 |
offset++; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1556 |
} |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1557 |
return 0xFF; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1558 |
} |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1559 |
else if(ret == 0) |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1560 |
{ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1561 |
return 0; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1562 |
} |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1563 |
else |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1564 |
{ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1565 |
return 0xFF; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1566 |
} |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1567 |
} |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1568 |
|
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1569 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1570 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1571 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1572 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1573 |
** @param nodeId |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1574 |
** @param index |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1575 |
** @param subIndex |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1576 |
** @param dataType |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1577 |
** @param Callback |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1578 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1579 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1580 |
**/ |
71 | 1581 |
INLINE UNS8 _readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback) |
0 | 1582 |
{ |
1583 |
UNS8 err; |
|
1584 |
UNS8 SDOfound = 0; |
|
1585 |
UNS8 i; |
|
1586 |
UNS8 line; |
|
71 | 1587 |
s_SDO sdo; /* SDO to transmit */ |
311 | 1588 |
UNS8 *pNodeIdServer; |
1589 |
UNS8 nodeIdServer; |
|
0 | 1590 |
UNS16 offset; |
1591 |
UNS16 lastIndex; |
|
1592 |
MSG_WAR(0x3AD5, "Send SDO to read in the dictionary of node : ", nodeId); |
|
1593 |
MSG_WAR(0x3AD6, " At index : ", index); |
|
1594 |
MSG_WAR(0x3AD7, " subIndex : ", subIndex); |
|
1595 |
||
1596 |
||
215 | 1597 |
/* Verify that there is no SDO communication yet. */ |
0 | 1598 |
err = getSDOlineOnUse(d, nodeId, SDO_CLIENT, &line); |
1599 |
if (!err) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1600 |
MSG_ERR(0x1AD8, "SDO error : Communication yet established. with node : ", nodeId); |
0 | 1601 |
return 0xFF; |
1602 |
} |
|
215 | 1603 |
/* Taking the line ... */ |
0 | 1604 |
err = getSDOfreeLine( d, SDO_CLIENT, &line ); |
1605 |
if (err) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1606 |
MSG_ERR(0x1AD9, "SDO error : No line free, too many SDO in progress. Aborted for node : ", nodeId); |
0 | 1607 |
return (0xFF); |
1608 |
} |
|
1609 |
else |
|
1610 |
MSG_WAR(0x3AE0, "Transmission on line : ", line); |
|
1611 |
||
215 | 1612 |
/* Check which SDO to use to communicate with the node */ |
0 | 1613 |
offset = d->firstIndex->SDO_CLT; |
1614 |
lastIndex = d->lastIndex->SDO_CLT; |
|
1615 |
if (offset == 0) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1616 |
MSG_ERR(0x1AE1, "writeNetworkDict : No SDO client index found", 0); |
0 | 1617 |
return 0xFF; |
1618 |
} |
|
1619 |
i = 0; |
|
1620 |
while (offset <= lastIndex) { |
|
1621 |
if (d->objdict[offset].bSubCount <= 3) { |
|
1622 |
MSG_ERR(0x1AE2, "Subindex 3 not found at index ", 0x1280 + i); |
|
1623 |
return 0xFF; |
|
1624 |
} |
|
215 | 1625 |
/* looking for the nodeId server */ |
311 | 1626 |
pNodeIdServer = (UNS8*) d->objdict[offset].pSubindex[3].pObject; |
0 | 1627 |
nodeIdServer = *pNodeIdServer; |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1628 |
|
311 | 1629 |
if(nodeIdServer == nodeId) { |
0 | 1630 |
SDOfound = 1; |
1631 |
break; |
|
1632 |
} |
|
1633 |
offset++; |
|
1634 |
i++; |
|
71 | 1635 |
} /* end while */ |
0 | 1636 |
if (!SDOfound) { |
1637 |
MSG_ERR(0x1AE3, "SDO. Error. No client found to communicate with node : ", nodeId); |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1638 |
return 0xFE; |
0 | 1639 |
} |
1640 |
MSG_WAR(0x3AE4," SDO client defined at index : ", 0x1280 + i); |
|
1641 |
initSDOline(d, line, nodeId, index, subIndex, SDO_UPLOAD_IN_PROGRESS); |
|
1642 |
getSDOlineOnUse(d, nodeId, SDO_CLIENT, &line); |
|
1643 |
sdo.nodeId = nodeId; |
|
215 | 1644 |
/* Send the SDO to the server. Initiate upload, cs=2. */ |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1645 |
d->transfers[line].dataType = dataType; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1646 |
sdo.body.data[0] = (2 << 5); |
71 | 1647 |
sdo.body.data[1] = index & 0xFF; /* LSB */ |
1648 |
sdo.body.data[2] = (index >> 8) & 0xFF; /* MSB */ |
|
0 | 1649 |
sdo.body.data[3] = subIndex; |
1650 |
for (i = 4 ; i < 8 ; i++) |
|
1651 |
sdo.body.data[i] = 0; |
|
154
1b3165f2d17d
Implemented writeNetworkDictCallBack test in TestMasterSlave example. Fixed callback assignement race condition in sdo.c.
etisserant
parents:
149
diff
changeset
|
1652 |
d->transfers[line].Callback = Callback; |
0 | 1653 |
err = sendSDO(d, SDO_CLIENT, sdo); |
1654 |
if (err) { |
|
1655 |
MSG_ERR(0x1AE5, "SDO. Error while sending SDO to node : ", nodeId); |
|
71 | 1656 |
/* release the line */ |
0 | 1657 |
resetSDOline(d, line); |
1658 |
return 0xFF; |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1659 |
} |
0 | 1660 |
return 0; |
1661 |
} |
|
1662 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1663 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1664 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1665 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1666 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1667 |
** @param nodeId |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1668 |
** @param index |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1669 |
** @param subIndex |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1670 |
** @param dataType |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1671 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1672 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1673 |
**/ |
32 | 1674 |
UNS8 readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType) |
1675 |
{ |
|
1676 |
return _readNetworkDict (d, nodeId, index, subIndex, dataType, NULL); |
|
1677 |
} |
|
1678 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1679 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1680 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1681 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1682 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1683 |
** @param nodeId |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1684 |
** @param index |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1685 |
** @param subIndex |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1686 |
** @param dataType |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1687 |
** @param Callback |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1688 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1689 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1690 |
**/ |
32 | 1691 |
UNS8 readNetworkDictCallback (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback) |
1692 |
{ |
|
1693 |
return _readNetworkDict (d, nodeId, index, subIndex, dataType, Callback); |
|
1694 |
} |
|
53 | 1695 |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1696 |
UNS8 readNetworkDictCallbackAI (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, UNS8 dataType, SDOCallback_t Callback) |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1697 |
{ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1698 |
UNS8 ret; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1699 |
UNS16 lastIndex; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1700 |
UNS16 offset; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1701 |
UNS8 nodeIdServer; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1702 |
UNS8 i; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1703 |
|
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1704 |
ret = _readNetworkDict (d, nodeId, index, subIndex, dataType, Callback); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1705 |
if(ret == 0xFE) |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1706 |
{ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1707 |
offset = d->firstIndex->SDO_CLT; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1708 |
lastIndex = d->lastIndex->SDO_CLT; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1709 |
if (offset == 0) |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1710 |
{ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1711 |
MSG_ERR(0x1AC6, "writeNetworkDict : No SDO client index found", 0); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1712 |
return 0xFF; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1713 |
} |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1714 |
i = 0; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1715 |
while (offset <= lastIndex) |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1716 |
{ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1717 |
if (d->objdict[offset].bSubCount <= 3) |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1718 |
{ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1719 |
MSG_ERR(0x1AC8, "Subindex 3 not found at index ", 0x1280 + i); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1720 |
return 0xFF; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1721 |
} |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1722 |
nodeIdServer = *(UNS8*) d->objdict[offset].pSubindex[3].pObject; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1723 |
if(nodeIdServer == 0) |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1724 |
{ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1725 |
*(UNS32*)d->objdict[offset].pSubindex[1].pObject = (UNS32)(0x600 + nodeId); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1726 |
*(UNS32*)d->objdict[offset].pSubindex[2].pObject = (UNS32)(0x580 + nodeId); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1727 |
*(UNS8*) d->objdict[offset].pSubindex[3].pObject = nodeId; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1728 |
return _readNetworkDict (d, nodeId, index, subIndex, dataType, Callback); |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1729 |
} |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1730 |
offset++; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1731 |
} |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1732 |
return 0xFF; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1733 |
} |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1734 |
else if(ret == 0) |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1735 |
{ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1736 |
return 0; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1737 |
} |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1738 |
else |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1739 |
{ |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1740 |
return 0xFF; |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1741 |
} |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1742 |
} |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1743 |
|
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1744 |
/*! |
495
b2d6307a89fa
Changed getReadResultNetworkDict behaviour about size. Do not copy more data than pointet by Size arg.
etisserant
parents:
481
diff
changeset
|
1745 |
** |
b2d6307a89fa
Changed getReadResultNetworkDict behaviour about size. Do not copy more data than pointet by Size arg.
etisserant
parents:
481
diff
changeset
|
1746 |
** |
b2d6307a89fa
Changed getReadResultNetworkDict behaviour about size. Do not copy more data than pointet by Size arg.
etisserant
parents:
481
diff
changeset
|
1747 |
** @param d |
b2d6307a89fa
Changed getReadResultNetworkDict behaviour about size. Do not copy more data than pointet by Size arg.
etisserant
parents:
481
diff
changeset
|
1748 |
** @param nodeId |
b2d6307a89fa
Changed getReadResultNetworkDict behaviour about size. Do not copy more data than pointet by Size arg.
etisserant
parents:
481
diff
changeset
|
1749 |
** @param data |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1750 |
** @param size pointer to expected size, changed into returned size. Expected size will be truncated to transfered data size |
495
b2d6307a89fa
Changed getReadResultNetworkDict behaviour about size. Do not copy more data than pointet by Size arg.
etisserant
parents:
481
diff
changeset
|
1751 |
** @param abortCode |
b2d6307a89fa
Changed getReadResultNetworkDict behaviour about size. Do not copy more data than pointet by Size arg.
etisserant
parents:
481
diff
changeset
|
1752 |
** |
b2d6307a89fa
Changed getReadResultNetworkDict behaviour about size. Do not copy more data than pointet by Size arg.
etisserant
parents:
481
diff
changeset
|
1753 |
** @return |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1754 |
**/ |
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
1755 |
UNS8 getReadResultNetworkDict (CO_Data* d, UNS8 nodeId, void* data, UNS32 *size, |
0 | 1756 |
UNS32 * abortCode) |
1757 |
{ |
|
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
1758 |
UNS32 i; |
0 | 1759 |
UNS8 err; |
1760 |
UNS8 line; |
|
499
061f12bd838b
getReadResultNetworkDict now returns abortcode. Now, abort message should be sent correctly from client.
etisserant
parents:
495
diff
changeset
|
1761 |
* abortCode = 0; |
0 | 1762 |
|
215 | 1763 |
/* Looking for the line tranfert. */ |
0 | 1764 |
err = getSDOlineOnUse(d, nodeId, SDO_CLIENT, &line); |
1765 |
if (err) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1766 |
MSG_ERR(0x1AF0, "SDO error : No line found for communication with node : ", nodeId); |
0 | 1767 |
return SDO_ABORTED_INTERNAL; |
1768 |
} |
|
503
8435a9ee54f8
Fixed (again) return of abortcode value in SDO's getReadResultNetworkDict
etisserant
parents:
501
diff
changeset
|
1769 |
* abortCode = d->transfers[line].abortCode; |
0 | 1770 |
if (d->transfers[line].state != SDO_FINISHED) |
1771 |
return d->transfers[line].state; |
|
1772 |
||
544
7620872e153c
Fixed bugs in SDO caused by UNS8->UNS32 size patch.
etisserant
parents:
539
diff
changeset
|
1773 |
/* if SDO initiated with e=0 and s=0 count is null, offset carry effective size*/ |
7620872e153c
Fixed bugs in SDO caused by UNS8->UNS32 size patch.
etisserant
parents:
539
diff
changeset
|
1774 |
if( d->transfers[line].count == 0) |
7620872e153c
Fixed bugs in SDO caused by UNS8->UNS32 size patch.
etisserant
parents:
539
diff
changeset
|
1775 |
d->transfers[line].count = d->transfers[line].offset; |
495
b2d6307a89fa
Changed getReadResultNetworkDict behaviour about size. Do not copy more data than pointet by Size arg.
etisserant
parents:
481
diff
changeset
|
1776 |
/* use transfers[line].count as max size */ |
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
1777 |
if( d->transfers[line].count < *size ) |
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
538
diff
changeset
|
1778 |
*size = d->transfers[line].count; |
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1779 |
|
544
7620872e153c
Fixed bugs in SDO caused by UNS8->UNS32 size patch.
etisserant
parents:
539
diff
changeset
|
1780 |
/* Copy payload to data pointer */ |
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1781 |
#ifdef SDO_DYNAMIC_BUFFER_ALLOCATION |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1782 |
{ |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1783 |
UNS8 *lineData = d->transfers[line].data; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1784 |
|
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1785 |
if (d->transfers[line].dynamicData && d->transfers[line].dynamicDataSize) |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1786 |
{ |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1787 |
lineData = d->transfers[line].dynamicData; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1788 |
} |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1789 |
for ( i = 0 ; i < *size ; i++) { |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1790 |
# ifdef CANOPEN_BIG_ENDIAN |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1791 |
if (d->transfers[line].dataType != visible_string) |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1792 |
( (char *) data)[*size - 1 - i] = lineData[i]; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1793 |
else /* String of bytes. */ |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1794 |
( (char *) data)[i] = lineData[i]; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1795 |
# else |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1796 |
( (char *) data)[i] = lineData[i]; |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1797 |
# endif |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1798 |
} |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1799 |
} |
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1800 |
#else //SDO_DYNAMIC_BUFFER_ALLOCATION |
0 | 1801 |
for ( i = 0 ; i < *size ; i++) { |
1802 |
# ifdef CANOPEN_BIG_ENDIAN |
|
1803 |
if (d->transfers[line].dataType != visible_string) |
|
1804 |
( (char *) data)[*size - 1 - i] = d->transfers[line].data[i]; |
|
215 | 1805 |
else /* String of bytes. */ |
0 | 1806 |
( (char *) data)[i] = d->transfers[line].data[i]; |
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1807 |
# else |
0 | 1808 |
( (char *) data)[i] = d->transfers[line].data[i]; |
1809 |
# endif |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1810 |
} |
636
033fe6f1ec3c
ADDED: - dynamic memory allocation for sdo transfer using malloc and free
Christian Taedcke
parents:
627
diff
changeset
|
1811 |
#endif //SDO_DYNAMIC_BUFFER_ALLOCATION |
0 | 1812 |
return SDO_FINISHED; |
1813 |
} |
|
1814 |
||
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1815 |
/*! |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1816 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1817 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1818 |
** @param d |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1819 |
** @param nodeId |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1820 |
** @param abortCode |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1821 |
** |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1822 |
** @return |
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1823 |
**/ |
0 | 1824 |
UNS8 getWriteResultNetworkDict (CO_Data* d, UNS8 nodeId, UNS32 * abortCode) |
1825 |
{ |
|
1826 |
UNS8 line = 0; |
|
1827 |
UNS8 err; |
|
1828 |
||
1829 |
* abortCode = 0; |
|
215 | 1830 |
/* Looking for the line tranfert. */ |
0 | 1831 |
err = getSDOlineOnUse(d, nodeId, SDO_CLIENT, &line); |
1832 |
if (err) { |
|
506
c17e2e17aca8
Patch from Jari K. implementing automatic SDO clien allocation, and add a new interface for (read/write)networkdict.
etisserant
parents:
503
diff
changeset
|
1833 |
MSG_ERR(0x1AF1, "SDO error : No line found for communication with node : ", nodeId); |
0 | 1834 |
return SDO_ABORTED_INTERNAL; |
1835 |
} |
|
1836 |
* abortCode = d->transfers[line].abortCode; |
|
1837 |
return d->transfers[line].state; |
|
1838 |
} |