SHARE
TWEET

Untitled

a guest Oct 16th, 2016 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2. from pymodbus.client.sync import ModbusSerialClient as ModbusClient
  3. import time
  4. import sys
  5.  
  6. start = int(sys.argv[1])
  7. count = int(sys.argv[2])
  8.  
  9. client = ModbusClient(method='rtu', port='/dev/ttyUSB0', baudrate=9600, stopbits=1, parity='N', bytesize=8, timeout=1)
  10.  
  11. connect = client.connect()
  12.  
  13. while True:
  14.         rr = client.read_holding_registers(start,count)
  15.         file = open("logs/energy.txt", "w")
  16.         file.write(str(rr.registers))
  17.         file.close()
  18.         time.sleep(5)
  19.  
  20. client.close()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top