etherlab/CommonEtherCATFunction.py
changeset 2360 2a3d022a7dac
parent 2358 8e5a9830867e
child 2361 5d6ce74f7835
equal deleted inserted replaced
2359:e945fcb54cd4 2360:2a3d022a7dac
    10 
    10 
    11 import os
    11 import os
    12 import wx
    12 import wx
    13 
    13 
    14 mailbox_protocols =  ["AoE", "EoE", "CoE", "FoE", "SoE", "VoE"]
    14 mailbox_protocols =  ["AoE", "EoE", "CoE", "FoE", "SoE", "VoE"]
       
    15 
    15 
    16 
    16 def ExtractHexDecValue(value):
    17 def ExtractHexDecValue(value):
    17     """
    18     """
    18      convert numerical value in string format into decimal or hex format.
    19      convert numerical value in string format into decimal or hex format.
    19      @param value : hex or decimal data
    20      @param value : hex or decimal data
    26     try:
    27     try:
    27         return int(value.replace("#", "0"), 16)
    28         return int(value.replace("#", "0"), 16)
    28 
    29 
    29     except Exception:
    30     except Exception:
    30         raise ValueError, "Invalid value for HexDecValue \"%s\"" % value
    31         raise ValueError, "Invalid value for HexDecValue \"%s\"" % value
       
    32 
    31 
    33 
    32 def ExtractName(names, default=None):
    34 def ExtractName(names, default=None):
    33     """
    35     """
    34      Extract "name" field from XML entries.
    36      Extract "name" field from XML entries.
    35      @param names : XML entry
    37      @param names : XML entry
   133 RESCAN = """
   135 RESCAN = """
   134 import commands
   136 import commands
   135 result = commands.getoutput("ethercat rescan -p %d")
   137 result = commands.getoutput("ethercat rescan -p %d")
   136 returnVal =result
   138 returnVal =result
   137 """
   139 """
       
   140 
   138 
   141 
   139 # --------------------------------------------------
   142 # --------------------------------------------------
   140 #    Common Method For EtherCAT Management
   143 #    Common Method For EtherCAT Management
   141 # --------------------------------------------------
   144 # --------------------------------------------------
   142 class _CommonSlave:
   145 class _CommonSlave: