bug correction in dcf.c, an entry of only one byte was not checked
authorMongo
Tue, 13 Dec 2011 17:38:12 +0100
changeset 671 06b30f679531
parent 670 e37511baf56b
child 672 3bbc9aeba925
bug correction in dcf.c, an entry of only one byte was not checked
examples/TestMasterSlave/TestMaster.c
src/dcf.c
--- a/examples/TestMasterSlave/TestMaster.c	Wed Nov 02 22:37:24 2011 +0100
+++ b/examples/TestMasterSlave/TestMaster.c	Tue Dec 13 17:38:12 2011 +0100
@@ -4,7 +4,7 @@
 #include "TestMaster.h"
 
 /**************************************************************************/
-/* Declaration of the mapped variables                                    */
+/* Declaration of mapped variables                                        */
 /**************************************************************************/
 UNS8 MasterMap1 = 0x0;		/* Mapped at index 0x2000, subindex 0x00 */
 UNS8 MasterMap2 = 0x0;		/* Mapped at index 0x2001, subindex 0x00 */
@@ -21,7 +21,7 @@
 INTEGER16 MasterMap13 = 0x0;		/* Mapped at index 0x200C, subindex 0x00 */
 
 /**************************************************************************/
-/* Declaration of the value range types                                   */
+/* Declaration of value range types                                       */
 /**************************************************************************/
 
 #define valueRange_EMC 0x9F /* Type for index 0x1003 subindex 0x00 (only set of value 0 is possible) */
@@ -114,14 +114,14 @@
                     UNS32 TestMaster_obj1010_Save_All_Parameters = 0x0;	/* 0 */
                     UNS32 TestMaster_obj1010_Save_Communication_Parameters = 0x0;	/* 0 */
                     UNS32 TestMaster_obj1010_Save_Application_Parameters = 0x0;	/* 0 */
-                    UNS32 TestMaster_obj1010_Save_Manufacturer_Parameters = 0x0;	/* 0 */
+                    UNS32 TestMaster_obj1010_Save_Manufacturer_Parameters_1 = 0x0;	/* 0 */
                     subindex TestMaster_Index1010[] = 
                      {
                        { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1010 },
                        { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1010_Save_All_Parameters },
                        { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1010_Save_Communication_Parameters },
                        { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1010_Save_Application_Parameters },
-                       { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1010_Save_Manufacturer_Parameters }
+                       { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1010_Save_Manufacturer_Parameters_1 }
                      };
 
 /* index 0x1011 :   Restore Default Parameters. */
@@ -129,14 +129,14 @@
                     UNS32 TestMaster_obj1011_Restore_All_Default_Parameters = 0x0;	/* 0 */
                     UNS32 TestMaster_obj1011_Restore_Communication_Default_Parameters = 0x0;	/* 0 */
                     UNS32 TestMaster_obj1011_Restore_Application_Default_Parameters = 0x0;	/* 0 */
-                    UNS32 TestMaster_obj1011_Restore_Manufacturer_Default_Parameters = 0x0;	/* 0 */
+                    UNS32 TestMaster_obj1011_Restore_Manufacturer_Defined_Default_Parameters_1 = 0x0;	/* 0 */
                     subindex TestMaster_Index1011[] = 
                      {
                        { RO, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1011 },
                        { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1011_Restore_All_Default_Parameters },
                        { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1011_Restore_Communication_Default_Parameters },
                        { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1011_Restore_Application_Default_Parameters },
-                       { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1011_Restore_Manufacturer_Default_Parameters }
+                       { RW, uint32, sizeof (UNS32), (void*)&TestMaster_obj1011_Restore_Manufacturer_Defined_Default_Parameters_1 }
                      };
 
 /* index 0x1014 :   Emergency COB ID. */
@@ -325,7 +325,7 @@
 
 /* index 0x1F22 :   Concise DCF. */
                     UNS8 TestMaster_highestSubIndex_obj1F22 = 2; /* number of subindex - 1*/
-                    UNS8* TestMaster_obj1F22[] = 
+                    INTEGER8* TestMaster_obj1F22[] = 
                     {
                       "",
                       "\x01\x00\x00\x00\x17\x10\x00\x02\x00\x00\x00\xe8\x03"
@@ -419,6 +419,10 @@
                        { RW, int16, sizeof (INTEGER16), (void*)&MasterMap13 }
                      };
 
+/**************************************************************************/
+/* Declaration of pointed variables                                       */
+/**************************************************************************/
+
 const indextable TestMaster_objdict[] = 
 {
   { (subindex*)TestMaster_Index1000,sizeof(TestMaster_Index1000)/sizeof(TestMaster_Index1000[0]), 0x1000},
@@ -507,7 +511,7 @@
  */
 s_PDO_status TestMaster_PDO_status[1] = {s_PDO_status_Initializer};
 
-quick_index TestMaster_firstIndex = {
+const quick_index TestMaster_firstIndex = {
   0, /* SDO_SVR */
   9, /* SDO_CLT */
   10, /* PDO_RCV */
@@ -516,7 +520,7 @@
   0 /* PDO_TRS_MAP */
 };
 
-quick_index TestMaster_lastIndex = {
+const quick_index TestMaster_lastIndex = {
   0, /* SDO_SVR */
   9, /* SDO_CLT */
   13, /* PDO_RCV */
@@ -525,7 +529,7 @@
   0 /* PDO_TRS_MAP */
 };
 
-UNS16 TestMaster_ObjdictSize = sizeof(TestMaster_objdict)/sizeof(TestMaster_objdict[0]); 
+const UNS16 TestMaster_ObjdictSize = sizeof(TestMaster_objdict)/sizeof(TestMaster_objdict[0]); 
 
 CO_Data TestMaster_Data = CANOPEN_NODE_DATA_INITIALIZER(TestMaster);
 
--- a/src/dcf.c	Wed Nov 02 22:37:24 2011 +0100
+++ b/src/dcf.c	Tue Dec 13 17:38:12 2011 +0100
@@ -88,7 +88,7 @@
         /* Check if data received match the DCF */
         if(size == d->dcf_size){
             match = 1;
-            while(--size)
+            while(size--)
                 if(buf[size] != d->dcf_data[size])
                     match = 0;
         }