Fixed automatic SDO server creation for slave
authoretisserant
Sat, 28 Jun 2008 18:43:15 +0200
changeset 492 b919a24a45cb
parent 491 2ad3dedf6c6a
child 493 a204a86a71f1
Fixed automatic SDO server creation for slave
Automatic PDO creation for slave
Remove PDO from EDS when mapping not defined
objdictgen/eds_utils.py
objdictgen/nodemanager.py
--- a/objdictgen/eds_utils.py	Thu Jun 26 11:38:59 2008 +0200
+++ b/objdictgen/eds_utils.py	Sat Jun 28 18:43:15 2008 +0200
@@ -516,6 +516,14 @@
     optionals = []
     manufacturers = []
     
+    # Remove all unused PDO
+    for entry in entries[:]:
+        if 0x1600 <= entry < 0x1800 or 0x1A00 <= entry < 0x1C00:
+            subentry_value = Node.GetEntry(entry, 1)
+            if subentry_value is None or subentry_value == 0:
+                entries.remove(entry)
+                entries.remove(entry - 0x200)
+                
     # For each entry, we generate the entry section or sections if there is subindexes
     for entry in entries:
         # Extract infos and values for the entry
--- a/objdictgen/nodemanager.py	Thu Jun 26 11:38:59 2008 +0200
+++ b/objdictgen/nodemanager.py	Sat Jun 28 18:43:15 2008 +0200
@@ -200,6 +200,7 @@
             self.CurrentNode.SetNodeType(type)
             self.CurrentNode.SetNodeDescription(description)
             AddIndexList = self.GetMandatoryIndexes()
+            AddSubIndexList = []
             if NMT == "NodeGuarding":
                 AddIndexList.extend([0x100C, 0x100D])
             elif NMT == "Heartbeat":
@@ -227,12 +228,22 @@
                     AddIndexList.extend([0x1021, 0x1022])
             if type == "slave":
                 # add default SDO server
-                AddIndexList.extend([0x1280])
+                AddIndexList.append(0x1200)
+                # add default 4 receive and 4 transmit PDO
+                for comm, mapping in [(0x1400, 0x1600),(0x1800, 0x1A00)]:
+                    firstparamindex = self.GetLineFromIndex(comm)
+                    firstmappingindex = self.GetLineFromIndex(mapping)
+                    AddIndexList.extend(range(firstparamindex, firstparamindex + 4))
+                    for idx in range(firstmappingindex, firstmappingindex + 4):
+                        AddIndexList.append(idx)
+                        AddSubIndexList.append((idx, 8))
             # Add a new buffer 
             index = self.AddNodeBuffer(self.CurrentNode.Copy(), False)
             self.SetCurrentFilePath("")
             # Add Mandatory indexes
             self.ManageEntriesOfCurrent(AddIndexList, [])
+            for idx, num in AddSubIndexList:
+                self.AddSubentriesToCurrent(idx, num)
             return index
         else:
             return result