src/objacces.c
changeset 431 166037b8f2ed
parent 430 61a24423589c
child 437 129bbe0504e4
equal deleted inserted replaced
430:61a24423589c 431:166037b8f2ed
   142      (*pDataType >= visible_string && *pExpectedSize < szData)) { 
   142      (*pDataType >= visible_string && *pExpectedSize < szData)) { 
   143 
   143 
   144 #  ifdef CANOPEN_BIG_ENDIAN
   144 #  ifdef CANOPEN_BIG_ENDIAN
   145      if(endianize && *pDataType > boolean && !(
   145      if(endianize && *pDataType > boolean && !(
   146             *pDataType >= visible_string && 
   146             *pDataType >= visible_string && 
   147             domain <= *pDataType)) {
   147             *pDataType <= domain)) {
   148       /* data must be transmited with low byte first */
   148       /* data must be transmited with low byte first */
   149       UNS8 i, j = 0;
   149       UNS8 i, j = 0;
   150       MSG_WAR(boolean, "data type ", *pDataType);
   150       MSG_WAR(boolean, "data type ", *pDataType);
   151       MSG_WAR(visible_string, "data type ", *pDataType);
   151       MSG_WAR(visible_string, "data type ", *pDataType);
   152       for ( i = szData ; i > 0 ; i--) {
   152       for ( i = szData ; i > 0 ; i--) {
   153         MSG_WAR(i," ", j);
   153         MSG_WAR(i," ", j);
   154         ((UNS8*)pDestData)[j++] =
   154         ((UNS8*)pDestData)[j++] =
   155           ((UNS8*)ptrTable->pSubindex[bSubindex].pObject)[i-1];
   155           ((UNS8*)ptrTable->pSubindex[bSubindex].pObject)[i-1];
   156       }
   156       }
       
   157       *pExpectedSize = szData;
   157     }
   158     }
   158     else /* no endianisation change */
   159     else /* no endianisation change */
   159 #  endif
   160 #  endif
   160     if(*pDataType != visible_string) {
   161     if(*pDataType != visible_string) {
   161         memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData);
   162         memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData);
   166          *  - store string size in td_subindex 
   167          *  - store string size in td_subindex 
   167          * */
   168          * */
   168         /* Copy null terminated string to user, and return discovered size */
   169         /* Copy null terminated string to user, and return discovered size */
   169         UNS8 *ptr = (UNS8*)ptrTable->pSubindex[bSubindex].pObject;
   170         UNS8 *ptr = (UNS8*)ptrTable->pSubindex[bSubindex].pObject;
   170         UNS8 *ptr_start = ptr;
   171         UNS8 *ptr_start = ptr;
   171         UNS8 *ptr_end = ptr + *pExpectedSize; /* *pExpectedSize IS < szData */ 
   172         /* *pExpectedSize IS < szData . if null, use szData */
       
   173         UNS8 *ptr_end = ptr + (*pExpectedSize ? *pExpectedSize : szData) ; 
   172         UNS8 *ptr_dest = (UNS8*)pDestData;
   174         UNS8 *ptr_dest = (UNS8*)pDestData;
   173         while( *ptr && ptr < ptr_end){
   175         while( *ptr && ptr < ptr_end){
   174             *(ptr_dest++) = *(ptr++);
   176             *(ptr_dest++) = *(ptr++);
   175         } 
   177         } 
   176          
   178          
   305     {
   307     {
   306 #ifdef CANOPEN_BIG_ENDIAN
   308 #ifdef CANOPEN_BIG_ENDIAN
   307       /* re-endianize do not occur for bool, strings time and domains */
   309       /* re-endianize do not occur for bool, strings time and domains */
   308       if(endianize && dataType > boolean && !(
   310       if(endianize && dataType > boolean && !(
   309             dataType >= visible_string && 
   311             dataType >= visible_string && 
   310             domain <= dataType))
   312             dataType <= domain))
   311         {
   313         {
   312           /* we invert the data source directly. This let us do range
   314           /* we invert the data source directly. This let us do range
   313             testing without */
   315             testing without */
   314           /* additional temp variable */
   316           /* additional temp variable */
   315           UNS8 i;
   317           UNS8 i;