![](/media/cache/profiles/IMG_2753.JPG.50x50_q85.jpg)
Can_open_masternode
framework/src/objacces.c@7:537bae5a6fc6, 2012-09-26 (annotated)
- Committer:
- sam_grove
- Date:
- Wed Sep 26 05:48:14 2012 +0000
- Revision:
- 7:537bae5a6fc6
- Parent:
- 0:9dd7c6129683
Pushing the project into the new repo
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sam_grove |
0:9dd7c6129683 | 1 | /* |
sam_grove |
0:9dd7c6129683 | 2 | This file is part of CanFestival, a library implementing CanOpen |
sam_grove |
0:9dd7c6129683 | 3 | Stack. |
sam_grove |
0:9dd7c6129683 | 4 | |
sam_grove |
0:9dd7c6129683 | 5 | Copyright (C): Edouard TISSERANT and Francis DUPIN |
sam_grove |
0:9dd7c6129683 | 6 | |
sam_grove |
0:9dd7c6129683 | 7 | See COPYING file for copyrights details. |
sam_grove |
0:9dd7c6129683 | 8 | |
sam_grove |
0:9dd7c6129683 | 9 | This library is free software; you can redistribute it and/or |
sam_grove |
0:9dd7c6129683 | 10 | modify it under the terms of the GNU Lesser General Public |
sam_grove |
0:9dd7c6129683 | 11 | License as published by the Free Software Foundation; either |
sam_grove |
0:9dd7c6129683 | 12 | version 2.1 of the License, or (at your option) any later version. |
sam_grove |
0:9dd7c6129683 | 13 | |
sam_grove |
0:9dd7c6129683 | 14 | This library is distributed in the hope that it will be useful, |
sam_grove |
0:9dd7c6129683 | 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
sam_grove |
0:9dd7c6129683 | 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
sam_grove |
0:9dd7c6129683 | 17 | Lesser General Public License for more details. |
sam_grove |
0:9dd7c6129683 | 18 | |
sam_grove |
0:9dd7c6129683 | 19 | You should have received a copy of the GNU Lesser General Public |
sam_grove |
0:9dd7c6129683 | 20 | License along with this library; if not, write to the Free Software |
sam_grove |
0:9dd7c6129683 | 21 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 |
sam_grove |
0:9dd7c6129683 | 22 | USA |
sam_grove |
0:9dd7c6129683 | 23 | */ |
sam_grove |
0:9dd7c6129683 | 24 | /*! |
sam_grove |
0:9dd7c6129683 | 25 | ** @file objacces.c |
sam_grove |
0:9dd7c6129683 | 26 | ** @author Edouard TISSERANT and Francis DUPIN |
sam_grove |
0:9dd7c6129683 | 27 | ** @date Tue Jun 5 08:55:23 2007 |
sam_grove |
0:9dd7c6129683 | 28 | ** |
sam_grove |
0:9dd7c6129683 | 29 | ** @brief |
sam_grove |
0:9dd7c6129683 | 30 | ** |
sam_grove |
0:9dd7c6129683 | 31 | ** |
sam_grove |
0:9dd7c6129683 | 32 | */ |
sam_grove |
0:9dd7c6129683 | 33 | |
sam_grove |
0:9dd7c6129683 | 34 | |
sam_grove |
0:9dd7c6129683 | 35 | |
sam_grove |
0:9dd7c6129683 | 36 | |
sam_grove |
0:9dd7c6129683 | 37 | /* #define DEBUG_WAR_CONSOLE_ON */ |
sam_grove |
0:9dd7c6129683 | 38 | /* #define DEBUG_ERR_CONSOLE_ON */ |
sam_grove |
0:9dd7c6129683 | 39 | |
sam_grove |
0:9dd7c6129683 | 40 | |
sam_grove |
0:9dd7c6129683 | 41 | #include "data.h" |
sam_grove |
0:9dd7c6129683 | 42 | |
sam_grove |
0:9dd7c6129683 | 43 | //We need the function implementation for linking |
sam_grove |
0:9dd7c6129683 | 44 | //Only a placeholder with a define isnt enough! |
sam_grove |
0:9dd7c6129683 | 45 | UNS8 accessDictionaryError(UNS16 index, UNS8 subIndex, |
sam_grove |
0:9dd7c6129683 | 46 | UNS32 sizeDataDict, UNS32 sizeDataGiven, UNS32 code) |
sam_grove |
0:9dd7c6129683 | 47 | { |
sam_grove |
0:9dd7c6129683 | 48 | #ifdef DEBUG_WAR_CONSOLE_ON |
sam_grove |
0:9dd7c6129683 | 49 | MSG_WAR(0x2B09,"Dictionary index : ", index); |
sam_grove |
0:9dd7c6129683 | 50 | MSG_WAR(0X2B10," subindex : ", subIndex); |
sam_grove |
0:9dd7c6129683 | 51 | switch (code) { |
sam_grove |
0:9dd7c6129683 | 52 | case OD_NO_SUCH_OBJECT: |
sam_grove |
0:9dd7c6129683 | 53 | MSG_WAR(0x2B11,"Index not found ", index); |
sam_grove |
0:9dd7c6129683 | 54 | break; |
sam_grove |
0:9dd7c6129683 | 55 | case OD_NO_SUCH_SUBINDEX : |
sam_grove |
0:9dd7c6129683 | 56 | MSG_WAR(0x2B12,"SubIndex not found ", subIndex); |
sam_grove |
0:9dd7c6129683 | 57 | break; |
sam_grove |
0:9dd7c6129683 | 58 | case OD_WRITE_NOT_ALLOWED : |
sam_grove |
0:9dd7c6129683 | 59 | MSG_WAR(0x2B13,"Write not allowed, data is read only ", index); |
sam_grove |
0:9dd7c6129683 | 60 | break; |
sam_grove |
0:9dd7c6129683 | 61 | case OD_LENGTH_DATA_INVALID : |
sam_grove |
0:9dd7c6129683 | 62 | MSG_WAR(0x2B14,"Conflict size data. Should be (bytes) : ", sizeDataDict); |
sam_grove |
0:9dd7c6129683 | 63 | MSG_WAR(0x2B15,"But you have given the size : ", sizeDataGiven); |
sam_grove |
0:9dd7c6129683 | 64 | break; |
sam_grove |
0:9dd7c6129683 | 65 | case OD_NOT_MAPPABLE : |
sam_grove |
0:9dd7c6129683 | 66 | MSG_WAR(0x2B16,"Not mappable data in a PDO at index : ", index); |
sam_grove |
0:9dd7c6129683 | 67 | break; |
sam_grove |
0:9dd7c6129683 | 68 | case OD_VALUE_TOO_LOW : |
sam_grove |
0:9dd7c6129683 | 69 | MSG_WAR(0x2B17,"Value range error : value too low. SDOabort : ", code); |
sam_grove |
0:9dd7c6129683 | 70 | break; |
sam_grove |
0:9dd7c6129683 | 71 | case OD_VALUE_TOO_HIGH : |
sam_grove |
0:9dd7c6129683 | 72 | MSG_WAR(0x2B18,"Value range error : value too high. SDOabort : ", code); |
sam_grove |
0:9dd7c6129683 | 73 | break; |
sam_grove |
0:9dd7c6129683 | 74 | default : |
sam_grove |
0:9dd7c6129683 | 75 | MSG_WAR(0x2B20, "Unknown error code : ", code); |
sam_grove |
0:9dd7c6129683 | 76 | } |
sam_grove |
0:9dd7c6129683 | 77 | #endif |
sam_grove |
0:9dd7c6129683 | 78 | |
sam_grove |
0:9dd7c6129683 | 79 | return 0; |
sam_grove |
0:9dd7c6129683 | 80 | } |
sam_grove |
0:9dd7c6129683 | 81 | |
sam_grove |
0:9dd7c6129683 | 82 | UNS32 _getODentry( CO_Data* d, |
sam_grove |
0:9dd7c6129683 | 83 | UNS16 wIndex, |
sam_grove |
0:9dd7c6129683 | 84 | UNS8 bSubindex, |
sam_grove |
0:9dd7c6129683 | 85 | void * pDestData, |
sam_grove |
0:9dd7c6129683 | 86 | UNS32 * pExpectedSize, |
sam_grove |
0:9dd7c6129683 | 87 | UNS8 * pDataType, |
sam_grove |
0:9dd7c6129683 | 88 | UNS8 checkAccess, |
sam_grove |
0:9dd7c6129683 | 89 | UNS8 endianize) |
sam_grove |
0:9dd7c6129683 | 90 | { /* DO NOT USE MSG_ERR because the macro may send a PDO -> infinite |
sam_grove |
0:9dd7c6129683 | 91 | loop if it fails. */ |
sam_grove |
0:9dd7c6129683 | 92 | UNS32 errorCode; |
sam_grove |
0:9dd7c6129683 | 93 | UNS32 szData; |
sam_grove |
0:9dd7c6129683 | 94 | const indextable *ptrTable; |
sam_grove |
0:9dd7c6129683 | 95 | ODCallback_t *Callback; |
sam_grove |
0:9dd7c6129683 | 96 | |
sam_grove |
0:9dd7c6129683 | 97 | ptrTable = (*d->scanIndexOD)(wIndex, &errorCode, &Callback); |
sam_grove |
0:9dd7c6129683 | 98 | |
sam_grove |
0:9dd7c6129683 | 99 | if (errorCode != OD_SUCCESSFUL) |
sam_grove |
0:9dd7c6129683 | 100 | return errorCode; |
sam_grove |
0:9dd7c6129683 | 101 | if( ptrTable->bSubCount <= bSubindex ) { |
sam_grove |
0:9dd7c6129683 | 102 | /* Subindex not found */ |
sam_grove |
0:9dd7c6129683 | 103 | accessDictionaryError(wIndex, bSubindex, 0, 0, OD_NO_SUCH_SUBINDEX); |
sam_grove |
0:9dd7c6129683 | 104 | return OD_NO_SUCH_SUBINDEX; |
sam_grove |
0:9dd7c6129683 | 105 | } |
sam_grove |
0:9dd7c6129683 | 106 | |
sam_grove |
0:9dd7c6129683 | 107 | if (checkAccess && (ptrTable->pSubindex[bSubindex].bAccessType & WO)) { |
sam_grove |
0:9dd7c6129683 | 108 | MSG_WAR(0x2B30, "Access Type : ", ptrTable->pSubindex[bSubindex].bAccessType); |
sam_grove |
0:9dd7c6129683 | 109 | accessDictionaryError(wIndex, bSubindex, 0, 0, OD_READ_NOT_ALLOWED); |
sam_grove |
0:9dd7c6129683 | 110 | return OD_READ_NOT_ALLOWED; |
sam_grove |
0:9dd7c6129683 | 111 | } |
sam_grove |
0:9dd7c6129683 | 112 | |
sam_grove |
0:9dd7c6129683 | 113 | *pDataType = ptrTable->pSubindex[bSubindex].bDataType; |
sam_grove |
0:9dd7c6129683 | 114 | szData = ptrTable->pSubindex[bSubindex].size; |
sam_grove |
0:9dd7c6129683 | 115 | |
sam_grove |
0:9dd7c6129683 | 116 | if(*pExpectedSize == 0 || |
sam_grove |
0:9dd7c6129683 | 117 | *pExpectedSize == szData || |
sam_grove |
0:9dd7c6129683 | 118 | /* allow to fetch a shorter string than expected */ |
sam_grove |
0:9dd7c6129683 | 119 | (*pDataType >= visible_string && *pExpectedSize < szData)) { |
sam_grove |
0:9dd7c6129683 | 120 | |
sam_grove |
0:9dd7c6129683 | 121 | # ifdef CANOPEN_BIG_ENDIAN |
sam_grove |
0:9dd7c6129683 | 122 | if(endianize && *pDataType > boolean && !( |
sam_grove |
0:9dd7c6129683 | 123 | *pDataType >= visible_string && |
sam_grove |
0:9dd7c6129683 | 124 | *pDataType <= domain)) { |
sam_grove |
0:9dd7c6129683 | 125 | /* data must be transmited with low byte first */ |
sam_grove |
0:9dd7c6129683 | 126 | UNS8 i, j = 0; |
sam_grove |
0:9dd7c6129683 | 127 | MSG_WAR(boolean, "data type ", *pDataType); |
sam_grove |
0:9dd7c6129683 | 128 | MSG_WAR(visible_string, "data type ", *pDataType); |
sam_grove |
0:9dd7c6129683 | 129 | for ( i = szData ; i > 0 ; i--) { |
sam_grove |
0:9dd7c6129683 | 130 | MSG_WAR(i," ", j); |
sam_grove |
0:9dd7c6129683 | 131 | ((UNS8*)pDestData)[j++] = |
sam_grove |
0:9dd7c6129683 | 132 | ((UNS8*)ptrTable->pSubindex[bSubindex].pObject)[i-1]; |
sam_grove |
0:9dd7c6129683 | 133 | } |
sam_grove |
0:9dd7c6129683 | 134 | *pExpectedSize = szData; |
sam_grove |
0:9dd7c6129683 | 135 | } |
sam_grove |
0:9dd7c6129683 | 136 | else /* no endianisation change */ |
sam_grove |
0:9dd7c6129683 | 137 | # endif |
sam_grove |
0:9dd7c6129683 | 138 | if(*pDataType != visible_string) { |
sam_grove |
0:9dd7c6129683 | 139 | memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData); |
sam_grove |
0:9dd7c6129683 | 140 | *pExpectedSize = szData; |
sam_grove |
0:9dd7c6129683 | 141 | }else{ |
sam_grove |
0:9dd7c6129683 | 142 | /* TODO : CONFORM TO DS-301 : |
sam_grove |
0:9dd7c6129683 | 143 | * - stop using NULL terminated strings |
sam_grove |
0:9dd7c6129683 | 144 | * - store string size in td_subindex |
sam_grove |
0:9dd7c6129683 | 145 | * */ |
sam_grove |
0:9dd7c6129683 | 146 | /* Copy null terminated string to user, and return discovered size */ |
sam_grove |
0:9dd7c6129683 | 147 | UNS8 *ptr = (UNS8*)ptrTable->pSubindex[bSubindex].pObject; |
sam_grove |
0:9dd7c6129683 | 148 | UNS8 *ptr_start = ptr; |
sam_grove |
0:9dd7c6129683 | 149 | /* *pExpectedSize IS < szData . if null, use szData */ |
sam_grove |
0:9dd7c6129683 | 150 | UNS8 *ptr_end = ptr + (*pExpectedSize ? *pExpectedSize : szData) ; |
sam_grove |
0:9dd7c6129683 | 151 | UNS8 *ptr_dest = (UNS8*)pDestData; |
sam_grove |
0:9dd7c6129683 | 152 | while( *ptr && ptr < ptr_end){ |
sam_grove |
0:9dd7c6129683 | 153 | *(ptr_dest++) = *(ptr++); |
sam_grove |
0:9dd7c6129683 | 154 | } |
sam_grove |
0:9dd7c6129683 | 155 | |
sam_grove |
0:9dd7c6129683 | 156 | *pExpectedSize = (UNS32) (ptr - ptr_start); |
sam_grove |
0:9dd7c6129683 | 157 | /* terminate string if not maximum length */ |
sam_grove |
0:9dd7c6129683 | 158 | if (*pExpectedSize < szData) |
sam_grove |
0:9dd7c6129683 | 159 | *(ptr) = 0; |
sam_grove |
0:9dd7c6129683 | 160 | } |
sam_grove |
0:9dd7c6129683 | 161 | |
sam_grove |
0:9dd7c6129683 | 162 | return OD_SUCCESSFUL; |
sam_grove |
0:9dd7c6129683 | 163 | } |
sam_grove |
0:9dd7c6129683 | 164 | else { /* Error ! */ |
sam_grove |
0:9dd7c6129683 | 165 | *pExpectedSize = szData; |
sam_grove |
0:9dd7c6129683 | 166 | accessDictionaryError(wIndex, bSubindex, szData, |
sam_grove |
0:9dd7c6129683 | 167 | *pExpectedSize, OD_LENGTH_DATA_INVALID); |
sam_grove |
0:9dd7c6129683 | 168 | return OD_LENGTH_DATA_INVALID; |
sam_grove |
0:9dd7c6129683 | 169 | } |
sam_grove |
0:9dd7c6129683 | 170 | } |
sam_grove |
0:9dd7c6129683 | 171 | |
sam_grove |
0:9dd7c6129683 | 172 | UNS32 _setODentry( CO_Data* d, |
sam_grove |
0:9dd7c6129683 | 173 | UNS16 wIndex, |
sam_grove |
0:9dd7c6129683 | 174 | UNS8 bSubindex, |
sam_grove |
0:9dd7c6129683 | 175 | void * pSourceData, |
sam_grove |
0:9dd7c6129683 | 176 | UNS32 * pExpectedSize, |
sam_grove |
0:9dd7c6129683 | 177 | UNS8 checkAccess, |
sam_grove |
0:9dd7c6129683 | 178 | UNS8 endianize) |
sam_grove |
0:9dd7c6129683 | 179 | { |
sam_grove |
0:9dd7c6129683 | 180 | UNS32 szData; |
sam_grove |
0:9dd7c6129683 | 181 | UNS8 dataType; |
sam_grove |
0:9dd7c6129683 | 182 | UNS32 errorCode; |
sam_grove |
0:9dd7c6129683 | 183 | const indextable *ptrTable; |
sam_grove |
0:9dd7c6129683 | 184 | ODCallback_t *Callback; |
sam_grove |
0:9dd7c6129683 | 185 | |
sam_grove |
0:9dd7c6129683 | 186 | ptrTable =(*d->scanIndexOD)(wIndex, &errorCode, &Callback); |
sam_grove |
0:9dd7c6129683 | 187 | if (errorCode != OD_SUCCESSFUL) |
sam_grove |
0:9dd7c6129683 | 188 | return errorCode; |
sam_grove |
0:9dd7c6129683 | 189 | |
sam_grove |
0:9dd7c6129683 | 190 | if( ptrTable->bSubCount <= bSubindex ) { |
sam_grove |
0:9dd7c6129683 | 191 | /* Subindex not found */ |
sam_grove |
0:9dd7c6129683 | 192 | accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_NO_SUCH_SUBINDEX); |
sam_grove |
0:9dd7c6129683 | 193 | return OD_NO_SUCH_SUBINDEX; |
sam_grove |
0:9dd7c6129683 | 194 | } |
sam_grove |
0:9dd7c6129683 | 195 | if (checkAccess && (ptrTable->pSubindex[bSubindex].bAccessType == RO)) { |
sam_grove |
0:9dd7c6129683 | 196 | MSG_WAR(0x2B25, "Access Type : ", ptrTable->pSubindex[bSubindex].bAccessType); |
sam_grove |
0:9dd7c6129683 | 197 | accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_WRITE_NOT_ALLOWED); |
sam_grove |
0:9dd7c6129683 | 198 | return OD_WRITE_NOT_ALLOWED; |
sam_grove |
0:9dd7c6129683 | 199 | } |
sam_grove |
0:9dd7c6129683 | 200 | |
sam_grove |
0:9dd7c6129683 | 201 | |
sam_grove |
0:9dd7c6129683 | 202 | dataType = ptrTable->pSubindex[bSubindex].bDataType; |
sam_grove |
0:9dd7c6129683 | 203 | szData = ptrTable->pSubindex[bSubindex].size; |
sam_grove |
0:9dd7c6129683 | 204 | |
sam_grove |
0:9dd7c6129683 | 205 | if( *pExpectedSize == 0 || |
sam_grove |
0:9dd7c6129683 | 206 | *pExpectedSize == szData || |
sam_grove |
0:9dd7c6129683 | 207 | /* allow to store a shorter string than entry size */ |
sam_grove |
0:9dd7c6129683 | 208 | (dataType == visible_string && *pExpectedSize < szData)) |
sam_grove |
0:9dd7c6129683 | 209 | { |
sam_grove |
0:9dd7c6129683 | 210 | #ifdef CANOPEN_BIG_ENDIAN |
sam_grove |
0:9dd7c6129683 | 211 | /* re-endianize do not occur for bool, strings time and domains */ |
sam_grove |
0:9dd7c6129683 | 212 | if(endianize && dataType > boolean && !( |
sam_grove |
0:9dd7c6129683 | 213 | dataType >= visible_string && |
sam_grove |
0:9dd7c6129683 | 214 | dataType <= domain)) |
sam_grove |
0:9dd7c6129683 | 215 | { |
sam_grove |
0:9dd7c6129683 | 216 | /* we invert the data source directly. This let us do range |
sam_grove |
0:9dd7c6129683 | 217 | testing without */ |
sam_grove |
0:9dd7c6129683 | 218 | /* additional temp variable */ |
sam_grove |
0:9dd7c6129683 | 219 | UNS8 i; |
sam_grove |
0:9dd7c6129683 | 220 | for ( i = 0 ; i < ( ptrTable->pSubindex[bSubindex].size >> 1) ; i++) |
sam_grove |
0:9dd7c6129683 | 221 | { |
sam_grove |
0:9dd7c6129683 | 222 | UNS8 tmp =((UNS8 *)pSourceData) [(ptrTable->pSubindex[bSubindex].size - 1) - i]; |
sam_grove |
0:9dd7c6129683 | 223 | ((UNS8 *)pSourceData) [(ptrTable->pSubindex[bSubindex].size - 1) - i] = ((UNS8 *)pSourceData)[i]; |
sam_grove |
0:9dd7c6129683 | 224 | ((UNS8 *)pSourceData)[i] = tmp; |
sam_grove |
0:9dd7c6129683 | 225 | } |
sam_grove |
0:9dd7c6129683 | 226 | } |
sam_grove |
0:9dd7c6129683 | 227 | #endif |
sam_grove |
0:9dd7c6129683 | 228 | errorCode = (*d->valueRangeTest)(dataType, pSourceData); |
sam_grove |
0:9dd7c6129683 | 229 | if (errorCode) { |
sam_grove |
0:9dd7c6129683 | 230 | accessDictionaryError(wIndex, bSubindex, szData, *pExpectedSize, errorCode); |
sam_grove |
0:9dd7c6129683 | 231 | return errorCode; |
sam_grove |
0:9dd7c6129683 | 232 | } |
sam_grove |
0:9dd7c6129683 | 233 | memcpy(ptrTable->pSubindex[bSubindex].pObject,pSourceData, *pExpectedSize); |
sam_grove |
0:9dd7c6129683 | 234 | /* TODO : CONFORM TO DS-301 : |
sam_grove |
0:9dd7c6129683 | 235 | * - stop using NULL terminated strings |
sam_grove |
0:9dd7c6129683 | 236 | * - store string size in td_subindex |
sam_grove |
0:9dd7c6129683 | 237 | * */ |
sam_grove |
0:9dd7c6129683 | 238 | /* terminate visible_string with '\0' */ |
sam_grove |
0:9dd7c6129683 | 239 | if(dataType == visible_string && *pExpectedSize < szData) |
sam_grove |
0:9dd7c6129683 | 240 | ((UNS8*)ptrTable->pSubindex[bSubindex].pObject)[*pExpectedSize] = 0; |
sam_grove |
0:9dd7c6129683 | 241 | |
sam_grove |
0:9dd7c6129683 | 242 | *pExpectedSize = szData; |
sam_grove |
0:9dd7c6129683 | 243 | |
sam_grove |
0:9dd7c6129683 | 244 | /* Callbacks */ |
sam_grove |
0:9dd7c6129683 | 245 | if(Callback && Callback[bSubindex]){ |
sam_grove |
0:9dd7c6129683 | 246 | errorCode = (Callback[bSubindex])(d, ptrTable, bSubindex); |
sam_grove |
0:9dd7c6129683 | 247 | if(errorCode != OD_SUCCESSFUL) |
sam_grove |
0:9dd7c6129683 | 248 | { |
sam_grove |
0:9dd7c6129683 | 249 | return errorCode; |
sam_grove |
0:9dd7c6129683 | 250 | } |
sam_grove |
0:9dd7c6129683 | 251 | } |
sam_grove |
0:9dd7c6129683 | 252 | |
sam_grove |
0:9dd7c6129683 | 253 | /* TODO : Store dans NVRAM */ |
sam_grove |
0:9dd7c6129683 | 254 | if (ptrTable->pSubindex[bSubindex].bAccessType & TO_BE_SAVE){ |
sam_grove |
0:9dd7c6129683 | 255 | (*d->storeODSubIndex)(d, wIndex, bSubindex); |
sam_grove |
0:9dd7c6129683 | 256 | } |
sam_grove |
0:9dd7c6129683 | 257 | return OD_SUCCESSFUL; |
sam_grove |
0:9dd7c6129683 | 258 | }else{ |
sam_grove |
0:9dd7c6129683 | 259 | *pExpectedSize = szData; |
sam_grove |
0:9dd7c6129683 | 260 | accessDictionaryError(wIndex, bSubindex, szData, *pExpectedSize, OD_LENGTH_DATA_INVALID); |
sam_grove |
0:9dd7c6129683 | 261 | return OD_LENGTH_DATA_INVALID; |
sam_grove |
0:9dd7c6129683 | 262 | } |
sam_grove |
0:9dd7c6129683 | 263 | } |
sam_grove |
0:9dd7c6129683 | 264 | |
sam_grove |
0:9dd7c6129683 | 265 | const indextable * scanIndexOD (CO_Data* d, UNS16 wIndex, UNS32 *errorCode, ODCallback_t **Callback) |
sam_grove |
0:9dd7c6129683 | 266 | { |
sam_grove |
0:9dd7c6129683 | 267 | return (*d->scanIndexOD)(wIndex, errorCode, Callback); |
sam_grove |
0:9dd7c6129683 | 268 | } |
sam_grove |
0:9dd7c6129683 | 269 | |
sam_grove |
0:9dd7c6129683 | 270 | UNS32 RegisterSetODentryCallBack(CO_Data* d, UNS16 wIndex, UNS8 bSubindex, ODCallback_t Callback) |
sam_grove |
0:9dd7c6129683 | 271 | { |
sam_grove |
0:9dd7c6129683 | 272 | UNS32 errorCode; |
sam_grove |
0:9dd7c6129683 | 273 | ODCallback_t *CallbackList; |
sam_grove |
0:9dd7c6129683 | 274 | const indextable *odentry; |
sam_grove |
0:9dd7c6129683 | 275 | |
sam_grove |
0:9dd7c6129683 | 276 | odentry = scanIndexOD (d, wIndex, &errorCode, &CallbackList); |
sam_grove |
0:9dd7c6129683 | 277 | if(errorCode == OD_SUCCESSFUL && CallbackList && bSubindex < odentry->bSubCount) |
sam_grove |
0:9dd7c6129683 | 278 | CallbackList[bSubindex] = Callback; |
sam_grove |
0:9dd7c6129683 | 279 | return errorCode; |
sam_grove |
0:9dd7c6129683 | 280 | } |
sam_grove |
0:9dd7c6129683 | 281 | |
sam_grove |
0:9dd7c6129683 | 282 | void _storeODSubIndex (CO_Data* d, UNS16 wIndex, UNS8 bSubindex){} |