modbus/modbus.py
changeset 2669 be233279d179
parent 2663 54f5b8e5c8d2
child 2677 556935640ec0
equal deleted inserted replaced
2668:cca3e5d7d6f3 2669:be233279d179
    28 from six.moves import xrange
    28 from six.moves import xrange
    29 
    29 
    30 from modbus.mb_utils import *
    30 from modbus.mb_utils import *
    31 from ConfigTreeNode import ConfigTreeNode
    31 from ConfigTreeNode import ConfigTreeNode
    32 from PLCControler import LOCATION_CONFNODE, LOCATION_VAR_MEMORY
    32 from PLCControler import LOCATION_CONFNODE, LOCATION_VAR_MEMORY
       
    33 import util.paths as paths
    33 
    34 
    34 base_folder = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0]
    35 base_folder = os.path.split(os.path.dirname(os.path.realpath(__file__)))[0]
    35 base_folder = os.path.join(base_folder, "..")
    36 base_folder = os.path.join(base_folder, "..")
    36 ModbusPath = os.path.join(base_folder, "Modbus")
    37 ModbusPath = os.path.join(base_folder, "Modbus")
    37 
    38 
   983         # Target is ARM with linux and not win on x86 so winsock2 (ws2_32) library is useless !!!
   984         # Target is ARM with linux and not win on x86 so winsock2 (ws2_32) library is useless !!!
   984         # if os.name == 'nt':   # other possible values: 'posix' 'os2' 'ce' 'java' 'riscos'
   985         # if os.name == 'nt':   # other possible values: 'posix' 'os2' 'ce' 'java' 'riscos'
   985         # LDFLAGS.append(" -lws2_32 ")  # on windows we need to load winsock
   986         # LDFLAGS.append(" -lws2_32 ")  # on windows we need to load winsock
   986         # library!
   987         # library!
   987 
   988 
   988         return [(Gen_MB_c_path, ' -I"' + ModbusPath + '"')], LDFLAGS, True
   989         websettingfile = open(paths.AbsNeighbourFile(__file__, "web_settings.py"), 'r')
       
   990         websettingcode = websettingfile.read()
       
   991         websettingfile.close()
       
   992 
       
   993         location_str = "_".join(map(str, self.GetCurrentLocation()))
       
   994         websettingcode = websettingcode % locals()
       
   995 
       
   996         runtimefile_path = os.path.join(buildpath, "runtime_modbus_websettings.py")
       
   997         runtimefile = open(runtimefile_path, 'w')
       
   998         runtimefile.write(websettingcode)
       
   999         runtimefile.close()
       
  1000 
       
  1001         return ([(Gen_MB_c_path, ' -I"' + ModbusPath + '"')], LDFLAGS, True,
       
  1002                 ("runtime_modbus_websettings_%s.py" % location_str, open(runtimefile_path, "rb")),
       
  1003         )