#!/usr/bin/python
from pyModbusTCP.client import ModbusClient
import time
import sys

i=1 
client=ModbusClient(host=sys.argv[1],port=502,auto_open=True,auto_close=True,timeout=10)

while True:
    #client = ModbusTcpClient(sys.argv[1])
    #client.write_single_register(0,65535) # ref #, followed by no to store
    #client.write_single_register(1,65535) # ref #, followed by no to store
    #client.write_single_register(2,0) # ref #, followed by no to store
    client.write_single_register(3,0) # ref #, followed by no to store
    #client.write_multiple_registers(0, [65535,65535,2,2])
    #client.close()
    print '\r>>packet: %d' % i,
    sys.stdout.flush()
    i+=1
    time.sleep(0.2)
print "Done"
