etherlab/CommonEtherCATFunction.py
changeset 2363 9c7da6ff6a34
parent 2361 5d6ce74f7835
child 2365 bc07b9910cdb
equal deleted inserted replaced
2362:6d31ef14f396 2363:9c7da6ff6a34
   489 
   489 
   490             # get protocol (profile) types supported by mailbox; <Device>-<Mailbox>
   490             # get protocol (profile) types supported by mailbox; <Device>-<Mailbox>
   491             mb = device.getMailbox()
   491             mb = device.getMailbox()
   492             if mb is not None:
   492             if mb is not None:
   493                 for mailbox_protocol in mailbox_protocols:
   493                 for mailbox_protocol in mailbox_protocols:
   494                     if getattr(mb,"get%s" % mailbox_protocol)() is not None:
   494                     if getattr(mb, "get%s" % mailbox_protocol)() is not None:
   495                         smartview_infos["supported_mailbox"] += "%s,  " % mailbox_protocol
   495                         smartview_infos["supported_mailbox"] += "%s,  " % mailbox_protocol
   496             smartview_infos["supported_mailbox"] = smartview_infos["supported_mailbox"].strip(",  ")
   496             smartview_infos["supported_mailbox"] = smartview_infos["supported_mailbox"].strip(",  ")
   497 
   497 
   498             # get standard configuration of mailbox; <Device>-<Sm>
   498             # get standard configuration of mailbox; <Device>-<Sm>
   499             for sm_element in device.getSm():
   499             for sm_element in device.getSm():
   783 
   783 
   784             # get supported mailbox protocols for EEPROM offset 0x0038-0x0039;
   784             # get supported mailbox protocols for EEPROM offset 0x0038-0x0039;
   785             data = 0
   785             data = 0
   786             mb = device.getMailbox()
   786             mb = device.getMailbox()
   787             if mb is not None :
   787             if mb is not None :
   788                 for bit,mbprot in enumerate(mailbox_protocols):
   788                 for bit, mbprot in enumerate(mailbox_protocols):
   789                     if getattr(mb,"get%s" % mbprot)() is not None:
   789                     if getattr(mb, "get%s" % mbprot)() is not None:
   790                         data += 1<<bit
   790                         data += 1<<bit
   791             data = "{:0>4x}".format(data)
   791             data = "{:0>4x}".format(data)
   792             eeprom.append(data[2:4])
   792             eeprom.append(data[2:4])
   793             eeprom.append(data[0:2])
   793             eeprom.append(data[0:2])
   794 
   794 
  1179         mb = device.getMailbox()
  1179         mb = device.getMailbox()
  1180         coe_details = 1  # sdo enabled
  1180         coe_details = 1  # sdo enabled
  1181         if mb is not None :
  1181         if mb is not None :
  1182             coe = mb.getCoE()
  1182             coe = mb.getCoE()
  1183             if coe is not None:
  1183             if coe is not None:
  1184                 for bit,flag in enumerate(["SdoInfo", "PdoAssign", "PdoConfig",
  1184                 for bit, flag in enumerate(["SdoInfo", "PdoAssign", "PdoConfig",
  1185                                            "PdoUpload", "CompleteAccess"]):
  1185                                            "PdoUpload", "CompleteAccess"]):
  1186                     if getattr(coe,"get%s" % flag)() is not None:
  1186                     if getattr(coe, "get%s" % flag)() is not None:
  1187                         coe_details += 1<<bit
  1187                         coe_details += 1<<bit
  1188         eeprom.append("{:0>2x}".format(coe_details))
  1188         eeprom.append("{:0>2x}".format(coe_details))
  1189 
  1189 
  1190         # word 4 : FoE Details and EoE Details
  1190         # word 4 : FoE Details and EoE Details
  1191         #  FoE Details; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<FoE>
  1191         #  FoE Details; <EtherCATInfo>-<Descriptions>-<Devices>-<Device>-<Mailbox>-<FoE>
  1209         ds402ch = False
  1209         ds402ch = False
  1210         if mb is not None :
  1210         if mb is not None :
  1211             coe = mb.getCoE()
  1211             coe = mb.getCoE()
  1212             if coe is not None :
  1212             if coe is not None :
  1213                 ds402ch = coe.getDS402Channels()
  1213                 ds402ch = coe.getDS402Channels()
  1214         eeprom.append("01" if ds402ch in [True,1] else "00")
  1214         eeprom.append("01" if ds402ch in [True, 1] else "00")
  1215 
  1215 
  1216         # word 6 : SysmanClass(reserved) and Flags
  1216         # word 6 : SysmanClass(reserved) and Flags
  1217         eeprom.append("00")  # reserved
  1217         eeprom.append("00")  # reserved
  1218         #  Flags
  1218         #  Flags
  1219         en_safeop = False
  1219         en_safeop = False
  1304         @param device : 'device' object in the slave ESI XML
  1304         @param device : 'device' object in the slave ESI XML
  1305         @return eeprom : "Strings" category EEPROM image data
  1305         @return eeprom : "Strings" category EEPROM image data
  1306         """
  1306         """
  1307         eeprom = []
  1307         eeprom = []
  1308         data = ""
  1308         data = ""
  1309         number = {"MBoxOut":"01", "MBoxIn":"02", "Outputs":"03", "Inputs":"04"}
  1309         number = {"MBoxOut": "01", "MBoxIn": "02", "Outputs": "03", "Inputs": "04"}
  1310 
  1310 
  1311         for sm in device.getSm():
  1311         for sm in device.getSm():
  1312             for attr in [sm.getStartAddress(),
  1312             for attr in [sm.getStartAddress(),
  1313                          sm.getDefaultSize(),
  1313                          sm.getDefaultSize(),
  1314                          sm.getControlByte()]:
  1314                          sm.getControlByte()]: