#!/usr/bin/python
from pymodbus.client.sync import ModbusTcpClient
import time
import sys

i=1 
t_end = time.time() + 60 * 1 # 60s X 1min
while time.time() < t_end:
    client = ModbusTcpClient(sys.argv[1])
    client.write_coils(40, [True, True, True]*4) # Ref #, followed by coil settings in list form
    client.close()
    print '\r>>packet: %d' % i,
    sys.stdout.flush()
    i+=1
print "Done"
