我在这里有一个 python 代码来读取输入寄存器并且它正在工作,但它没有在 HMI Droid Studio 应用程序中显示寄存器。这是代码:
from pymodbus.client.sync import ModbusTcpClient as ModbusClient
import time
Kanban1 = 0
#Open TCP Port
#client = Modbus ('192.168.43.136')
client = ModbusClient ('192.168.4.189')
client.connect()
rq = client.write_register(0,100)
try:
while True:
rr = client.read_holding_registers(0,50)
print rr.registers
if(rr.registers[Kanban1] < 100):
print "Reading Registers"
time.sleep(1)
except KeyboardInterrupt:
client.close()
print "Finish"
任何帮助表示感谢谢谢