Modbus TCP/IP経由でpymodbusを使用して、リクエストを作成し、正しい方法でレスポンスを取得する方法を誰かが説明できますか?
PLC をスレーブとして使用し、PC をマスターとして使用します。
私はそのような方法でそれをやろうとしています:
from pymodbus.client.sync import ModbusTcpClient
host = '192.168.56.9'
port = 502
client = ModbusTcpClient(host, port)
client.connect()
#Register address 0x102A (4138dec) with a word count of 1
#Value - MODBUS/TCP Connections
#Access - Read
#Description - Number of TCP connections
request = client.read_holding_registers(4138, 1)
response = client.execute(request)
print response
>>> ReadRegisterResponse (1)