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