src/objacces.c
changeset 208 05d95c45b388
parent 175 e255529b6f7d
child 215 f49e5a6b7804
equal deleted inserted replaced
207:b6572d0336c3 208:05d95c45b388
     1 /*
     1 /*
     2 This file is part of CanFestival, a library implementing CanOpen Stack. 
     2   This file is part of CanFestival, a library implementing CanOpen
     3 
     3   Stack.
     4 Copyright (C): Edouard TISSERANT and Francis DUPIN
     4 
     5 
     5   Copyright (C): Edouard TISSERANT and Francis DUPIN
     6 See COPYING file for copyrights details.
     6 
     7 
     7   See COPYING file for copyrights details.
     8 This library is free software; you can redistribute it and/or
     8 
     9 modify it under the terms of the GNU Lesser General Public
     9   This library is free software; you can redistribute it and/or
    10 License as published by the Free Software Foundation; either
    10   modify it under the terms of the GNU Lesser General Public
    11 version 2.1 of the License, or (at your option) any later version.
    11   License as published by the Free Software Foundation; either
    12 
    12   version 2.1 of the License, or (at your option) any later version.
    13 This library is distributed in the hope that it will be useful,
    13 
    14 but WITHOUT ANY WARRANTY; without even the implied warranty of
    14   This library is distributed in the hope that it will be useful,
    15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    15   but WITHOUT ANY WARRANTY; without even the implied warranty of
    16 Lesser General Public License for more details.
    16   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    17 
    17   Lesser General Public License for more details.
    18 You should have received a copy of the GNU Lesser General Public
    18 
    19 License along with this library; if not, write to the Free Software
    19   You should have received a copy of the GNU Lesser General Public
    20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    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
    21 */
    23 */
       
    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 
    22 
    36 
    23 /* #define DEBUG_WAR_CONSOLE_ON */
    37 /* #define DEBUG_WAR_CONSOLE_ON */
    24 /* #define DEBUG_ERR_CONSOLE_ON */
    38 /* #define DEBUG_ERR_CONSOLE_ON */
    25 
    39 
    26 
    40 
    27 #include "objacces.h"
    41 #include "objacces.h"
    28 
    42 
    29 
    43 
    30 
    44 /*!
    31 UNS8 accessDictionaryError(UNS16 index, UNS8 subIndex, 
    45 **
    32 			     UNS8 sizeDataDict, UNS8 sizeDataGiven, UNS32 code)
    46 **
       
    47 ** @param index
       
    48 ** @param subIndex
       
    49 ** @param sizeDataDict
       
    50 ** @param sizeDataGiven
       
    51 ** @param code
       
    52 **
       
    53 ** @return
       
    54 **/
       
    55 UNS8 accessDictionaryError(UNS16 index, UNS8 subIndex,
       
    56                            UNS8 sizeDataDict, UNS8 sizeDataGiven, UNS32 code)
    33 {
    57 {
    34 #ifdef DEBUG_WAR_CONSOLE_ON
    58 #ifdef DEBUG_WAR_CONSOLE_ON
    35   MSG_WAR(0x2B09,"Dictionary index : ", index);
    59   MSG_WAR(0x2B09,"Dictionary index : ", index);
    36   MSG_WAR(0X2B10,"           subindex : ", subIndex);
    60   MSG_WAR(0X2B10,"           subindex : ", subIndex);
    37   switch (code) {
    61   switch (code) {
    38     case  OD_NO_SUCH_OBJECT: 
    62   case  OD_NO_SUCH_OBJECT:
    39       MSG_WAR(0x2B11,"Index not found ", index);
    63     MSG_WAR(0x2B11,"Index not found ", index);
    40       break;
    64     break;
    41     case OD_NO_SUCH_SUBINDEX :
    65   case OD_NO_SUCH_SUBINDEX :
    42       MSG_WAR(0x2B12,"SubIndex not found ", subIndex);
    66     MSG_WAR(0x2B12,"SubIndex not found ", subIndex);
    43       break;   
    67     break;
    44     case OD_WRITE_NOT_ALLOWED :
    68   case OD_WRITE_NOT_ALLOWED :
    45       MSG_WAR(0x2B13,"Write not allowed, data is read only ", index);
    69     MSG_WAR(0x2B13,"Write not allowed, data is read only ", index);
    46       break;         
    70     break;
    47     case OD_LENGTH_DATA_INVALID :    
    71   case OD_LENGTH_DATA_INVALID :
    48       MSG_WAR(0x2B14,"Conflict size data. Should be (bytes)  : ", sizeDataDict);
    72     MSG_WAR(0x2B14,"Conflict size data. Should be (bytes)  : ", sizeDataDict);
    49       MSG_WAR(0x2B15,"But you have given the size  : ", sizeDataGiven);
    73     MSG_WAR(0x2B15,"But you have given the size  : ", sizeDataGiven);
    50       break;
    74     break;
    51     case OD_NOT_MAPPABLE :
    75   case OD_NOT_MAPPABLE :
    52       MSG_WAR(0x2B16,"Not mappable data in a PDO at index    : ", index);
    76     MSG_WAR(0x2B16,"Not mappable data in a PDO at index    : ", index);
    53       break;
    77     break;
    54     case OD_VALUE_TOO_LOW :
    78   case OD_VALUE_TOO_LOW :
    55       MSG_WAR(0x2B17,"Value range error : value too low. SDOabort : ", code);
    79     MSG_WAR(0x2B17,"Value range error : value too low. SDOabort : ", code);
    56       break;
    80     break;
    57     case OD_VALUE_TOO_HIGH :
    81   case OD_VALUE_TOO_HIGH :
    58       MSG_WAR(0x2B18,"Value range error : value too high. SDOabort : ", code);
    82     MSG_WAR(0x2B18,"Value range error : value too high. SDOabort : ", code);
    59       break;
    83     break;
    60   default :
    84   default :
    61     MSG_WAR(0x2B20, "Unknown error code : ", code);
    85     MSG_WAR(0x2B20, "Unknown error code : ", code);
    62   }
    86   }
    63 #endif
    87 #endif
    64   return 0; 
    88   return 0;
    65 }	
    89 }
    66 
    90 
    67 
    91 /*!
    68 UNS32 _getODentry( CO_Data* d, 
    92 **
    69                   UNS16 wIndex,
    93 **
    70 		  UNS8 bSubindex,
    94 ** @param d
    71 		  void * pDestData,
    95 ** @param wIndex
    72 		  UNS8 * pExpectedSize,
    96 ** @param bSubindex
    73 		  UNS8 * pDataType,
    97 ** @param pDestData
    74 		  UNS8 checkAccess,
    98 ** @param pExpectedSize
    75 		  UNS8 endianize)
    99 ** @param pDataType
    76 { /* DO NOT USE MSG_ERR because the macro may send a PDO -> infinite loop if it fails. */
   100 ** @param checkAccess
       
   101 ** @param endianize
       
   102 **
       
   103 ** @return
       
   104 **/
       
   105 UNS32 _getODentry( CO_Data* d,
       
   106                    UNS16 wIndex,
       
   107                    UNS8 bSubindex,
       
   108                    void * pDestData,
       
   109                    UNS8 * pExpectedSize,
       
   110                    UNS8 * pDataType,
       
   111                    UNS8 checkAccess,
       
   112                    UNS8 endianize)
       
   113 { /*! DO NOT USE MSG_ERR because the macro may send a PDO -> infinite
       
   114     loop if it fails. */
    77   UNS32 errorCode;
   115   UNS32 errorCode;
    78   UNS8 szData;
   116   UNS8 szData;
    79   const indextable *ptrTable;
   117   const indextable *ptrTable;
    80   ODCallback_t *Callback;
   118   ODCallback_t *Callback;
    81 
   119 
    86   if( ptrTable->bSubCount <= bSubindex ) {
   124   if( ptrTable->bSubCount <= bSubindex ) {
    87     /* Subindex not found */
   125     /* Subindex not found */
    88     accessDictionaryError(wIndex, bSubindex, 0, 0, OD_NO_SUCH_SUBINDEX);
   126     accessDictionaryError(wIndex, bSubindex, 0, 0, OD_NO_SUCH_SUBINDEX);
    89     return OD_NO_SUCH_SUBINDEX;
   127     return OD_NO_SUCH_SUBINDEX;
    90   }
   128   }
    91   
   129 
    92   if (checkAccess && !(ptrTable->pSubindex[bSubindex].bAccessType & WO)) {
   130   if (checkAccess && !(ptrTable->pSubindex[bSubindex].bAccessType & WO)) {
    93   	MSG_WAR(0x2B30, "Access Type : ", ptrTable->pSubindex[bSubindex].bAccessType);
   131     MSG_WAR(0x2B30, "Access Type : ", ptrTable->pSubindex[bSubindex].bAccessType);
    94     accessDictionaryError(wIndex, bSubindex, 0, 0, OD_WRITE_NOT_ALLOWED);
   132     accessDictionaryError(wIndex, bSubindex, 0, 0, OD_WRITE_NOT_ALLOWED);
    95     return OD_READ_NOT_ALLOWED;
   133     return OD_READ_NOT_ALLOWED;
    96   }
   134   }
    97 
   135 
    98   *pDataType = ptrTable->pSubindex[bSubindex].bDataType;
   136   *pDataType = ptrTable->pSubindex[bSubindex].bDataType;
    99    szData = ptrTable->pSubindex[bSubindex].size;
   137   szData = ptrTable->pSubindex[bSubindex].size;
   100 
   138 
   101    if(	*pExpectedSize == 0 ||
   139   if(*pExpectedSize == 0 ||
   102   	*pExpectedSize == szData ||
   140      *pExpectedSize == szData ||
   103   	(*pDataType == visible_string && *pExpectedSize < szData)) {/* We allow to fetch a shorter string than expected */
   141      (*pDataType == visible_string && *pExpectedSize < szData)) {
   104      
   142     /*! We
       
   143       allow to fetch a shorter string than expected */
       
   144 
   105 #  ifdef CANOPEN_BIG_ENDIAN
   145 #  ifdef CANOPEN_BIG_ENDIAN
   106      if(endianize && *pDataType > boolean && *pDataType < visible_string) {
   146     if(endianize && *pDataType > boolean && *pDataType < visible_string) {
   107        /* data must be transmited with low byte first */
   147       /*! data must be transmited with low byte first */
   108        UNS8 i, j = 0;
   148       UNS8 i, j = 0;
   109        MSG_WAR(boolean, "data type ", *pDataType);
   149       MSG_WAR(boolean, "data type ", *pDataType);
   110        MSG_WAR(visible_string, "data type ", *pDataType);
   150       MSG_WAR(visible_string, "data type ", *pDataType);
   111        for ( i = szData ; i > 0 ; i--) {
   151       for ( i = szData ; i > 0 ; i--) {
   112          MSG_WAR(i," ", j);
   152         MSG_WAR(i," ", j);
   113 	 ((UNS8*)pDestData)[j++] = 
   153         ((UNS8*)pDestData)[j++] =
   114 	   ((UNS8*)ptrTable->pSubindex[bSubindex].pObject)[i-1];
   154           ((UNS8*)ptrTable->pSubindex[bSubindex].pObject)[i-1];
   115        }
   155       }
   116      }
   156     }
   117      else /* It it is a visible string no endianisation to perform */
   157     else /*! It it is a visible string no endianisation to perform */
   118        memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData);
   158       memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData);
   119 #  else
   159 #  else
   120      memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData);
   160     memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData);
   121 #  endif
   161 #  endif
   122      
   162 
   123      *pExpectedSize = szData;
   163     *pExpectedSize = szData;
   124 #if 0
   164 #if 0
   125      /* Me laisser ça, please ! (FD) */
   165     /*! Me laisser a, please ! (FD) */
   126      {
   166     {
   127        UNS8 i;
   167       UNS8 i;
   128        for (i = 0 ; i < 10 ; i++) {
   168       for (i = 0 ; i < 10 ; i++) {
   129 	 MSG_WAR(*pExpectedSize, "dic data= ",
   169         MSG_WAR(*pExpectedSize, "dic data= ",
   130 		 *(UNS8 *)(ptrTable->pSubindex[bSubindex].pObject + i));
   170                 *(UNS8 *)(ptrTable->pSubindex[bSubindex].pObject + i));
   131        }
   171       }
   132       
   172 
   133      }
   173     }
   134 #endif
   174 #endif
   135      return OD_SUCCESSFUL;
   175     return OD_SUCCESSFUL;
   136    }
   176   }
   137    else { /* Error ! */
   177   else { /*! Error ! */
   138      *pExpectedSize = szData;
   178     *pExpectedSize = szData;
   139      accessDictionaryError(wIndex, bSubindex, szData, 
   179     accessDictionaryError(wIndex, bSubindex, szData,
   140 			   *pExpectedSize, OD_LENGTH_DATA_INVALID);
   180                           *pExpectedSize, OD_LENGTH_DATA_INVALID);
   141      return OD_LENGTH_DATA_INVALID;
   181     return OD_LENGTH_DATA_INVALID;
   142    }
   182   }
   143 }
   183 }
   144 
   184 
   145 UNS32 getODentry( CO_Data* d, 
   185 /*!
       
   186 **
       
   187 **
       
   188 ** @param d
       
   189 ** @param wIndex
       
   190 ** @param bSubindex
       
   191 ** @param pDestData
       
   192 ** @param pExpectedSize
       
   193 ** @param pDataType
       
   194 ** @param checkAccess
       
   195 **
       
   196 ** @return
       
   197 **/
       
   198 UNS32 getODentry( CO_Data* d,
   146                   UNS16 wIndex,
   199                   UNS16 wIndex,
   147 		  UNS8 bSubindex,
   200                   UNS8 bSubindex,
   148 		  void * pDestData,
   201                   void * pDestData,
   149 		  UNS8 * pExpectedSize,
   202                   UNS8 * pExpectedSize,
   150 		  UNS8 * pDataType,
   203                   UNS8 * pDataType,
   151 		  UNS8 checkAccess)
   204                   UNS8 checkAccess)
   152 {
   205 {
   153 	return _getODentry( d, 
   206   return _getODentry( d,
   154                   wIndex,
   207                       wIndex,
   155 		  bSubindex,
   208                       bSubindex,
   156 		  pDestData,
   209                       pDestData,
   157 		  pExpectedSize,
   210                       pExpectedSize,
   158 		  pDataType,
   211                       pDataType,
   159 		  checkAccess,
   212                       checkAccess,
   160 		  1);//endianize
   213                       1);//endianize
   161 }
   214 }
   162 
   215 
   163 UNS32 readLocalDict( CO_Data* d, 
   216 /*!
   164                   UNS16 wIndex,
   217 **
   165 		  UNS8 bSubindex,
   218 **
   166 		  void * pDestData,
   219 ** @param d
   167 		  UNS8 * pExpectedSize,
   220 ** @param wIndex
   168 		  UNS8 * pDataType,
   221 ** @param bSubindex
   169 		  UNS8 checkAccess)
   222 ** @param pDestData
   170 {
   223 ** @param pExpectedSize
   171 		return _getODentry( d, 
   224 ** @param pDataType
   172                   wIndex,
   225 ** @param checkAccess
   173 		  bSubindex,
   226 **
   174 		  pDestData,
   227 ** @return
   175 		  pExpectedSize,
   228 **/
   176 		  pDataType,
   229 UNS32 readLocalDict( CO_Data* d,
   177 		  checkAccess,
   230                      UNS16 wIndex,
   178 		  0);//do not endianize
   231                      UNS8 bSubindex,
   179 }
   232                      void * pDestData,
   180 
   233                      UNS8 * pExpectedSize,
   181 UNS32 _setODentry( CO_Data* d, 
   234                      UNS8 * pDataType,
   182                   UNS16 wIndex,
   235                      UNS8 checkAccess)
   183 		  UNS8 bSubindex, 
   236 {
   184 		  void * pSourceData, 
   237   return _getODentry( d,
   185 		  UNS8 * pExpectedSize, 
   238                       wIndex,
   186 		  UNS8 checkAccess,
   239                       bSubindex,
   187 		  UNS8 endianize)
   240                       pDestData,
       
   241                       pExpectedSize,
       
   242                       pDataType,
       
   243                       checkAccess,
       
   244                       0);//do not endianize
       
   245 }
       
   246 
       
   247 /*!
       
   248 **
       
   249 **
       
   250 ** @param d
       
   251 ** @param wIndex
       
   252 ** @param bSubindex
       
   253 ** @param pSourceData
       
   254 ** @param pExpectedSize
       
   255 ** @param checkAccess
       
   256 ** @param endianize
       
   257 **
       
   258 ** @return
       
   259 **/
       
   260 UNS32 _setODentry( CO_Data* d,
       
   261                    UNS16 wIndex,
       
   262                    UNS8 bSubindex,
       
   263                    void * pSourceData,
       
   264                    UNS8 * pExpectedSize,
       
   265                    UNS8 checkAccess,
       
   266                    UNS8 endianize)
   188 {
   267 {
   189   UNS8 szData;
   268   UNS8 szData;
   190   UNS8 dataType;
   269   UNS8 dataType;
   191   UNS32 errorCode;
   270   UNS32 errorCode;
   192   const indextable *ptrTable;
   271   const indextable *ptrTable;
   195   ptrTable =(*d->scanIndexOD)(wIndex, &errorCode, &Callback);
   274   ptrTable =(*d->scanIndexOD)(wIndex, &errorCode, &Callback);
   196   if (errorCode != OD_SUCCESSFUL)
   275   if (errorCode != OD_SUCCESSFUL)
   197     return errorCode;
   276     return errorCode;
   198 
   277 
   199   if( ptrTable->bSubCount <= bSubindex ) {
   278   if( ptrTable->bSubCount <= bSubindex ) {
   200     /* Subindex not found */
   279     /*! Subindex not found */
   201     accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_NO_SUCH_SUBINDEX);
   280     accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_NO_SUCH_SUBINDEX);
   202     return OD_NO_SUCH_SUBINDEX;
   281     return OD_NO_SUCH_SUBINDEX;
   203   }
   282   }
   204   if (checkAccess && (ptrTable->pSubindex[bSubindex].bAccessType == RO)) {
   283   if (checkAccess && (ptrTable->pSubindex[bSubindex].bAccessType == RO)) {
   205   	MSG_WAR(0x2B25, "Access Type : ", ptrTable->pSubindex[bSubindex].bAccessType);
   284     MSG_WAR(0x2B25, "Access Type : ", ptrTable->pSubindex[bSubindex].bAccessType);
   206     accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_WRITE_NOT_ALLOWED);
   285     accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_WRITE_NOT_ALLOWED);
   207     return OD_WRITE_NOT_ALLOWED;
   286     return OD_WRITE_NOT_ALLOWED;
   208   }
   287   }
   209 
   288 
   210 
   289 
   211    dataType = ptrTable->pSubindex[bSubindex].bDataType;
   290   dataType = ptrTable->pSubindex[bSubindex].bDataType;
   212    szData = ptrTable->pSubindex[bSubindex].size;
   291   szData = ptrTable->pSubindex[bSubindex].size;
   213 
   292 
   214   if( *pExpectedSize == 0 ||
   293   if( *pExpectedSize == 0 ||
   215   	*pExpectedSize == szData ||
   294       *pExpectedSize == szData ||
   216   	(dataType == visible_string && *pExpectedSize < szData)) /* We allow to store a shorter string than entry size */
   295       (dataType == visible_string && *pExpectedSize < szData)) /* We
   217   {
   296                                                                   allow to store a shorter string than entry size */
   218       #ifdef CANOPEN_BIG_ENDIAN
   297     {
   219 	      if(endianize && dataType > boolean && dataType < visible_string)
   298 #ifdef CANOPEN_BIG_ENDIAN
   220 	      {
   299       if(endianize && dataType > boolean && dataType < visible_string)
   221 			/* we invert the data source directly. This let us do range testing without */
   300         {
   222 			/* additional temp variable */
   301           /*! we invert the data source directly. This let us do range
   223 		 	UNS8 i;
   302             testing without */
   224 	  		for ( i = 0 ; i < ( ptrTable->pSubindex[bSubindex].size >> 1)  ; i++) 
   303           /*! additional temp variable */
   225 	  		{
   304           UNS8 i;
   226 	    		UNS8 tmp =((UNS8 *)pSourceData) [(ptrTable->pSubindex[bSubindex].size - 1) - i];
   305           for ( i = 0 ; i < ( ptrTable->pSubindex[bSubindex].size >> 1)  ; i++)
   227 	    		((UNS8 *)pSourceData) [(ptrTable->pSubindex[bSubindex].size - 1) - i] = ((UNS8 *)pSourceData)[i];
   306             {
   228 	    		((UNS8 *)pSourceData)[i] = tmp;
   307               UNS8 tmp =((UNS8 *)pSourceData) [(ptrTable->pSubindex[bSubindex].size - 1) - i];
   229 	    	}
   308               ((UNS8 *)pSourceData) [(ptrTable->pSubindex[bSubindex].size - 1) - i] = ((UNS8 *)pSourceData)[i];
   230 		}  
   309               ((UNS8 *)pSourceData)[i] = tmp;
   231       #endif
   310             }
       
   311         }
       
   312 #endif
   232       errorCode = (*d->valueRangeTest)(dataType, pSourceData);
   313       errorCode = (*d->valueRangeTest)(dataType, pSourceData);
   233       if (errorCode) {
   314       if (errorCode) {
   234 	accessDictionaryError(wIndex, bSubindex, szData, *pExpectedSize, errorCode);
   315         accessDictionaryError(wIndex, bSubindex, szData, *pExpectedSize, errorCode);
   235 	return errorCode;
   316         return errorCode;
   236       }
   317       }
   237       memcpy(ptrTable->pSubindex[bSubindex].pObject,pSourceData, *pExpectedSize);
   318       memcpy(ptrTable->pSubindex[bSubindex].pObject,pSourceData, *pExpectedSize);
   238       *pExpectedSize = szData;
   319       *pExpectedSize = szData;
   239       
   320 
   240       /* Callbacks */
   321       /*! Callbacks */
   241       if(Callback && Callback[bSubindex]){
   322       if(Callback && Callback[bSubindex]){
   242       	 (*Callback[bSubindex])(d, ptrTable, bSubindex);
   323         (*Callback[bSubindex])(d, ptrTable, bSubindex);
   243       }
   324       }
   244       
   325 
   245       /* TODO : Store dans NVRAM */     
   326       /*! TODO : Store dans NVRAM */
   246       if (ptrTable->pSubindex[bSubindex].bAccessType & TO_BE_SAVE){
   327       if (ptrTable->pSubindex[bSubindex].bAccessType & TO_BE_SAVE){
   247       	(*d->storeODSubIndex)(wIndex, bSubindex);
   328         (*d->storeODSubIndex)(wIndex, bSubindex);
   248       }
   329       }
   249       return OD_SUCCESSFUL;
   330       return OD_SUCCESSFUL;
   250   }else{
   331     }else{
   251       *pExpectedSize = szData;
   332       *pExpectedSize = szData;
   252       accessDictionaryError(wIndex, bSubindex, szData, *pExpectedSize, OD_LENGTH_DATA_INVALID);
   333       accessDictionaryError(wIndex, bSubindex, szData, *pExpectedSize, OD_LENGTH_DATA_INVALID);
   253       return OD_LENGTH_DATA_INVALID;
   334       return OD_LENGTH_DATA_INVALID;
   254   }
   335     }
   255 }
   336 }
   256 
   337 
   257 UNS32 setODentry( CO_Data* d, 
   338 /*!
       
   339 **
       
   340 **
       
   341 ** @param d
       
   342 ** @param wIndex
       
   343 ** @param bSubindex
       
   344 ** @param pSourceData
       
   345 ** @param pExpectedSize
       
   346 ** @param checkAccess
       
   347 **
       
   348 ** @return
       
   349 **/
       
   350 UNS32 setODentry( CO_Data* d,
   258                   UNS16 wIndex,
   351                   UNS16 wIndex,
   259 		  UNS8 bSubindex, 
   352                   UNS8 bSubindex,
   260 		  void * pSourceData, 
   353                   void * pSourceData,
   261 		  UNS8 * pExpectedSize, 
   354                   UNS8 * pExpectedSize,
   262 		  UNS8 checkAccess)
   355                   UNS8 checkAccess)
   263 {
   356 {
   264 	return _setODentry( d, 
   357   return _setODentry( d,
   265                   wIndex,
   358                       wIndex,
   266 		  bSubindex, 
   359                       bSubindex,
   267 		  pSourceData, 
   360                       pSourceData,
   268 		  pExpectedSize, 
   361                       pExpectedSize,
   269 		  checkAccess,
   362                       checkAccess,
   270 		  1);//endianize
   363                       1);//endianize
   271 }
   364 }
   272 
   365 
   273 UNS32 writeLocalDict( CO_Data* d, 
   366 /*!
   274                   UNS16 wIndex,
   367 **
   275 		  UNS8 bSubindex, 
   368 **
   276 		  void * pSourceData, 
   369 ** @param d
   277 		  UNS8 * pExpectedSize, 
   370 ** @param wIndex
   278 		  UNS8 checkAccess)
   371 ** @param bSubindex
   279 {
   372 ** @param pSourceData
   280 	return _setODentry( d, 
   373 ** @param pExpectedSize
   281                   wIndex,
   374 ** @param checkAccess
   282 		  bSubindex, 
   375 **
   283 		  pSourceData, 
   376 ** @return
   284 		  pExpectedSize, 
   377 **/
   285 		  checkAccess,
   378 UNS32 writeLocalDict( CO_Data* d,
   286 		  0);//do not endianize
   379                       UNS16 wIndex,
   287 }
   380                       UNS8 bSubindex,
   288 
   381                       void * pSourceData,
   289 
   382                       UNS8 * pExpectedSize,
   290 
   383                       UNS8 checkAccess)
   291 
   384 {
       
   385   return _setODentry( d,
       
   386                       wIndex,
       
   387                       bSubindex,
       
   388                       pSourceData,
       
   389                       pExpectedSize,
       
   390                       checkAccess,
       
   391                       0);//do not endianize
       
   392 }
       
   393 
       
   394 /*!
       
   395 **
       
   396 **
       
   397 ** @param d
       
   398 ** @param wIndex
       
   399 ** @param errorCode
       
   400 ** @param Callback
       
   401 **
       
   402 ** @return
       
   403 **/
   292 const indextable * scanIndexOD (CO_Data* d, UNS16 wIndex, UNS32 *errorCode, ODCallback_t **Callback)
   404 const indextable * scanIndexOD (CO_Data* d, UNS16 wIndex, UNS32 *errorCode, ODCallback_t **Callback)
   293 {
   405 {
   294   return (*d->scanIndexOD)(wIndex, errorCode, Callback);
   406   return (*d->scanIndexOD)(wIndex, errorCode, Callback);
   295 }
   407 }
   296 
   408 
       
   409 /*!
       
   410 **
       
   411 **
       
   412 ** @param d
       
   413 ** @param wIndex
       
   414 ** @param bSubindex
       
   415 ** @param Callback
       
   416 **
       
   417 ** @return
       
   418 **/
   297 UNS32 RegisterSetODentryCallBack(CO_Data* d, UNS16 wIndex, UNS8 bSubindex, ODCallback_t Callback)
   419 UNS32 RegisterSetODentryCallBack(CO_Data* d, UNS16 wIndex, UNS8 bSubindex, ODCallback_t Callback)
   298 {
   420 {
   299 	UNS32 errorCode;
   421   UNS32 errorCode;
   300 	ODCallback_t *CallbackList;
   422   ODCallback_t *CallbackList;
   301 
   423 
   302 	scanIndexOD (d, wIndex, &errorCode, &CallbackList);
   424   scanIndexOD (d, wIndex, &errorCode, &CallbackList);
   303 	if(errorCode == OD_SUCCESSFUL && CallbackList) 
   425   if(errorCode == OD_SUCCESSFUL && CallbackList)
   304 		CallbackList[bSubindex] = Callback;
   426     CallbackList[bSubindex] = Callback;
   305 	return errorCode;
   427   return errorCode;
   306 }
   428 }
   307 
   429 
       
   430 /*!
       
   431 **
       
   432 **
       
   433 ** @param wIndex
       
   434 ** @param bSubindex
       
   435 **/
   308 void _storeODSubIndex (UNS16 wIndex, UNS8 bSubindex){}
   436 void _storeODSubIndex (UNS16 wIndex, UNS8 bSubindex){}