115 UNS32 * pExpectedSize,
124 ODCallback_t *Callback;
126 ptrTable = (*d->scanIndexOD)(wIndex, &errorCode, &Callback);
130 if( ptrTable->bSubCount <= bSubindex )
134 return OD_NO_SUCH_SUBINDEX;
137 if (checkAccess && (ptrTable->pSubindex[bSubindex].bAccessType & WO))
139 MSG_WAR(0x2B30,
"Access Type : ", ptrTable->pSubindex[bSubindex].bAccessType);
141 return OD_READ_NOT_ALLOWED;
145 *pDataType = ptrTable->pSubindex[bSubindex].bDataType;
146 szData = ptrTable->pSubindex[bSubindex].size;
148 if(*pExpectedSize == 0 ||
149 *pExpectedSize == szData ||
151 (*pDataType >= visible_string && *pExpectedSize < szData))
154# ifdef CANOPEN_BIG_ENDIAN
155 if(endianize && *pDataType >
boolean && !(
156 *pDataType >= visible_string &&
157 *pDataType <= domain))
161 MSG_WAR(
boolean,
"data type ", *pDataType);
162 MSG_WAR(visible_string,
"data type ", *pDataType);
163 for ( i = szData ; i > 0 ; i--)
166 ((
UNS8*)pDestData)[j++] =
167 ((
UNS8*)ptrTable->pSubindex[bSubindex].pObject)[i-1];
170 *pExpectedSize = szData;
174 if(*pDataType != visible_string)
176 memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject, szData);
177 *pExpectedSize = szData;
184 UNS8 *ptr = (
UNS8*)ptrTable->pSubindex[bSubindex].pObject;
185 UNS8 *ptr_start = ptr;
188 UNS8 *ptr_end = ptr + (*pExpectedSize ? *pExpectedSize : szData) ;
191 while( *ptr && ptr < ptr_end)
193 *(ptr_dest++) = *(ptr++);
196 *pExpectedSize = (
UNS32)(ptr - ptr_start);
198 if (*pExpectedSize < szData)
207 *pExpectedSize = szData;
209 *pExpectedSize, OD_LENGTH_DATA_INVALID);
211 return OD_LENGTH_DATA_INVALID;
239 UNS32 * pExpectedSize,
247 ODCallback_t *Callback;
249 ptrTable =(*d->scanIndexOD)(wIndex, &errorCode, &Callback);
253 if( ptrTable->bSubCount <= bSubindex )
257 return OD_NO_SUCH_SUBINDEX;
259 if (checkAccess && (ptrTable->pSubindex[bSubindex].bAccessType == RO))
261 MSG_WAR(0x2B25,
"Access Type : ", ptrTable->pSubindex[bSubindex].bAccessType);
263 return OD_WRITE_NOT_ALLOWED;
267 dataType = ptrTable->pSubindex[bSubindex].bDataType;
268 szData = ptrTable->pSubindex[bSubindex].size;
270 if( *pExpectedSize == 0 ||
271 *pExpectedSize == szData ||
273 (dataType == visible_string && *pExpectedSize < szData))
275#ifdef CANOPEN_BIG_ENDIAN
277 if(endianize && dataType >
boolean && !(
278 dataType >= visible_string &&
285 for ( i = 0 ; i < ( ptrTable->pSubindex[bSubindex].size >> 1) ; i++)
287 UNS8 tmp =((
UNS8 *)pSourceData) [(ptrTable->pSubindex[bSubindex].size - 1) - i];
288 ((
UNS8 *)pSourceData) [(ptrTable->pSubindex[bSubindex].size - 1) - i] = ((
UNS8 *)pSourceData)[i];
289 ((
UNS8 *)pSourceData)[i] = tmp;
293 errorCode = (*d->valueRangeTest)(dataType, pSourceData);
299 memcpy(ptrTable->pSubindex[bSubindex].pObject,pSourceData, szData);
305 if(dataType == visible_string && *pExpectedSize < szData)
306 ((
UNS8*)ptrTable->pSubindex[bSubindex].pObject)[*pExpectedSize] = 0;
308 *pExpectedSize = szData;
311 if(Callback && Callback[bSubindex])
313 errorCode = (Callback[bSubindex])(d, ptrTable, bSubindex);
321 if (ptrTable->pSubindex[bSubindex].bAccessType & TO_BE_SAVE)
323 (*d->storeODSubIndex)(d, wIndex, bSubindex);
329 *pExpectedSize = szData;
331 return OD_LENGTH_DATA_INVALID;
360ODCallback_t *CallbackList;
363 odentry =
scanIndexOD (d, wIndex, &errorCode, &CallbackList);
364 if(errorCode ==
OD_SUCCESSFUL && CallbackList && bSubindex < odentry->bSubCount)
365 CallbackList[bSubindex] = Callback;
const indextable * scanIndexOD(CO_Data *d, UNS16 wIndex, UNS32 *errorCode, ODCallback_t **Callback)
Scan the index of object dictionary. Used only by setODentry and getODentry.
UNS32 _setODentry(CO_Data *d, UNS16 wIndex, UNS8 bSubindex, void *pSourceData, UNS32 *pExpectedSize, UNS8 checkAccess, UNS8 endianize)
By this function you can write an entry into the object dictionary.
#define accessDictionaryError(index, subIndex, sizeDataDict, sizeDataGiven, code)
Print MSG_WAR (s) if error to the access to the object dictionary occurs.
UNS32 _getODentry(CO_Data *d, UNS16 wIndex, UNS8 bSubindex, void *pDestData, UNS32 *pExpectedSize, UNS8 *pDataType, UNS8 checkAccess, UNS8 endianize)
_getODentry() Reads an entry from the object dictionary.