etherlab/EthercatMaster.py
changeset 2358 8e5a9830867e
parent 2356 c26e0c66d8d5
child 2360 2a3d022a7dac
equal deleted inserted replaced
2357:7c67286cddbe 2358:8e5a9830867e
   659                             vars.append({"name": "0x%4.4x-0x%2.2x: %s" % (index, subindex, entry["Name"]),
   659                             vars.append({"name": "0x%4.4x-0x%2.2x: %s" % (index, subindex, entry["Name"]),
   660                                          "type": var_class,
   660                                          "type": var_class,
   661                                          "size": var_size,
   661                                          "size": var_size,
   662                                          "IEC_type": entry["Type"],
   662                                          "IEC_type": entry["Type"],
   663                                          "var_name": "%s_%4.4x_%2.2x" % ("_".join(device_name.split()), index, subindex),
   663                                          "var_name": "%s_%4.4x_%2.2x" % ("_".join(device_name.split()), index, subindex),
   664                                          "location": "%s%s%s"%(var_dir, var_size, ".".join(map(str, current_location +
   664                                          "location": "%s%s%s" % (var_dir, var_size, ".".join(map(str, current_location +
   665                                                                                                     (index, subindex)))),
   665                                                                                                     (index, subindex)))),
   666                                          "description": "",
   666                                          "description": "",
   667                                          "children": []})
   667                                          "children": []})
   668 
   668 
   669         return vars
   669         return vars
   701     def _Generate_C(self, buildpath, locations):
   701     def _Generate_C(self, buildpath, locations):
   702         current_location = self.GetCurrentLocation()
   702         current_location = self.GetCurrentLocation()
   703         # define a unique name for the generated C file
   703         # define a unique name for the generated C file
   704         location_str = "_".join(map(lambda x:str(x), current_location))
   704         location_str = "_".join(map(lambda x:str(x), current_location))
   705 
   705 
   706         Gen_Ethercatfile_path = os.path.join(buildpath, "ethercat_%s.c"%location_str)
   706         Gen_Ethercatfile_path = os.path.join(buildpath, "ethercat_%s.c" % location_str)
   707 
   707 
   708         self.FileGenerator = _EthercatCFileGenerator(self)
   708         self.FileGenerator = _EthercatCFileGenerator(self)
   709 
   709 
   710         LocationCFilesAndCFLAGS, LDFLAGS, extra_files = ConfigTreeNode._Generate_C(self, buildpath, locations)
   710         LocationCFilesAndCFLAGS, LDFLAGS, extra_files = ConfigTreeNode._Generate_C(self, buildpath, locations)
   711 
   711 
   736 
   736 
   737         self.FileGenerator.GenerateCFile(Gen_Ethercatfile_path, location_str, self.BaseParams.getIEC_Channel())
   737         self.FileGenerator.GenerateCFile(Gen_Ethercatfile_path, location_str, self.BaseParams.getIEC_Channel())
   738 
   738 
   739         LocationCFilesAndCFLAGS.insert(0,
   739         LocationCFilesAndCFLAGS.insert(0,
   740             (current_location,
   740             (current_location,
   741              [(Gen_Ethercatfile_path, '"-I%s"'%os.path.abspath(self.GetCTRoot().GetIECLibPath()))],
   741              [(Gen_Ethercatfile_path, '"-I%s"' % os.path.abspath(self.GetCTRoot().GetIECLibPath()))],
   742              True))
   742              True))
   743         LDFLAGS.append("-lethercat_rtdm -lrtdm")
   743         LDFLAGS.append("-lethercat_rtdm -lrtdm")
   744 
   744 
   745         return LocationCFilesAndCFLAGS, LDFLAGS, extra_files
   745         return LocationCFilesAndCFLAGS, LDFLAGS, extra_files
   746 
   746