Added _writenetworkdictionary option to avoir endianiation
authoretisserant
Tue, 24 Apr 2007 16:16:03 +0200
changeset 174 cd1638bc0cb0
parent 173 d776314a1efc
child 175 e255529b6f7d
Added _writenetworkdictionary option to avoir endianiation
src/sdo.c
--- a/src/sdo.c	Tue Apr 24 14:41:19 2007 +0200
+++ b/src/sdo.c	Tue Apr 24 16:16:03 2007 +0200
@@ -40,7 +40,7 @@
 
 /** Called by writeNetworkDict */
 INLINE UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, 
-		       UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback);
+		       UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize);
 
 /** Called by readNetworkDict */
 INLINE UNS8 _readNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, UNS8 subIndex, 
@@ -1070,7 +1070,7 @@
 
 /*******************************************************************)******/
 INLINE UNS8 _writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, 
-		       UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback)
+		       UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback, UNS8 endianize)
 {
   UNS8 err;
   UNS8 SDOfound = 0;
@@ -1137,7 +1137,7 @@
   /* Copy data to transfers structure. */
   for (j = 0 ; j < count ; j++) {
 # ifdef CANOPEN_BIG_ENDIAN
-    if (dataType == 0)
+    if (dataType == 0 && endianize)
       d->transfers[line].data[count - 1 - j] = ((char *)data)[j];
     else /* String of bytes. */
       d->transfers[line].data[j] = ((char *)data)[j];
@@ -1182,7 +1182,7 @@
 UNS8 writeNetworkDict (CO_Data* d, UNS8 nodeId, UNS16 index, 
 		       UNS8 subIndex, UNS8 count, UNS8 dataType, void *data)
 {
-	return _writeNetworkDict (d, nodeId, index, subIndex, count, dataType, data, NULL);
+	return _writeNetworkDict (d, nodeId, index, subIndex, count, dataType, data, NULL, 1);
 }
 
 /*--------------------------------------------------------------------------*/
@@ -1190,7 +1190,7 @@
 UNS8 writeNetworkDictCallBack (CO_Data* d, UNS8 nodeId, UNS16 index, 
 		       UNS8 subIndex, UNS8 count, UNS8 dataType, void *data, SDOCallback_t Callback)
 {
-	return _writeNetworkDict (d, nodeId, index, subIndex, count, dataType, data, Callback);	
+	return _writeNetworkDict (d, nodeId, index, subIndex, count, dataType, data, Callback, 1);	
 }