]> rtime.felk.cvut.cz Git - CanFestival-3.git/commitdiff
Added writeLocalDict and readLocalDict, that have to be called from application inste...
authoretisserant <etisserant>
Tue, 24 Apr 2007 14:49:40 +0000 (14:49 +0000)
committeretisserant <etisserant>
Tue, 24 Apr 2007 14:49:40 +0000 (14:49 +0000)
examples/TestMasterMicroMod/TestMasterMicroMod.c
examples/TestMasterSlave/Master.c
examples/win32test/main.c
include/objacces.h
src/objacces.c
src/win32/CanFestival-3.def

index 2569f823789c5a49ee55b3602cdf94151ad67668..1594e22fcb51224f1235cd474a06c4ce94bba0f0 100644 (file)
@@ -63,7 +63,7 @@ void TestMaster_initialisation()
        /*****************************************
         * 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 @@ void TestMaster_initialisation()
        /*****************************************
         * 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,*/ 
index 3c1314fe08c0fb3f0f01c0f6322a6239c16d14a4..f8483818e191b368c4d05a84b2fc2a80549d0dab 100644 (file)
@@ -46,14 +46,14 @@ void TestMaster_initialisation()
        /*****************************************
         * 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,*/ 
index 096a9dda21baeb42d7f42e663e19269ebd413ccc..d64ebe9e8ef61f3a2941750fed1c11bfff416a12 100644 (file)
@@ -134,9 +134,9 @@ int main(int argc, char *argv[])
          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]="";
index 95725967e882a399f37b2f692e994b0512ec4809..8dcf5bda430e542eb98f8b6623e283389ba647dc 100644 (file)
@@ -128,6 +128,14 @@ UNS32 setODentry( CO_Data* d,
                  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)
index c21776f797cdbdf7a1222f61d463160606738cd0..48daada780db50a22c8c79cdba213dfed4730087 100644 (file)
@@ -65,13 +65,14 @@ UNS8 accessDictionaryError(UNS16 index, UNS8 subIndex,
 }      
 
 
-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 @@ UNS32 getODentry( CO_Data* d,
        (*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 getODentry( CO_Data* d,
    }
 }
 
-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 @@ UNS32 setODentry( CO_Data* d,
        (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,
   }
 }
 
+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)
 {
index 654598f54efd3023af61e0fff8a5aa328cae94ed..f01d6fbc8f928cf4e40082d9b4055240b4f19307 100644 (file)
@@ -15,6 +15,8 @@ EXPORTS
         accessDictionaryError
         getODentry
         setODentry
+        writeLocalDict
+        readLocalDict
         scanIndexOD
         RegisterSetODentryCallBack
         sendPDO