mirror of
https://github.com/brocktice/tristar-python-modbus.git
synced 2025-05-15 06:10:11 -07:00
Converted to take hosts on command line.
This commit is contained in:
parent
b6d56ce312
commit
aa52d6b717
@ -8,6 +8,14 @@
|
||||
import time
|
||||
counter = 0
|
||||
|
||||
import sys
|
||||
|
||||
if len(sys.argv) <= 1:
|
||||
print "Usage: read_registers.py <ip address 1> [ip address 2] ..."
|
||||
exit(1)
|
||||
|
||||
hosts = sys.argv[1:]
|
||||
|
||||
# import the server implementation
|
||||
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
|
||||
|
||||
@ -17,8 +25,6 @@ logging.basicConfig()
|
||||
log = logging.getLogger('./modbus.error')
|
||||
log.setLevel(logging.ERROR)
|
||||
|
||||
hosts = ['192.168.1.2']
|
||||
|
||||
for host in hosts:
|
||||
print "Host %s" % host
|
||||
client = ModbusClient(host,502)
|
||||
|
Loading…
x
Reference in New Issue
Block a user