def StartTcpServer(context, identity=None, address=None, console=False, **kwargs):
 from twisted.internet import reactor
 address = (address or ('', Defaults.Port))
 framer = ModbusSocketFramer
 factory = ModbusServerFactory(context, framer, identity, **kwargs)
 if console:
  from pymodbus.internal.ptwisted import InstallManagementConsole
  InstallManagementConsole({'factory': factory})
 _logger.info(('Starting Modbus TCP Server on %s:%s' % address))
 reactor.listenTCP(address[1], factory, interface=address[0])
 reactor.run()

def StartTcpServer ( context , identity = None , address = None , console = False , ** kwargs ) : from twisted . internet import reactor address = ( address or ( '' , Defaults . Port ) ) framer = ModbusSocketFramer factory = ModbusServerFactory ( context , framer , identity , ** kwargs ) if console : from pymodbus . internal . ptwisted import InstallManagementConsole InstallManagementConsole ( { 'factory' : factory } ) _logger . info ( ( 'Starting Modbus TCP Server on %s:%s' % address ) ) reactor . listenTCP ( address [ 1 ] , factory , interface = address [ 0 ] ) reactor . run ( )
a factory to start and run a tcp modbus server .