Newer
Older
SCADA / modbus / test_hold_int.py
root on 8 May 2022 707 bytes playing with modbus day #1
  1. #!/usr/bin/python
  2. from pyModbusTCP.client import ModbusClient
  3. import time
  4. import sys
  5.  
  6. i=1
  7. client=ModbusClient(host=sys.argv[1],port=502,auto_open=True,auto_close=True,timeout=10)
  8.  
  9. while True:
  10. #client = ModbusTcpClient(sys.argv[1])
  11. #client.write_single_register(0,65535) # ref #, followed by no to store
  12. #client.write_single_register(1,65535) # ref #, followed by no to store
  13. #client.write_single_register(2,0) # ref #, followed by no to store
  14. client.write_single_register(3,0) # ref #, followed by no to store
  15. #client.write_multiple_registers(0, [65535,65535,2,2])
  16. #client.close()
  17. print '\r>>packet: %d' % i,
  18. sys.stdout.flush()
  19. i+=1
  20. time.sleep(0.2)
  21. print "Done"
Buy Me A Coffee