Bug on gen_cfile.py valueRangeTest generation fixed
authorlbessard
Thu, 27 Sep 2007 09:42:51 +0200
changeset 287 fa4df65d0683
parent 286 85d5361179f3
child 288 26015ee2c2c9
Bug on gen_cfile.py valueRangeTest generation fixed
examples/TestMasterMicroMod/TestMaster.c
examples/TestMasterSlave/TestMaster.c
examples/TestMasterSlave/TestSlave.c
objdictgen/gen_cfile.py
--- a/examples/TestMasterMicroMod/TestMaster.c	Thu Sep 27 08:59:22 2007 +0200
+++ b/examples/TestMasterMicroMod/TestMaster.c	Thu Sep 27 09:42:51 2007 +0200
@@ -20,9 +20,14 @@
 /* Declaration of the value range types                                   */
 /**************************************************************************/
 
+#define valueRange_EMC 0x9F /* Type for index 0x1003 subindex 0x00 (only set of value 0 is possible) */
 UNS32 TestMaster_valueRangeTest (UNS8 typeValue, void * value)
 {
   switch (typeValue) {
+    case valueRange_EMC:
+      if (*(UNS8*)value < (UNS8)0) return OD_VALUE_TOO_LOW;
+      if (*(UNS8*)value > (UNS8)0) return OD_VALUE_TOO_HIGH;
+      break;
   }
   return 0;
 }
@@ -75,7 +80,7 @@
                      };
                     subindex TestMaster_Index1003[] = 
                      {
-                       { RW, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1003 },
+                       { RW, valueRange_EMC, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1003 },
                        { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1003[0] }
                      };
 
--- a/examples/TestMasterSlave/TestMaster.c	Thu Sep 27 08:59:22 2007 +0200
+++ b/examples/TestMasterSlave/TestMaster.c	Thu Sep 27 09:42:51 2007 +0200
@@ -24,9 +24,14 @@
 /* Declaration of the value range types                                   */
 /**************************************************************************/
 
+#define valueRange_EMC 0x9F /* Type for index 0x1003 subindex 0x00 (only set of value 0 is possible) */
 UNS32 TestMaster_valueRangeTest (UNS8 typeValue, void * value)
 {
   switch (typeValue) {
+    case valueRange_EMC:
+      if (*(UNS8*)value < (UNS8)0) return OD_VALUE_TOO_LOW;
+      if (*(UNS8*)value > (UNS8)0) return OD_VALUE_TOO_HIGH;
+      break;
   }
   return 0;
 }
@@ -79,7 +84,7 @@
                      };
                     subindex TestMaster_Index1003[] = 
                      {
-                       { RW, uint8, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1003 },
+                       { RW, valueRange_EMC, sizeof (UNS8), (void*)&TestMaster_highestSubIndex_obj1003 },
                        { RO, uint32, sizeof (UNS32), (void*)&TestMaster_obj1003[0] }
                      };
 
--- a/examples/TestMasterSlave/TestSlave.c	Thu Sep 27 08:59:22 2007 +0200
+++ b/examples/TestMasterSlave/TestSlave.c	Thu Sep 27 09:42:51 2007 +0200
@@ -24,9 +24,14 @@
 /* Declaration of the value range types                                   */
 /**************************************************************************/
 
+#define valueRange_EMC 0x9F /* Type for index 0x1003 subindex 0x00 (only set of value 0 is possible) */
 UNS32 TestSlave_valueRangeTest (UNS8 typeValue, void * value)
 {
   switch (typeValue) {
+    case valueRange_EMC:
+      if (*(UNS8*)value < (UNS8)0) return OD_VALUE_TOO_LOW;
+      if (*(UNS8*)value > (UNS8)0) return OD_VALUE_TOO_HIGH;
+      break;
   }
   return 0;
 }
@@ -67,7 +72,7 @@
                      };
 
 /* index 0x1003 :   Pre-defined Error Field. */
-                    UNS8 TestSlave_highestSubIndex_obj1003 = 8; /* number of subindex - 1*/
+                    UNS8 TestSlave_highestSubIndex_obj1003 = 0; /* number of subindex - 1*/
                     UNS32 TestSlave_obj1003[] = 
                     {
                       0x0,	/* 0 */
@@ -93,7 +98,7 @@
                      };
                     subindex TestSlave_Index1003[] = 
                      {
-                       { RW, uint8, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1003 },
+                       { RW, valueRange_EMC, sizeof (UNS8), (void*)&TestSlave_highestSubIndex_obj1003 },
                        { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1003[0] },
                        { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1003[1] },
                        { RO, uint32, sizeof (UNS32), (void*)&TestSlave_obj1003[2] },
--- a/objdictgen/gen_cfile.py	Thu Sep 27 08:59:22 2007 +0200
+++ b/objdictgen/gen_cfile.py	Thu Sep 27 09:42:51 2007 +0200
@@ -107,8 +107,8 @@
     valueRangeContent = ""
     strDefine = "\n#define valueRange_EMC 0x9F /* Type for index 0x1003 subindex 0x00 (only set of value 0 is possible) */"
     strSwitch = """    case valueRange_EMC:
-      if (*(UNS8*)Value < (UNS8)0) return OD_VALUE_TOO_LOW;
-      if (*(UNS8*)Value > (UNS8)0) return OD_VALUE_TOO_HIGH;
+      if (*(UNS8*)value < (UNS8)0) return OD_VALUE_TOO_LOW;
+      if (*(UNS8*)value > (UNS8)0) return OD_VALUE_TOO_HIGH;
       break;\n"""
     internal_types["valueRange_EMC"] = ("UNS8", "", "valueRange_EMC")
     num = 0
@@ -125,8 +125,8 @@
             maxvalue = str(Node.GetEntry(index, 3))
             strDefine += "\n#define valueRange_%d 0x%02X /* Type %s, %s < value < %s */"%(num,index,typeinfos[0],minvalue,maxvalue)
             strSwitch += """    case valueRange_%d:
-      if (*(%s*)Value < (%s)%s) return OD_VALUE_TOO_LOW;
-      if (*(%s*)Value > (%s)%s) return OD_VALUE_TOO_HIGH;
+      if (*(%s*)value < (%s)%s) return OD_VALUE_TOO_LOW;
+      if (*(%s*)value > (%s)%s) return OD_VALUE_TOO_HIGH;
       break;\n"""%(num,typeinfos[0],typeinfos[0],minvalue,typeinfos[0],typeinfos[0],maxvalue)
 
     valueRangeContent += strDefine