Added writeLocalDict and readLocalDict, that have to be called from application instead of getODEntry and setODEntry. Fix potential endianization problem.
authoretisserant
Tue, 24 Apr 2007 16:49:40 +0200
changeset 175 e255529b6f7d
parent 174 cd1638bc0cb0
child 176 5d57fe1e3a5b
Added writeLocalDict and readLocalDict, that have to be called from application instead of getODEntry and setODEntry. Fix potential endianization problem.
examples/TestMasterMicroMod/TestMasterMicroMod.c
examples/TestMasterSlave/Master.c
examples/win32test/main.c
include/objacces.h
src/objacces.c
src/win32/CanFestival-3.def
--- a/examples/TestMasterMicroMod/TestMasterMicroMod.c	Tue Apr 24 16:16:03 2007 +0200
+++ b/examples/TestMasterMicroMod/TestMasterMicroMod.c	Tue Apr 24 16:49:40 2007 +0200
@@ -63,7 +63,7 @@
 	/*****************************************
 	 * Define RPDOs to match slave ID=0x40 TPDOs*
 	 *****************************************/
-	setODentry( &TestMaster_Data, /*CO_Data* d*/
+	writeLocalDict( &TestMaster_Data, /*CO_Data* d*/
 			0x1400, /*UNS16 index*/
 			0x01, /*UNS8 subind*/ 
 			&PDO1_COBID, /*void * pSourceData,*/ 
@@ -74,7 +74,7 @@
 	/*****************************************
 	 * Define TPDOs to match slave ID=0x40 RPDOs*
 	 *****************************************/
-	setODentry( &TestMaster_Data, /*CO_Data* d*/
+	writeLocalDict( &TestMaster_Data, /*CO_Data* d*/
 			0x1800, /*UNS16 index*/
 			0x01, /*UNS8 subind*/ 
 			&PDO2_COBID, /*void * pSourceData,*/ 
--- a/examples/TestMasterSlave/Master.c	Tue Apr 24 16:16:03 2007 +0200
+++ b/examples/TestMasterSlave/Master.c	Tue Apr 24 16:49:40 2007 +0200
@@ -46,14 +46,14 @@
 	/*****************************************
 	 * Define RPDOs to match slave ID=2 TPDOs*
 	 *****************************************/
-	setODentry( &TestMaster_Data, /*CO_Data* d*/
+	writeLocalDict( &TestMaster_Data, /*CO_Data* d*/
 			0x1400, /*UNS16 index*/
 			0x01, /*UNS8 subind*/ 
 			&PDO1_COBID, /*void * pSourceData,*/ 
 			&size, /* UNS8 * pExpectedSize*/
 			RW);  /* UNS8 checkAccess */
 			
-	setODentry( &TestMaster_Data, /*CO_Data* d*/
+	writeLocalDict( &TestMaster_Data, /*CO_Data* d*/
 			0x1401, /*UNS16 index*/
 			0x01, /*UNS8 subind*/ 
 			&PDO2_COBID, /*void * pSourceData,*/ 
--- a/examples/win32test/main.c	Tue Apr 24 16:16:03 2007 +0200
+++ b/examples/win32test/main.c	Tue Apr 24 16:49:40 2007 +0200
@@ -134,9 +134,9 @@
          UNS32 Node_ID_of_the_SDO_Server = node_id;
          UNS8 ExpectedSize = sizeof (UNS32);
 
-         if (OD_SUCCESSFUL ==  setODentry(&win32test_Data, 0x1280, 1, &COB_ID_Client_to_Server_Transmit_SDO, &ExpectedSize, RW) 
-              && OD_SUCCESSFUL ==  setODentry(&win32test_Data, 0x1280, 2, &COB_ID_Server_to_Client_Receive_SDO, &ExpectedSize, RW) 
-              && OD_SUCCESSFUL ==  setODentry(&win32test_Data, 0x1280, 3, &Node_ID_of_the_SDO_Server, &ExpectedSize, RW))
+         if (OD_SUCCESSFUL ==  writeLocalDict(&win32test_Data, 0x1280, 1, &COB_ID_Client_to_Server_Transmit_SDO, &ExpectedSize, RW) 
+              && OD_SUCCESSFUL ==  writeLocalDict(&win32test_Data, 0x1280, 2, &COB_ID_Server_to_Client_Receive_SDO, &ExpectedSize, RW) 
+              && OD_SUCCESSFUL ==  writeLocalDict(&win32test_Data, 0x1280, 3, &Node_ID_of_the_SDO_Server, &ExpectedSize, RW))
             {
             UNS32 dev_type = 0;
             char device_name[64]="";
--- a/include/objacces.h	Tue Apr 24 16:16:03 2007 +0200
+++ b/include/objacces.h	Tue Apr 24 16:49:40 2007 +0200
@@ -128,6 +128,14 @@
 		  UNS8 * pExpectedSize, 
 		  UNS8 checkAccess);
 
+/*The same, without endianisation*/
+UNS32 writeLocalDict( CO_Data* d, 
+                  UNS16 wIndex,
+		  UNS8 bSubindex, 
+		  void * pSourceData, 
+		  UNS8 * pExpectedSize, 
+		  UNS8 checkAccess);
+
 
 /* Scan the index of object dictionary. Used only by setODentry and getODentry.
  *  *errorCode :  OD_SUCCESSFUL if index foundor SDO abort code. (See file def.h)
--- a/src/objacces.c	Tue Apr 24 16:16:03 2007 +0200
+++ b/src/objacces.c	Tue Apr 24 16:49:40 2007 +0200
@@ -65,13 +65,14 @@
 }	
 
 
-UNS32 getODentry( CO_Data* d, 
+UNS32 _getODentry( CO_Data* d, 
                   UNS16 wIndex,
 		  UNS8 bSubindex,
 		  void * pDestData,
 		  UNS8 * pExpectedSize,
 		  UNS8 * pDataType,
-		  UNS8 checkAccess)
+		  UNS8 checkAccess,
+		  UNS8 endianize)
 { /* DO NOT USE MSG_ERR because the macro may send a PDO -> infinite loop if it fails. */
   UNS32 errorCode;
   UNS8 szData;
@@ -102,7 +103,7 @@
   	(*pDataType == visible_string && *pExpectedSize < szData)) {/* We allow to fetch a shorter string than expected */
      
 #  ifdef CANOPEN_BIG_ENDIAN
-     if(*pDataType > boolean && *pDataType < visible_string) {
+     if(endianize && *pDataType > boolean && *pDataType < visible_string) {
        /* data must be transmited with low byte first */
        UNS8 i, j = 0;
        MSG_WAR(boolean, "data type ", *pDataType);
@@ -141,12 +142,49 @@
    }
 }
 
-UNS32 setODentry( CO_Data* d, 
+UNS32 getODentry( CO_Data* d, 
+                  UNS16 wIndex,
+		  UNS8 bSubindex,
+		  void * pDestData,
+		  UNS8 * pExpectedSize,
+		  UNS8 * pDataType,
+		  UNS8 checkAccess)
+{
+	return _getODentry( d, 
+                  wIndex,
+		  bSubindex,
+		  pDestData,
+		  pExpectedSize,
+		  pDataType,
+		  checkAccess,
+		  1);//endianize
+}
+
+UNS32 readLocalDict( CO_Data* d, 
+                  UNS16 wIndex,
+		  UNS8 bSubindex,
+		  void * pDestData,
+		  UNS8 * pExpectedSize,
+		  UNS8 * pDataType,
+		  UNS8 checkAccess)
+{
+		return _getODentry( d, 
+                  wIndex,
+		  bSubindex,
+		  pDestData,
+		  pExpectedSize,
+		  pDataType,
+		  checkAccess,
+		  0);//do not endianize
+}
+
+UNS32 _setODentry( CO_Data* d, 
                   UNS16 wIndex,
 		  UNS8 bSubindex, 
 		  void * pSourceData, 
 		  UNS8 * pExpectedSize, 
-		  UNS8 checkAccess)
+		  UNS8 checkAccess,
+		  UNS8 endianize)
 {
   UNS8 szData;
   UNS8 dataType;
@@ -178,7 +216,7 @@
   	(dataType == visible_string && *pExpectedSize < szData)) /* We allow to store a shorter string than entry size */
   {
       #ifdef CANOPEN_BIG_ENDIAN
-	      if(dataType > boolean && dataType < visible_string)
+	      if(endianize && dataType > boolean && dataType < visible_string)
 	      {
 			/* we invert the data source directly. This let us do range testing without */
 			/* additional temp variable */
@@ -216,6 +254,40 @@
   }
 }
 
+UNS32 setODentry( CO_Data* d, 
+                  UNS16 wIndex,
+		  UNS8 bSubindex, 
+		  void * pSourceData, 
+		  UNS8 * pExpectedSize, 
+		  UNS8 checkAccess)
+{
+	return _setODentry( d, 
+                  wIndex,
+		  bSubindex, 
+		  pSourceData, 
+		  pExpectedSize, 
+		  checkAccess,
+		  1);//endianize
+}
+
+UNS32 writeLocalDict( CO_Data* d, 
+                  UNS16 wIndex,
+		  UNS8 bSubindex, 
+		  void * pSourceData, 
+		  UNS8 * pExpectedSize, 
+		  UNS8 checkAccess)
+{
+	return _setODentry( d, 
+                  wIndex,
+		  bSubindex, 
+		  pSourceData, 
+		  pExpectedSize, 
+		  checkAccess,
+		  0);//do not endianize
+}
+
+
+
 
 const indextable * scanIndexOD (CO_Data* d, UNS16 wIndex, UNS32 *errorCode, ODCallback_t **Callback)
 {
--- a/src/win32/CanFestival-3.def	Tue Apr 24 16:16:03 2007 +0200
+++ b/src/win32/CanFestival-3.def	Tue Apr 24 16:49:40 2007 +0200
@@ -15,6 +15,8 @@
         accessDictionaryError
         getODentry
         setODentry
+        writeLocalDict
+        readLocalDict
         scanIndexOD
         RegisterSetODentryCallBack
         sendPDO