CANOPEN_BIG_ENDIAN :
authordejoigny
Wed, 17 May 2006 20:40:17 +0200
changeset 12 1d3b9ad366c8
parent 11 64ed038bdc74
child 13 0e43acff2c96
CANOPEN_BIG_ENDIAN :
fonctionne pour SDO et PDO.
SDO segment?s test?s en upload et download. Semble ok.
src/objacces.c
src/sdo.c
--- a/src/objacces.c	Wed May 17 15:01:30 2006 +0200
+++ b/src/objacces.c	Wed May 17 20:40:17 2006 +0200
@@ -23,7 +23,6 @@
 //#define DEBUG_WAR_CONSOLE_ON
 //#define DEBUG_ERR_CONSOLE_ON
 
-#undef CANOPEN_BIG_ENDIAN
 
 #include "objacces.h"
 
@@ -96,28 +95,48 @@
   *pDataType = ptrTable->pSubindex[bSubindex].bDataType;
    szData = ptrTable->pSubindex[bSubindex].size;
 
-  if(	*pExpectedSize == 0 ||
+   if(	*pExpectedSize == 0 ||
   	*pExpectedSize == szData ||
-  	(*pDataType == visible_string && *pExpectedSize > szData)) // We allow to fetch a shorter string than expected
-  {
-	#ifdef CANOPEN_BIG_ENDIAN
-	      if(*pDataType > boolean && *pDataType < visible_string) {
-		// data must be transmited with low byte first
-		UNS8 i, j = 0;
-		for ( i = ptrTable->pSubindex[bSubindex].size ; i > 0 ; i--) {
-			((char*)pDestData)[j++] = ((char*)ptrTable->pSubindex[bSubindex].pObject)[i-1];
-		}
-	      }
-	#else  	
-  	      memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,*pExpectedSize);
-	#endif
-      *pExpectedSize = szData;
-      return OD_SUCCESSFUL;
-  }else{
-      *pExpectedSize = szData;
-      accessDictionaryError(wIndex, bSubindex, szData, *pExpectedSize, OD_LENGTH_DATA_INVALID);
-      return OD_LENGTH_DATA_INVALID;
-  }
+  	(*pDataType == visible_string && *pExpectedSize < szData)) {// We allow to fetch a shorter string than expected
+     
+#  ifdef CANOPEN_BIG_ENDIAN
+     if(*pDataType > boolean && *pDataType < visible_string) {
+       // data must be transmited with low byte first
+       UNS8 i, j = 0;
+       MSG_WAR(boolean, "data type ", *pDataType);
+       MSG_WAR(visible_string, "data type ", *pDataType);
+       for ( i = szData ; i > 0 ; i--) {
+         MSG_WAR(i," ", j);
+	 ((UNS8*)pDestData)[j++] = 
+	   ((UNS8*)ptrTable->pSubindex[bSubindex].pObject)[i-1];
+       }
+     }
+     else // It it is a visible string no endianisation to perform
+       memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData);
+#  else
+     memcpy(pDestData, ptrTable->pSubindex[bSubindex].pObject,szData);
+#  endif
+     
+     *pExpectedSize = szData;
+#if 0
+     // Me laisser ça, please ! (FD)
+     {
+       UNS8 i;
+       for (i = 0 ; i < 10 ; i++) {
+	 MSG_WAR(*pExpectedSize, "dic data= ",
+		 *(UNS8 *)(ptrTable->pSubindex[bSubindex].pObject + i));
+       }
+      
+     }
+#endif
+     return OD_SUCCESSFUL;
+   }
+   else { // Error !
+     *pExpectedSize = szData;
+     accessDictionaryError(wIndex, bSubindex, szData, 
+			   *pExpectedSize, OD_LENGTH_DATA_INVALID);
+     return OD_LENGTH_DATA_INVALID;
+   }
 }
 
 UNS32 setODentry( CO_Data* d, 
--- a/src/sdo.c	Wed May 17 15:01:30 2006 +0200
+++ b/src/sdo.c	Wed May 17 20:40:17 2006 +0200
@@ -136,8 +136,8 @@
   UNS8  dataType;
   UNS32 errorCode;
 
-  MSG_WAR(0x3A05, "Reading at index : ", d->transfers[line].index);
-  MSG_WAR(0x3A06, "Reading at subIndex : ", d->transfers[line].subIndex);
+  MSG_WAR(0x3A05, "objdict->line index : ", d->transfers[line].index);
+  MSG_WAR(0x3A06, "  subIndex : ", d->transfers[line].subIndex);
 
   errorCode = getODentry(d, 	d->transfers[line].index,
   				d->transfers[line].subIndex,
@@ -149,6 +149,15 @@
 
   d->transfers[line].count = size;
   d->transfers[line].offset = 0;
+#if 0
+  // Me laisser ça, please ! (FD)
+  {
+    UNS8 i;
+    for (i = 0 ; i < 10 ; i++) {
+      MSG_WAR(i, "data= ", d->transfers[line].data[i]);
+    }     
+  }
+#endif
   return 0;
 }
 
@@ -764,10 +773,10 @@
       // Search if a SDO transfert have been yet initiated
       err = getSDOlineOnUse( d, nodeId, whoami, &line );
       if (! err) {
-	MSG_ERR(0x1A92, "SDO error : Transmission yet started at line : ", line); 
+	    MSG_ERR(0x1A92, "SDO error : Transmission yet started at line : ", line); 
         MSG_WAR(0x3A93, "nodeId = ", nodeId); 
-	failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_LOCAL_CTRL_ERROR);
-	return 0xFF;
+	    failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_LOCAL_CTRL_ERROR);
+	    return 0xFF;
       }
       // No line on use. Great !
       // Try to open a new line.