src/objacces.c
changeset 10 0c4d04e5fac0
parent 8 eee2b0c89213
child 11 64ed038bdc74
equal deleted inserted replaced
9:49f701f3dca7 10:0c4d04e5fac0
    18 You should have received a copy of the GNU Lesser General Public
    18 You should have received a copy of the GNU Lesser General Public
    19 License along with this library; if not, write to the Free Software
    19 License along with this library; if not, write to the Free Software
    20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    21 */
    21 */
    22 
    22 
    23 //#define DEBUG_WAR_CONSOLE_ON
    23 #define DEBUG_WAR_CONSOLE_ON
    24 //#define DEBUG_ERR_CONSOLE_ON
    24 #define DEBUG_ERR_CONSOLE_ON
    25 
    25 
    26 #include "objacces.h"
    26 #include "objacces.h"
    27 
    27 
    28 
    28 
    29 #ifdef DEBUG_WAR_CONSOLE_ON
    29 #ifdef DEBUG_WAR_CONSOLE_ON
    97   if(	*pExpectedSize == 0 ||
    97   if(	*pExpectedSize == 0 ||
    98   	*pExpectedSize == szData ||
    98   	*pExpectedSize == szData ||
    99   	(*pDataType == visible_string && *pExpectedSize > szData)) // We allow to fetch a shorter string than expected
    99   	(*pDataType == visible_string && *pExpectedSize > szData)) // We allow to fetch a shorter string than expected
   100   {
   100   {
   101 	#ifdef CANOPEN_BIG_ENDIAN
   101 	#ifdef CANOPEN_BIG_ENDIAN
   102 	      if(*pDataType > boolean && pDataType < visible_string){
   102 	      if(*pDataType > boolean && *pDataType < visible_string){
   103 		// data must be transmited with low byte first
   103 		// data must be transmited with low byte first
       
   104 		MSG_WAR(0x2B30, "Dans ENDIANISATION", 0x00);
   104 		UNS8 i, j = 0;
   105 		UNS8 i, j = 0;
   105 		for ( i = ptrTable->pSubindex[bSubindex].size ; i > 0 ; i--) {
   106 		for ( i = ptrTable->pSubindex[bSubindex].size ; i > 0 ; i--) {
   106 			((char*)pDestData)[j++] = ((char*)ptrTable->pSubindex[bSubindex].pObject)[i-1];
   107 			((char*)pDestData)[j++] = ((char*)ptrTable->pSubindex[bSubindex].pObject)[i-1];
   107 		}
   108 		}
       
   109 	      }
       
   110 	      else {
       
   111 	      	MSG_WAR(0x2B32, "cas string", 0x00);
   108 	      }
   112 	      }
   109 	#else  	
   113 	#else  	
   110   	      memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,*pExpectedSize);
   114   	      memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,*pExpectedSize);
   111 	#endif
   115 	#endif
   112       *pExpectedSize = szData;
   116       *pExpectedSize = szData;
   156   {
   160   {
   157       #ifdef CANOPEN_BIG_ENDIAN
   161       #ifdef CANOPEN_BIG_ENDIAN
   158 	      if(dataType > boolean && dataType < visible_string){
   162 	      if(dataType > boolean && dataType < visible_string){
   159 		// we invert the data source directly. This let us do range testing without
   163 		// we invert the data source directly. This let us do range testing without
   160 		// additional temp variable
   164 		// additional temp variable
       
   165 		MSG_WAR(0x2B31, "Dans ENDIANISATION", 0x00);
   161 		UNS8 i, j = 0;
   166 		UNS8 i, j = 0;
   162 		for ( i = ptrTable->pSubindex[bSubindex].size >> 1 ; i > 0 ; i--) {
   167 		for ( i = ptrTable->pSubindex[bSubindex].size ; i > 0 ; i--) {
   163 			char tmp = ((char*)pSourceData)[i - 1];
   168 			((char*)ptrTable->pSubindex[bSubindex].pObject)[i - 1] = ((char*)pSourceData)[j++];
   164 			((char*)pSourceData)[i - 1] = ((char*)pSourceData)[j];
       
   165 			((char*)pSourceData)[j++] = tmp;
       
   166 		}
   169 		}
       
   170 //		for ( i = ptrTable->pSubindex[bSubindex].size >> 1 ; i > 0 ; i--) {
       
   171 //			char tmp = ((char*)pSourceData)[i - 1];
       
   172 //			((char*)pSourceData)[i - 1] = ((char*)pSourceData)[j];
       
   173 //			((char*)pSourceData)[j++] = tmp;
       
   174 //		}
       
   175 	      }
       
   176 	      else {
       
   177 	      	MSG_WAR(0x2B35, "cas string", 0x00);
   167 	      }
   178 	      }
   168       #endif
   179       #endif
   169       errorCode = (*d->valueRangeTest)(dataType, pSourceData);
   180       errorCode = (*d->valueRangeTest)(dataType, pSourceData);
   170       if (errorCode) {
   181       if (errorCode) {
   171 	accessDictionaryError(wIndex, bSubindex, szData, *pExpectedSize, errorCode);
   182 	accessDictionaryError(wIndex, bSubindex, szData, *pExpectedSize, errorCode);