diff -r 2cb34a4ac65a -r 6b5a4c21e061 doc/doxygen/html/objacces_8c-source.html --- a/doc/doxygen/html/objacces_8c-source.html Tue Jun 05 17:34:33 2007 +0200 +++ b/doc/doxygen/html/objacces_8c-source.html Tue Jun 05 18:43:21 2007 +0200 @@ -16,314 +16,304 @@
  • Globals
  • /home/epimerde/documents/tc11/CanFestival-3/src/objacces.c

    Go to the documentation of this file.
    00001 /*
    -00002 This file is part of CanFestival, a library implementing CanOpen Stack. 
    -00003 
    -00004 Copyright (C): Edouard TISSERANT and Francis DUPIN
    -00005 
    -00006 See COPYING file for copyrights details.
    -00007 
    -00008 This library is free software; you can redistribute it and/or
    -00009 modify it under the terms of the GNU Lesser General Public
    -00010 License as published by the Free Software Foundation; either
    -00011 version 2.1 of the License, or (at your option) any later version.
    -00012 
    -00013 This library is distributed in the hope that it will be useful,
    -00014 but WITHOUT ANY WARRANTY; without even the implied warranty of
    -00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    -00016 Lesser General Public License for more details.
    -00017 
    -00018 You should have received a copy of the GNU Lesser General Public
    -00019 License along with this library; if not, write to the Free Software
    -00020 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    -00021 */
    -00022 
    -00023 /* #define DEBUG_WAR_CONSOLE_ON */
    -00024 /* #define DEBUG_ERR_CONSOLE_ON */
    -00025 
    -00026 
    -00027 #include "objacces.h"
    -00028 
    -00029 
    -00030 
    -00031 UNS8 accessDictionaryError(UNS16 index, UNS8 subIndex, 
    -00032                              UNS8 sizeDataDict, UNS8 sizeDataGiven, UNS32 code)
    -00033 {
    -00034 #ifdef DEBUG_WAR_CONSOLE_ON
    -00035   MSG_WAR(0x2B09,"Dictionary index : ", index);
    -00036   MSG_WAR(0X2B10,"           subindex : ", subIndex);
    -00037   switch (code) {
    -00038     case  OD_NO_SUCH_OBJECT: 
    -00039       MSG_WAR(0x2B11,"Index not found ", index);
    -00040       break;
    -00041     case OD_NO_SUCH_SUBINDEX :
    -00042       MSG_WAR(0x2B12,"SubIndex not found ", subIndex);
    -00043       break;   
    -00044     case OD_WRITE_NOT_ALLOWED :
    -00045       MSG_WAR(0x2B13,"Write not allowed, data is read only ", index);
    -00046       break;         
    -00047     case OD_LENGTH_DATA_INVALID :    
    -00048       MSG_WAR(0x2B14,"Conflict size data. Should be (bytes)  : ", sizeDataDict);
    -00049       MSG_WAR(0x2B15,"But you have given the size  : ", sizeDataGiven);
    -00050       break;
    -00051     case OD_NOT_MAPPABLE :
    -00052       MSG_WAR(0x2B16,"Not mappable data in a PDO at index    : ", index);
    -00053       break;
    -00054     case OD_VALUE_TOO_LOW :
    -00055       MSG_WAR(0x2B17,"Value range error : value too low. SDOabort : ", code);
    -00056       break;
    -00057     case OD_VALUE_TOO_HIGH :
    -00058       MSG_WAR(0x2B18,"Value range error : value too high. SDOabort : ", code);
    -00059       break;
    -00060   default :
    -00061     MSG_WAR(0x2B20, "Unknown error code : ", code);
    -00062   }
    -00063 #endif
    -00064   return 0; 
    -00065 }       
    -00066 
    -00067 
    -00068 UNS32 _getODentry( CO_Data* d, 
    -00069                   UNS16 wIndex,
    -00070                   UNS8 bSubindex,
    -00071                   void * pDestData,
    -00072                   UNS8 * pExpectedSize,
    -00073                   UNS8 * pDataType,
    -00074                   UNS8 checkAccess,
    -00075                   UNS8 endianize)
    -00076 { /* DO NOT USE MSG_ERR because the macro may send a PDO -> infinite loop if it fails. */
    -00077   UNS32 errorCode;
    -00078   UNS8 szData;
    -00079   const indextable *ptrTable;
    -00080   ODCallback_t *Callback;
    -00081 
    -00082   ptrTable = (*d->scanIndexOD)(wIndex, &errorCode, &Callback);
    -00083 
    -00084   if (errorCode != OD_SUCCESSFUL)
    -00085     return errorCode;
    -00086   if( ptrTable->bSubCount <= bSubindex ) {
    -00087     /* Subindex not found */
    -00088     accessDictionaryError(wIndex, bSubindex, 0, 0, OD_NO_SUCH_SUBINDEX);
    -00089     return OD_NO_SUCH_SUBINDEX;
    -00090   }
    -00091   
    -00092   if (checkAccess && !(ptrTable->pSubindex[bSubindex].bAccessType & WO)) {
    -00093         MSG_WAR(0x2B30, "Access Type : ", ptrTable->pSubindex[bSubindex].bAccessType);
    -00094     accessDictionaryError(wIndex, bSubindex, 0, 0, OD_WRITE_NOT_ALLOWED);
    -00095     return OD_READ_NOT_ALLOWED;
    -00096   }
    -00097 
    -00098   *pDataType = ptrTable->pSubindex[bSubindex].bDataType;
    -00099    szData = ptrTable->pSubindex[bSubindex].size;
    -00100 
    -00101    if(  *pExpectedSize == 0 ||
    -00102         *pExpectedSize == szData ||
    -00103         (*pDataType == visible_string && *pExpectedSize < szData)) {/* We allow to fetch a shorter string than expected */
    -00104      
    -00105 #  ifdef CANOPEN_BIG_ENDIAN
    -00106      if(endianize && *pDataType > boolean && *pDataType < visible_string) {
    -00107        /* data must be transmited with low byte first */
    -00108        UNS8 i, j = 0;
    -00109        MSG_WAR(boolean, "data type ", *pDataType);
    -00110        MSG_WAR(visible_string, "data type ", *pDataType);
    -00111        for ( i = szData ; i > 0 ; i--) {
    -00112          MSG_WAR(i," ", j);
    -00113          ((UNS8*)pDestData)[j++] = 
    -00114            ((UNS8*)ptrTable->pSubindex[bSubindex].pObject)[i-1];
    -00115        }
    -00116      }
    -00117      else /* It it is a visible string no endianisation to perform */
    -00118        memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData);
    -00119 #  else
    -00120      memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData);
    -00121 #  endif
    -00122      
    -00123      *pExpectedSize = szData;
    -00124 #if 0
    -00125      /* Me laisser ça, please ! (FD) */
    -00126      {
    -00127        UNS8 i;
    -00128        for (i = 0 ; i < 10 ; i++) {
    -00129          MSG_WAR(*pExpectedSize, "dic data= ",
    -00130                  *(UNS8 *)(ptrTable->pSubindex[bSubindex].pObject + i));
    -00131        }
    -00132       
    -00133      }
    -00134 #endif
    -00135      return OD_SUCCESSFUL;
    -00136    }
    -00137    else { /* Error ! */
    -00138      *pExpectedSize = szData;
    -00139      accessDictionaryError(wIndex, bSubindex, szData, 
    -00140                            *pExpectedSize, OD_LENGTH_DATA_INVALID);
    -00141      return OD_LENGTH_DATA_INVALID;
    -00142    }
    -00143 }
    -00144 
    -00145 UNS32 getODentry( CO_Data* d, 
    -00146                   UNS16 wIndex,
    -00147                   UNS8 bSubindex,
    -00148                   void * pDestData,
    -00149                   UNS8 * pExpectedSize,
    -00150                   UNS8 * pDataType,
    -00151                   UNS8 checkAccess)
    -00152 {
    -00153         return _getODentry( d, 
    -00154                   wIndex,
    -00155                   bSubindex,
    -00156                   pDestData,
    -00157                   pExpectedSize,
    -00158                   pDataType,
    -00159                   checkAccess,
    -00160                   1);//endianize
    -00161 }
    -00162 
    -00163 UNS32 readLocalDict( CO_Data* d, 
    -00164                   UNS16 wIndex,
    -00165                   UNS8 bSubindex,
    -00166                   void * pDestData,
    -00167                   UNS8 * pExpectedSize,
    -00168                   UNS8 * pDataType,
    -00169                   UNS8 checkAccess)
    -00170 {
    -00171                 return _getODentry( d, 
    -00172                   wIndex,
    -00173                   bSubindex,
    -00174                   pDestData,
    -00175                   pExpectedSize,
    -00176                   pDataType,
    -00177                   checkAccess,
    -00178                   0);//do not endianize
    -00179 }
    -00180 
    -00181 UNS32 _setODentry( CO_Data* d, 
    -00182                   UNS16 wIndex,
    -00183                   UNS8 bSubindex, 
    -00184                   void * pSourceData, 
    -00185                   UNS8 * pExpectedSize, 
    -00186                   UNS8 checkAccess,
    -00187                   UNS8 endianize)
    -00188 {
    -00189   UNS8 szData;
    -00190   UNS8 dataType;
    -00191   UNS32 errorCode;
    -00192   const indextable *ptrTable;
    -00193   ODCallback_t *Callback;
    -00194 
    -00195   ptrTable =(*d->scanIndexOD)(wIndex, &errorCode, &Callback);
    -00196   if (errorCode != OD_SUCCESSFUL)
    -00197     return errorCode;
    -00198 
    -00199   if( ptrTable->bSubCount <= bSubindex ) {
    -00200     /* Subindex not found */
    -00201     accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_NO_SUCH_SUBINDEX);
    -00202     return OD_NO_SUCH_SUBINDEX;
    -00203   }
    -00204   if (checkAccess && (ptrTable->pSubindex[bSubindex].bAccessType == RO)) {
    -00205         MSG_WAR(0x2B25, "Access Type : ", ptrTable->pSubindex[bSubindex].bAccessType);
    -00206     accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_WRITE_NOT_ALLOWED);
    -00207     return OD_WRITE_NOT_ALLOWED;
    -00208   }
    -00209 
    -00210 
    -00211    dataType = ptrTable->pSubindex[bSubindex].bDataType;
    -00212    szData = ptrTable->pSubindex[bSubindex].size;
    -00213 
    -00214   if( *pExpectedSize == 0 ||
    -00215         *pExpectedSize == szData ||
    -00216         (dataType == visible_string && *pExpectedSize < szData)) /* We allow to store a shorter string than entry size */
    -00217   {
    -00218       #ifdef CANOPEN_BIG_ENDIAN
    -00219               if(endianize && dataType > boolean && dataType < visible_string)
    -00220               {
    -00221                         /* we invert the data source directly. This let us do range testing without */
    -00222                         /* additional temp variable */
    -00223                         UNS8 i;
    -00224                         for ( i = 0 ; i < ( ptrTable->pSubindex[bSubindex].size >> 1)  ; i++) 
    -00225                         {
    -00226                         UNS8 tmp =((UNS8 *)pSourceData) [(ptrTable->pSubindex[bSubindex].size - 1) - i];
    -00227                         ((UNS8 *)pSourceData) [(ptrTable->pSubindex[bSubindex].size - 1) - i] = ((UNS8 *)pSourceData)[i];
    -00228                         ((UNS8 *)pSourceData)[i] = tmp;
    -00229                 }
    -00230                 }  
    -00231       #endif
    -00232       errorCode = (*d->valueRangeTest)(dataType, pSourceData);
    -00233       if (errorCode) {
    -00234         accessDictionaryError(wIndex, bSubindex, szData, *pExpectedSize, errorCode);
    -00235         return errorCode;
    -00236       }
    -00237       memcpy(ptrTable->pSubindex[bSubindex].pObject,pSourceData, *pExpectedSize);
    -00238       *pExpectedSize = szData;
    -00239       
    -00240       /* Callbacks */
    -00241       if(Callback && Callback[bSubindex]){
    -00242          (*Callback[bSubindex])(d, ptrTable, bSubindex);
    -00243       }
    -00244       
    -00245       /* TODO : Store dans NVRAM */     
    -00246       if (ptrTable->pSubindex[bSubindex].bAccessType & TO_BE_SAVE){
    -00247         (*d->storeODSubIndex)(wIndex, bSubindex);
    -00248       }
    -00249       return OD_SUCCESSFUL;
    -00250   }else{
    -00251       *pExpectedSize = szData;
    -00252       accessDictionaryError(wIndex, bSubindex, szData, *pExpectedSize, OD_LENGTH_DATA_INVALID);
    -00253       return OD_LENGTH_DATA_INVALID;
    -00254   }
    -00255 }
    -00256 
    -00257 UNS32 setODentry( CO_Data* d, 
    -00258                   UNS16 wIndex,
    -00259                   UNS8 bSubindex, 
    -00260                   void * pSourceData, 
    -00261                   UNS8 * pExpectedSize, 
    -00262                   UNS8 checkAccess)
    -00263 {
    -00264         return _setODentry( d, 
    -00265                   wIndex,
    -00266                   bSubindex, 
    -00267                   pSourceData, 
    -00268                   pExpectedSize, 
    -00269                   checkAccess,
    -00270                   1);//endianize
    -00271 }
    -00272 
    -00273 UNS32 writeLocalDict( CO_Data* d, 
    -00274                   UNS16 wIndex,
    -00275                   UNS8 bSubindex, 
    -00276                   void * pSourceData, 
    -00277                   UNS8 * pExpectedSize, 
    -00278                   UNS8 checkAccess)
    -00279 {
    -00280         return _setODentry( d, 
    -00281                   wIndex,
    -00282                   bSubindex, 
    -00283                   pSourceData, 
    -00284                   pExpectedSize, 
    -00285                   checkAccess,
    -00286                   0);//do not endianize
    -00287 }
    +00002   This file is part of CanFestival, a library implementing CanOpen
    +00003   Stack.
    +00004 
    +00005   Copyright (C): Edouard TISSERANT and Francis DUPIN
    +00006 
    +00007   See COPYING file for copyrights details.
    +00008 
    +00009   This library is free software; you can redistribute it and/or
    +00010   modify it under the terms of the GNU Lesser General Public
    +00011   License as published by the Free Software Foundation; either
    +00012   version 2.1 of the License, or (at your option) any later version.
    +00013 
    +00014   This library is distributed in the hope that it will be useful,
    +00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
    +00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    +00017   Lesser General Public License for more details.
    +00018 
    +00019   You should have received a copy of the GNU Lesser General Public
    +00020   License along with this library; if not, write to the Free Software
    +00021   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
    +00022   USA
    +00023 */
    +00037 /* #define DEBUG_WAR_CONSOLE_ON */
    +00038 /* #define DEBUG_ERR_CONSOLE_ON */
    +00039 
    +00040 
    +00041 #include "objacces.h"
    +00042 
    +00043 
    +00055 UNS8 accessDictionaryError(UNS16 index, UNS8 subIndex,
    +00056                            UNS8 sizeDataDict, UNS8 sizeDataGiven, UNS32 code)
    +00057 {
    +00058 #ifdef DEBUG_WAR_CONSOLE_ON
    +00059   MSG_WAR(0x2B09,"Dictionary index : ", index);
    +00060   MSG_WAR(0X2B10,"           subindex : ", subIndex);
    +00061   switch (code) {
    +00062   case  OD_NO_SUCH_OBJECT:
    +00063     MSG_WAR(0x2B11,"Index not found ", index);
    +00064     break;
    +00065   case OD_NO_SUCH_SUBINDEX :
    +00066     MSG_WAR(0x2B12,"SubIndex not found ", subIndex);
    +00067     break;
    +00068   case OD_WRITE_NOT_ALLOWED :
    +00069     MSG_WAR(0x2B13,"Write not allowed, data is read only ", index);
    +00070     break;
    +00071   case OD_LENGTH_DATA_INVALID :
    +00072     MSG_WAR(0x2B14,"Conflict size data. Should be (bytes)  : ", sizeDataDict);
    +00073     MSG_WAR(0x2B15,"But you have given the size  : ", sizeDataGiven);
    +00074     break;
    +00075   case OD_NOT_MAPPABLE :
    +00076     MSG_WAR(0x2B16,"Not mappable data in a PDO at index    : ", index);
    +00077     break;
    +00078   case OD_VALUE_TOO_LOW :
    +00079     MSG_WAR(0x2B17,"Value range error : value too low. SDOabort : ", code);
    +00080     break;
    +00081   case OD_VALUE_TOO_HIGH :
    +00082     MSG_WAR(0x2B18,"Value range error : value too high. SDOabort : ", code);
    +00083     break;
    +00084   default :
    +00085     MSG_WAR(0x2B20, "Unknown error code : ", code);
    +00086   }
    +00087 #endif
    +00088   return 0;
    +00089 }
    +00090 
    +00105 UNS32 _getODentry( CO_Data* d,
    +00106                    UNS16 wIndex,
    +00107                    UNS8 bSubindex,
    +00108                    void * pDestData,
    +00109                    UNS8 * pExpectedSize,
    +00110                    UNS8 * pDataType,
    +00111                    UNS8 checkAccess,
    +00112                    UNS8 endianize)
    +00113 { 
    +00115   UNS32 errorCode;
    +00116   UNS8 szData;
    +00117   const indextable *ptrTable;
    +00118   ODCallback_t *Callback;
    +00119 
    +00120   ptrTable = (*d->scanIndexOD)(wIndex, &errorCode, &Callback);
    +00121 
    +00122   if (errorCode != OD_SUCCESSFUL)
    +00123     return errorCode;
    +00124   if( ptrTable->bSubCount <= bSubindex ) {
    +00125     /* Subindex not found */
    +00126     accessDictionaryError(wIndex, bSubindex, 0, 0, OD_NO_SUCH_SUBINDEX);
    +00127     return OD_NO_SUCH_SUBINDEX;
    +00128   }
    +00129 
    +00130   if (checkAccess && !(ptrTable->pSubindex[bSubindex].bAccessType & WO)) {
    +00131     MSG_WAR(0x2B30, "Access Type : ", ptrTable->pSubindex[bSubindex].bAccessType);
    +00132     accessDictionaryError(wIndex, bSubindex, 0, 0, OD_WRITE_NOT_ALLOWED);
    +00133     return OD_READ_NOT_ALLOWED;
    +00134   }
    +00135 
    +00136   *pDataType = ptrTable->pSubindex[bSubindex].bDataType;
    +00137   szData = ptrTable->pSubindex[bSubindex].size;
    +00138 
    +00139   if(*pExpectedSize == 0 ||
    +00140      *pExpectedSize == szData ||
    +00141      (*pDataType == visible_string && *pExpectedSize < szData)) {
    +00145 #  ifdef CANOPEN_BIG_ENDIAN
    +00146     if(endianize && *pDataType > boolean && *pDataType < visible_string) {
    +00148       UNS8 i, j = 0;
    +00149       MSG_WAR(boolean, "data type ", *pDataType);
    +00150       MSG_WAR(visible_string, "data type ", *pDataType);
    +00151       for ( i = szData ; i > 0 ; i--) {
    +00152         MSG_WAR(i," ", j);
    +00153         ((UNS8*)pDestData)[j++] =
    +00154           ((UNS8*)ptrTable->pSubindex[bSubindex].pObject)[i-1];
    +00155       }
    +00156     }
    +00157     else 
    +00158       memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData);
    +00159 #  else
    +00160     memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData);
    +00161 #  endif
    +00162 
    +00163     *pExpectedSize = szData;
    +00164 #if 0
    +00165 
    +00166     {
    +00167       UNS8 i;
    +00168       for (i = 0 ; i < 10 ; i++) {
    +00169         MSG_WAR(*pExpectedSize, "dic data= ",
    +00170                 *(UNS8 *)(ptrTable->pSubindex[bSubindex].pObject + i));
    +00171       }
    +00172 
    +00173     }
    +00174 #endif
    +00175     return OD_SUCCESSFUL;
    +00176   }
    +00177   else { 
    +00178     *pExpectedSize = szData;
    +00179     accessDictionaryError(wIndex, bSubindex, szData,
    +00180                           *pExpectedSize, OD_LENGTH_DATA_INVALID);
    +00181     return OD_LENGTH_DATA_INVALID;
    +00182   }
    +00183 }
    +00184 
    +00198 UNS32 getODentry( CO_Data* d,
    +00199                   UNS16 wIndex,
    +00200                   UNS8 bSubindex,
    +00201                   void * pDestData,
    +00202                   UNS8 * pExpectedSize,
    +00203                   UNS8 * pDataType,
    +00204                   UNS8 checkAccess)
    +00205 {
    +00206   return _getODentry( d,
    +00207                       wIndex,
    +00208                       bSubindex,
    +00209                       pDestData,
    +00210                       pExpectedSize,
    +00211                       pDataType,
    +00212                       checkAccess,
    +00213                       1);//endianize
    +00214 }
    +00215 
    +00229 UNS32 readLocalDict( CO_Data* d,
    +00230                      UNS16 wIndex,
    +00231                      UNS8 bSubindex,
    +00232                      void * pDestData,
    +00233                      UNS8 * pExpectedSize,
    +00234                      UNS8 * pDataType,
    +00235                      UNS8 checkAccess)
    +00236 {
    +00237   return _getODentry( d,
    +00238                       wIndex,
    +00239                       bSubindex,
    +00240                       pDestData,
    +00241                       pExpectedSize,
    +00242                       pDataType,
    +00243                       checkAccess,
    +00244                       0);//do not endianize
    +00245 }
    +00246 
    +00260 UNS32 _setODentry( CO_Data* d,
    +00261                    UNS16 wIndex,
    +00262                    UNS8 bSubindex,
    +00263                    void * pSourceData,
    +00264                    UNS8 * pExpectedSize,
    +00265                    UNS8 checkAccess,
    +00266                    UNS8 endianize)
    +00267 {
    +00268   UNS8 szData;
    +00269   UNS8 dataType;
    +00270   UNS32 errorCode;
    +00271   const indextable *ptrTable;
    +00272   ODCallback_t *Callback;
    +00273 
    +00274   ptrTable =(*d->scanIndexOD)(wIndex, &errorCode, &Callback);
    +00275   if (errorCode != OD_SUCCESSFUL)
    +00276     return errorCode;
    +00277 
    +00278   if( ptrTable->bSubCount <= bSubindex ) {
    +00280     accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_NO_SUCH_SUBINDEX);
    +00281     return OD_NO_SUCH_SUBINDEX;
    +00282   }
    +00283   if (checkAccess && (ptrTable->pSubindex[bSubindex].bAccessType == RO)) {
    +00284     MSG_WAR(0x2B25, "Access Type : ", ptrTable->pSubindex[bSubindex].bAccessType);
    +00285     accessDictionaryError(wIndex, bSubindex, 0, *pExpectedSize, OD_WRITE_NOT_ALLOWED);
    +00286     return OD_WRITE_NOT_ALLOWED;
    +00287   }
     00288 
     00289 
    -00290 
    -00291 
    -00292 const indextable * scanIndexOD (CO_Data* d, UNS16 wIndex, UNS32 *errorCode, ODCallback_t **Callback)
    -00293 {
    -00294   return (*d->scanIndexOD)(wIndex, errorCode, Callback);
    -00295 }
    -00296 
    -00297 UNS32 RegisterSetODentryCallBack(CO_Data* d, UNS16 wIndex, UNS8 bSubindex, ODCallback_t Callback)
    -00298 {
    -00299         UNS32 errorCode;
    -00300         ODCallback_t *CallbackList;
    -00301 
    -00302         scanIndexOD (d, wIndex, &errorCode, &CallbackList);
    -00303         if(errorCode == OD_SUCCESSFUL && CallbackList) 
    -00304                 CallbackList[bSubindex] = Callback;
    -00305         return errorCode;
    -00306 }
    -00307 
    -00308 void _storeODSubIndex (UNS16 wIndex, UNS8 bSubindex){}
    -

    Generated on Mon Jun 4 17:09:26 2007 for CanFestival by  +00290 dataType = ptrTable->pSubindex[bSubindex].bDataType; +00291 szData = ptrTable->pSubindex[bSubindex].size; +00292 +00293 if( *pExpectedSize == 0 || +00294 *pExpectedSize == szData || +00295 (dataType == visible_string && *pExpectedSize < szData)) /* We +00296 allow to store a shorter string than entry size */ +00297 { +00298 #ifdef CANOPEN_BIG_ENDIAN +00299 if(endianize && dataType > boolean && dataType < visible_string) +00300 { +00304 UNS8 i; +00305 for ( i = 0 ; i < ( ptrTable->pSubindex[bSubindex].size >> 1) ; i++) +00306 { +00307 UNS8 tmp =((UNS8 *)pSourceData) [(ptrTable->pSubindex[bSubindex].size - 1) - i]; +00308 ((UNS8 *)pSourceData) [(ptrTable->pSubindex[bSubindex].size - 1) - i] = ((UNS8 *)pSourceData)[i]; +00309 ((UNS8 *)pSourceData)[i] = tmp; +00310 } +00311 } +00312 #endif +00313 errorCode = (*d->valueRangeTest)(dataType, pSourceData); +00314 if (errorCode) { +00315 accessDictionaryError(wIndex, bSubindex, szData, *pExpectedSize, errorCode); +00316 return errorCode; +00317 } +00318 memcpy(ptrTable->pSubindex[bSubindex].pObject,pSourceData, *pExpectedSize); +00319 *pExpectedSize = szData; +00320 +00322 if(Callback && Callback[bSubindex]){ +00323 (*Callback[bSubindex])(d, ptrTable, bSubindex); +00324 } +00325 +00327 if (ptrTable->pSubindex[bSubindex].bAccessType & TO_BE_SAVE){ +00328 (*d->storeODSubIndex)(wIndex, bSubindex); +00329 } +00330 return OD_SUCCESSFUL; +00331 }else{ +00332 *pExpectedSize = szData; +00333 accessDictionaryError(wIndex, bSubindex, szData, *pExpectedSize, OD_LENGTH_DATA_INVALID); +00334 return OD_LENGTH_DATA_INVALID; +00335 } +00336 } +00337 +00350 UNS32 setODentry( CO_Data* d, +00351 UNS16 wIndex, +00352 UNS8 bSubindex, +00353 void * pSourceData, +00354 UNS8 * pExpectedSize, +00355 UNS8 checkAccess) +00356 { +00357 return _setODentry( d, +00358 wIndex, +00359 bSubindex, +00360 pSourceData, +00361 pExpectedSize, +00362 checkAccess, +00363 1);//endianize +00364 } +00365 +00378 UNS32 writeLocalDict( CO_Data* d, +00379 UNS16 wIndex, +00380 UNS8 bSubindex, +00381 void * pSourceData, +00382 UNS8 * pExpectedSize, +00383 UNS8 checkAccess) +00384 { +00385 return _setODentry( d, +00386 wIndex, +00387 bSubindex, +00388 pSourceData, +00389 pExpectedSize, +00390 checkAccess, +00391 0);//do not endianize +00392 } +00393 +00404 const indextable * scanIndexOD (CO_Data* d, UNS16 wIndex, UNS32 *errorCode, ODCallback_t **Callback) +00405 { +00406 return (*d->scanIndexOD)(wIndex, errorCode, Callback); +00407 } +00408 +00419 UNS32 RegisterSetODentryCallBack(CO_Data* d, UNS16 wIndex, UNS8 bSubindex, ODCallback_t Callback) +00420 { +00421 UNS32 errorCode; +00422 ODCallback_t *CallbackList; +00423 +00424 scanIndexOD (d, wIndex, &errorCode, &CallbackList); +00425 if(errorCode == OD_SUCCESSFUL && CallbackList) +00426 CallbackList[bSubindex] = Callback; +00427 return errorCode; +00428 } +00429 +00436 void _storeODSubIndex (UNS16 wIndex, UNS8 bSubindex){} +
    Generated on Tue Jun 5 18:32:05 2007 for CanFestival by  doxygen 1.5.1