author | greg |
Wed, 16 Sep 2009 15:19:58 +0200 | |
changeset 592 | b98df76c6fd5 |
parent 588 | ee181b4f177b |
child 594 | 17a171fe7c56 |
permissions | -rw-r--r-- |
0 | 1 |
/* |
208 | 2 |
This file is part of CanFestival, a library implementing CanOpen |
3 |
Stack. |
|
4 |
||
5 |
Copyright (C): Edouard TISSERANT and Francis DUPIN |
|
6 |
||
7 |
See COPYING file for copyrights details. |
|
8 |
||
9 |
This library is free software; you can redistribute it and/or |
|
10 |
modify it under the terms of the GNU Lesser General Public |
|
11 |
License as published by the Free Software Foundation; either |
|
12 |
version 2.1 of the License, or (at your option) any later version. |
|
13 |
||
14 |
This library is distributed in the hope that it will be useful, |
|
15 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
16 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
17 |
Lesser General Public License for more details. |
|
18 |
||
19 |
You should have received a copy of the GNU Lesser General Public |
|
20 |
License along with this library; if not, write to the Free Software |
|
21 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
|
22 |
USA |
|
0 | 23 |
*/ |
208 | 24 |
/*! |
25 |
** @file objacces.c |
|
26 |
** @author Edouard TISSERANT and Francis DUPIN |
|
27 |
** @date Tue Jun 5 08:55:23 2007 |
|
28 |
** |
|
29 |
** @brief |
|
30 |
** |
|
31 |
** |
|
32 |
*/ |
|
33 |
||
34 |
||
35 |
||
0 | 36 |
|
71 | 37 |
/* #define DEBUG_WAR_CONSOLE_ON */ |
38 |
/* #define DEBUG_ERR_CONSOLE_ON */ |
|
11 | 39 |
|
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
|
40 |
|
378
d2abf6c8c27b
As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents:
215
diff
changeset
|
41 |
#include "data.h" |
0 | 42 |
|
469
f2b07ea215b5
Applied edward's patch for OD acces macros (optimization) and boudaries check (safety).
etisserant
parents:
450
diff
changeset
|
43 |
#ifdef DEBUG_WAR_CONSOLE_ON |
208 | 44 |
UNS8 accessDictionaryError(UNS16 index, UNS8 subIndex, |
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
469
diff
changeset
|
45 |
UNS32 sizeDataDict, UNS32 sizeDataGiven, UNS32 code) |
0 | 46 |
{ |
47 |
MSG_WAR(0x2B09,"Dictionary index : ", index); |
|
48 |
MSG_WAR(0X2B10," subindex : ", subIndex); |
|
49 |
switch (code) { |
|
208 | 50 |
case OD_NO_SUCH_OBJECT: |
51 |
MSG_WAR(0x2B11,"Index not found ", index); |
|
52 |
break; |
|
53 |
case OD_NO_SUCH_SUBINDEX : |
|
54 |
MSG_WAR(0x2B12,"SubIndex not found ", subIndex); |
|
55 |
break; |
|
56 |
case OD_WRITE_NOT_ALLOWED : |
|
57 |
MSG_WAR(0x2B13,"Write not allowed, data is read only ", index); |
|
58 |
break; |
|
59 |
case OD_LENGTH_DATA_INVALID : |
|
60 |
MSG_WAR(0x2B14,"Conflict size data. Should be (bytes) : ", sizeDataDict); |
|
61 |
MSG_WAR(0x2B15,"But you have given the size : ", sizeDataGiven); |
|
62 |
break; |
|
63 |
case OD_NOT_MAPPABLE : |
|
64 |
MSG_WAR(0x2B16,"Not mappable data in a PDO at index : ", index); |
|
65 |
break; |
|
66 |
case OD_VALUE_TOO_LOW : |
|
67 |
MSG_WAR(0x2B17,"Value range error : value too low. SDOabort : ", code); |
|
68 |
break; |
|
69 |
case OD_VALUE_TOO_HIGH : |
|
70 |
MSG_WAR(0x2B18,"Value range error : value too high. SDOabort : ", code); |
|
71 |
break; |
|
0 | 72 |
default : |
73 |
MSG_WAR(0x2B20, "Unknown error code : ", code); |
|
74 |
} |
|
469
f2b07ea215b5
Applied edward's patch for OD acces macros (optimization) and boudaries check (safety).
etisserant
parents:
450
diff
changeset
|
75 |
return 0; |
f2b07ea215b5
Applied edward's patch for OD acces macros (optimization) and boudaries check (safety).
etisserant
parents:
450
diff
changeset
|
76 |
} |
f2b07ea215b5
Applied edward's patch for OD acces macros (optimization) and boudaries check (safety).
etisserant
parents:
450
diff
changeset
|
77 |
#else |
f2b07ea215b5
Applied edward's patch for OD acces macros (optimization) and boudaries check (safety).
etisserant
parents:
450
diff
changeset
|
78 |
#define accessDictionaryError(index, subIndex, sizeDataDict, sizeDataGiven, code) |
75
debc68b124b7
compiler compatibility : accessDictionaryError contains nothing out of debogue mode
frdupin
parents:
71
diff
changeset
|
79 |
#endif |
208 | 80 |
|
81 |
UNS32 _getODentry( CO_Data* d, |
|
82 |
UNS16 wIndex, |
|
83 |
UNS8 bSubindex, |
|
84 |
void * pDestData, |
|
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
469
diff
changeset
|
85 |
UNS32 * pExpectedSize, |
208 | 86 |
UNS8 * pDataType, |
87 |
UNS8 checkAccess, |
|
88 |
UNS8 endianize) |
|
215 | 89 |
{ /* DO NOT USE MSG_ERR because the macro may send a PDO -> infinite |
208 | 90 |
loop if it fails. */ |
0 | 91 |
UNS32 errorCode; |
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
469
diff
changeset
|
92 |
UNS32 szData; |
0 | 93 |
const indextable *ptrTable; |
94 |
ODCallback_t *Callback; |
|
95 |
||
96 |
ptrTable = (*d->scanIndexOD)(wIndex, &errorCode, &Callback); |
|
97 |
||
98 |
if (errorCode != OD_SUCCESSFUL) |
|
99 |
return errorCode; |
|
100 |
if( ptrTable->bSubCount <= bSubindex ) { |
|
71 | 101 |
/* Subindex not found */ |
0 | 102 |
accessDictionaryError(wIndex, bSubindex, 0, 0, OD_NO_SUCH_SUBINDEX); |
103 |
return OD_NO_SUCH_SUBINDEX; |
|
104 |
} |
|
208 | 105 |
|
402
77f875d45250
Fixed faulty read access checking on OD access. Added read acces s checking in SDO (was disabled)
etisserant
parents:
378
diff
changeset
|
106 |
if (checkAccess && (ptrTable->pSubindex[bSubindex].bAccessType & WO)) { |
208 | 107 |
MSG_WAR(0x2B30, "Access Type : ", ptrTable->pSubindex[bSubindex].bAccessType); |
450 | 108 |
accessDictionaryError(wIndex, bSubindex, 0, 0, OD_READ_NOT_ALLOWED); |
0 | 109 |
return OD_READ_NOT_ALLOWED; |
110 |
} |
|
111 |
||
112 |
*pDataType = ptrTable->pSubindex[bSubindex].bDataType; |
|
208 | 113 |
szData = ptrTable->pSubindex[bSubindex].size; |
114 |
||
115 |
if(*pExpectedSize == 0 || |
|
116 |
*pExpectedSize == szData || |
|
421
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
117 |
/* allow to fetch a shorter string than expected */ |
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
118 |
(*pDataType >= visible_string && *pExpectedSize < szData)) { |
208 | 119 |
|
12 | 120 |
# ifdef CANOPEN_BIG_ENDIAN |
430 | 121 |
if(endianize && *pDataType > boolean && !( |
122 |
*pDataType >= visible_string && |
|
431 | 123 |
*pDataType <= domain)) { |
215 | 124 |
/* data must be transmited with low byte first */ |
208 | 125 |
UNS8 i, j = 0; |
126 |
MSG_WAR(boolean, "data type ", *pDataType); |
|
127 |
MSG_WAR(visible_string, "data type ", *pDataType); |
|
128 |
for ( i = szData ; i > 0 ; i--) { |
|
129 |
MSG_WAR(i," ", j); |
|
130 |
((UNS8*)pDestData)[j++] = |
|
131 |
((UNS8*)ptrTable->pSubindex[bSubindex].pObject)[i-1]; |
|
132 |
} |
|
431 | 133 |
*pExpectedSize = szData; |
208 | 134 |
} |
419
f63ce68a8239
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
402
diff
changeset
|
135 |
else /* no endianisation change */ |
12 | 136 |
# endif |
421
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
137 |
if(*pDataType != visible_string) { |
419
f63ce68a8239
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
402
diff
changeset
|
138 |
memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData); |
f63ce68a8239
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
402
diff
changeset
|
139 |
*pExpectedSize = szData; |
f63ce68a8239
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
402
diff
changeset
|
140 |
}else{ |
f63ce68a8239
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
402
diff
changeset
|
141 |
/* TODO : CONFORM TO DS-301 : |
f63ce68a8239
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
402
diff
changeset
|
142 |
* - stop using NULL terminated strings |
f63ce68a8239
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
402
diff
changeset
|
143 |
* - store string size in td_subindex |
f63ce68a8239
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
402
diff
changeset
|
144 |
* */ |
f63ce68a8239
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
402
diff
changeset
|
145 |
/* Copy null terminated string to user, and return discovered size */ |
f63ce68a8239
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
402
diff
changeset
|
146 |
UNS8 *ptr = (UNS8*)ptrTable->pSubindex[bSubindex].pObject; |
f63ce68a8239
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
402
diff
changeset
|
147 |
UNS8 *ptr_start = ptr; |
431 | 148 |
/* *pExpectedSize IS < szData . if null, use szData */ |
149 |
UNS8 *ptr_end = ptr + (*pExpectedSize ? *pExpectedSize : szData) ; |
|
429 | 150 |
UNS8 *ptr_dest = (UNS8*)pDestData; |
419
f63ce68a8239
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
402
diff
changeset
|
151 |
while( *ptr && ptr < ptr_end){ |
429 | 152 |
*(ptr_dest++) = *(ptr++); |
419
f63ce68a8239
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
402
diff
changeset
|
153 |
} |
421
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
154 |
|
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
155 |
*pExpectedSize = ptr - ptr_start; |
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
156 |
/* terminate string if not maximum length */ |
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
157 |
if (*pExpectedSize < szData) |
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
158 |
*(ptr) = 0; |
419
f63ce68a8239
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
402
diff
changeset
|
159 |
} |
402
77f875d45250
Fixed faulty read access checking on OD access. Added read acces s checking in SDO (was disabled)
etisserant
parents:
378
diff
changeset
|
160 |
|
208 | 161 |
return OD_SUCCESSFUL; |
162 |
} |
|
215 | 163 |
else { /* Error ! */ |
208 | 164 |
*pExpectedSize = szData; |
165 |
accessDictionaryError(wIndex, bSubindex, szData, |
|
166 |
*pExpectedSize, OD_LENGTH_DATA_INVALID); |
|
167 |
return OD_LENGTH_DATA_INVALID; |
|
168 |
} |
|
169 |
} |
|
170 |
||
588 | 171 |
UNS32 getODentry( CO_Data* OD, |
172 |
UNS16 wIndex, |
|
173 |
UNS8 bSubindex, |
|
174 |
void * pDestData, |
|
175 |
UNS32 * pExpectedSize, |
|
176 |
UNS8 * pDataType, |
|
177 |
UNS8 checkAccess) |
|
178 |
{ |
|
179 |
return _getODentry( OD, wIndex, bSubindex, pDestData, pExpectedSize, |
|
180 |
pDataType, checkAccess, 1); |
|
181 |
} |
|
182 |
||
183 |
UNS32 readLocalDict( CO_Data* OD, |
|
184 |
UNS16 wIndex, |
|
185 |
UNS8 bSubindex, |
|
186 |
void * pDestData, |
|
187 |
UNS32 * pExpectedSize, |
|
188 |
UNS8 * pDataType, |
|
189 |
UNS8 checkAccess) |
|
190 |
{ |
|
191 |
return _getODentry( OD, wIndex, bSubindex, pDestData, pExpectedSize, |
|
192 |
pDataType, checkAccess, 0); |
|
193 |
} |
|
194 |
||
208 | 195 |
UNS32 _setODentry( CO_Data* d, |
196 |
UNS16 wIndex, |
|
197 |
UNS8 bSubindex, |
|
198 |
void * pSourceData, |
|
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
469
diff
changeset
|
199 |
UNS32 * pExpectedSize, |
208 | 200 |
UNS8 checkAccess, |
201 |
UNS8 endianize) |
|
0 | 202 |
{ |
539
187058b4a4b8
Changed OD size from UNS8 to UNS32, and repercuted change to PDO and SDO. Thanks to Jari Kuusisto for patch.
etisserant
parents:
469
diff
changeset
|
203 |
UNS32 szData; |
0 | 204 |
UNS8 dataType; |
205 |
UNS32 errorCode; |
|
206 |
const indextable *ptrTable; |
|
207 |
ODCallback_t *Callback; |
|
208 |
||
209 |
ptrTable =(*d->scanIndexOD)(wIndex, &errorCode, &Callback); |
|
210 |
if (errorCode != OD_SUCCESSFUL) |
|
211 |
return errorCode; |
|
212 |
||
213 |
if( ptrTable->bSubCount <= bSubindex ) { |
|
215 | 214 |
/* Subindex not found */ |
0 | 215 |
accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_NO_SUCH_SUBINDEX); |
216 |
return OD_NO_SUCH_SUBINDEX; |
|
217 |
} |
|
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
|
218 |
if (checkAccess && (ptrTable->pSubindex[bSubindex].bAccessType == RO)) { |
208 | 219 |
MSG_WAR(0x2B25, "Access Type : ", ptrTable->pSubindex[bSubindex].bAccessType); |
0 | 220 |
accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_WRITE_NOT_ALLOWED); |
221 |
return OD_WRITE_NOT_ALLOWED; |
|
222 |
} |
|
223 |
||
224 |
||
208 | 225 |
dataType = ptrTable->pSubindex[bSubindex].bDataType; |
226 |
szData = ptrTable->pSubindex[bSubindex].size; |
|
0 | 227 |
|
228 |
if( *pExpectedSize == 0 || |
|
208 | 229 |
*pExpectedSize == szData || |
421
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
230 |
/* allow to store a shorter string than entry size */ |
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
231 |
(dataType == visible_string && *pExpectedSize < szData)) |
208 | 232 |
{ |
233 |
#ifdef CANOPEN_BIG_ENDIAN |
|
421
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
234 |
/* re-endianize do not occur for bool, strings time and domains */ |
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
235 |
if(endianize && dataType > boolean && !( |
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
236 |
dataType >= visible_string && |
431 | 237 |
dataType <= domain)) |
208 | 238 |
{ |
215 | 239 |
/* we invert the data source directly. This let us do range |
208 | 240 |
testing without */ |
215 | 241 |
/* additional temp variable */ |
208 | 242 |
UNS8 i; |
243 |
for ( i = 0 ; i < ( ptrTable->pSubindex[bSubindex].size >> 1) ; i++) |
|
244 |
{ |
|
245 |
UNS8 tmp =((UNS8 *)pSourceData) [(ptrTable->pSubindex[bSubindex].size - 1) - i]; |
|
246 |
((UNS8 *)pSourceData) [(ptrTable->pSubindex[bSubindex].size - 1) - i] = ((UNS8 *)pSourceData)[i]; |
|
247 |
((UNS8 *)pSourceData)[i] = tmp; |
|
248 |
} |
|
249 |
} |
|
250 |
#endif |
|
0 | 251 |
errorCode = (*d->valueRangeTest)(dataType, pSourceData); |
252 |
if (errorCode) { |
|
208 | 253 |
accessDictionaryError(wIndex, bSubindex, szData, *pExpectedSize, errorCode); |
254 |
return errorCode; |
|
0 | 255 |
} |
2
8d4a822f95e4
Fixed Endianisation/ValueRange order in SetODentry
etisserant
parents:
1
diff
changeset
|
256 |
memcpy(ptrTable->pSubindex[bSubindex].pObject,pSourceData, *pExpectedSize); |
421
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
257 |
/* TODO : CONFORM TO DS-301 : |
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
258 |
* - stop using NULL terminated strings |
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
259 |
* - store string size in td_subindex |
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
260 |
* */ |
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
261 |
/* terminate visible_string with '\0' */ |
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
262 |
if(dataType == visible_string && *pExpectedSize < szData) |
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
263 |
((UNS8*)ptrTable->pSubindex[bSubindex].pObject)[*pExpectedSize] = 0; |
6221b4db8c42
Added support for null terminated strings as VISIBLE_STRING.
etisserant
parents:
419
diff
changeset
|
264 |
|
0 | 265 |
*pExpectedSize = szData; |
208 | 266 |
|
215 | 267 |
/* Callbacks */ |
0 | 268 |
if(Callback && Callback[bSubindex]){ |
437
129bbe0504e4
Now OD callback return val ahev influance on SDO transmission (if callback fall, SDO abord may be signaled)
etisserant
parents:
431
diff
changeset
|
269 |
errorCode = (Callback[bSubindex])(d, ptrTable, bSubindex); |
129bbe0504e4
Now OD callback return val ahev influance on SDO transmission (if callback fall, SDO abord may be signaled)
etisserant
parents:
431
diff
changeset
|
270 |
if(errorCode != OD_SUCCESSFUL) |
129bbe0504e4
Now OD callback return val ahev influance on SDO transmission (if callback fall, SDO abord may be signaled)
etisserant
parents:
431
diff
changeset
|
271 |
{ |
129bbe0504e4
Now OD callback return val ahev influance on SDO transmission (if callback fall, SDO abord may be signaled)
etisserant
parents:
431
diff
changeset
|
272 |
return errorCode; |
129bbe0504e4
Now OD callback return val ahev influance on SDO transmission (if callback fall, SDO abord may be signaled)
etisserant
parents:
431
diff
changeset
|
273 |
} |
129bbe0504e4
Now OD callback return val ahev influance on SDO transmission (if callback fall, SDO abord may be signaled)
etisserant
parents:
431
diff
changeset
|
274 |
} |
208 | 275 |
|
215 | 276 |
/* TODO : Store dans NVRAM */ |
161
c4908cc776a9
SetODEntry now call CO_data->storeODSubEntry(Index,SubIndex) for variables to be Stored (when column Save==True in GUI)
etisserant
parents:
75
diff
changeset
|
277 |
if (ptrTable->pSubindex[bSubindex].bAccessType & TO_BE_SAVE){ |
378
d2abf6c8c27b
As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents:
215
diff
changeset
|
278 |
(*d->storeODSubIndex)(d, wIndex, bSubindex); |
161
c4908cc776a9
SetODEntry now call CO_data->storeODSubEntry(Index,SubIndex) for variables to be Stored (when column Save==True in GUI)
etisserant
parents:
75
diff
changeset
|
279 |
} |
0 | 280 |
return OD_SUCCESSFUL; |
208 | 281 |
}else{ |
0 | 282 |
*pExpectedSize = szData; |
283 |
accessDictionaryError(wIndex, bSubindex, szData, *pExpectedSize, OD_LENGTH_DATA_INVALID); |
|
284 |
return OD_LENGTH_DATA_INVALID; |
|
208 | 285 |
} |
286 |
} |
|
287 |
||
588 | 288 |
UNS32 setODentry( CO_Data* d, |
289 |
UNS16 wIndex, |
|
290 |
UNS8 bSubindex, |
|
291 |
void * pSourceData, |
|
292 |
UNS32 * pExpectedSize, |
|
293 |
UNS8 checkAccess) |
|
294 |
{ |
|
295 |
return _setODentry( d, wIndex, bSubindex, pSourceData, pExpectedSize, |
|
296 |
checkAccess, 1); |
|
297 |
} |
|
298 |
||
299 |
UNS32 writeLocalDict( CO_Data* d, |
|
300 |
UNS16 wIndex, |
|
301 |
UNS8 bSubindex, |
|
302 |
void * pSourceData, |
|
303 |
UNS32 * pExpectedSize, |
|
304 |
UNS8 checkAccess) |
|
305 |
{ |
|
306 |
return _setODentry( d, wIndex, bSubindex, pSourceData, pExpectedSize, checkAccess, 0); |
|
307 |
} |
|
308 |
||
0 | 309 |
const indextable * scanIndexOD (CO_Data* d, UNS16 wIndex, UNS32 *errorCode, ODCallback_t **Callback) |
310 |
{ |
|
311 |
return (*d->scanIndexOD)(wIndex, errorCode, Callback); |
|
312 |
} |
|
313 |
||
314 |
UNS32 RegisterSetODentryCallBack(CO_Data* d, UNS16 wIndex, UNS8 bSubindex, ODCallback_t Callback) |
|
315 |
{ |
|
469
f2b07ea215b5
Applied edward's patch for OD acces macros (optimization) and boudaries check (safety).
etisserant
parents:
450
diff
changeset
|
316 |
UNS32 errorCode; |
f2b07ea215b5
Applied edward's patch for OD acces macros (optimization) and boudaries check (safety).
etisserant
parents:
450
diff
changeset
|
317 |
ODCallback_t *CallbackList; |
f2b07ea215b5
Applied edward's patch for OD acces macros (optimization) and boudaries check (safety).
etisserant
parents:
450
diff
changeset
|
318 |
const indextable *odentry; |
f2b07ea215b5
Applied edward's patch for OD acces macros (optimization) and boudaries check (safety).
etisserant
parents:
450
diff
changeset
|
319 |
|
f2b07ea215b5
Applied edward's patch for OD acces macros (optimization) and boudaries check (safety).
etisserant
parents:
450
diff
changeset
|
320 |
odentry = scanIndexOD (d, wIndex, &errorCode, &CallbackList); |
f2b07ea215b5
Applied edward's patch for OD acces macros (optimization) and boudaries check (safety).
etisserant
parents:
450
diff
changeset
|
321 |
if(errorCode == OD_SUCCESSFUL && CallbackList && bSubindex < odentry->bSubCount) |
208 | 322 |
CallbackList[bSubindex] = Callback; |
323 |
return errorCode; |
|
324 |
} |
|
325 |
||
378
d2abf6c8c27b
As requested long ago, added CoData* parameter to all this applications callback, let application designer use identical callback for multiple nodes, and reduce source code length.
etisserant
parents:
215
diff
changeset
|
326 |
void _storeODSubIndex (CO_Data* d, UNS16 wIndex, UNS8 bSubindex){} |