Raspberry Pi 3 Model B を使用して Allen Bradly PLC から値を読み取ろうとしています。それらの間の通信に Pymodbus Modbus TCP プロトコルを使用しています。
テスト クライアントを実行すると、次のエラーが表示されます。
pi@raspberrypi:/var $ python test1.py
Got here 1
Traceback (most recent call last):
File "test1.py", line 12, in <module>
request = client.read_holding_registers(0,1)
File "build/bdist.linux-armv7l/egg/pymodbus/client/common.py", line 109, in read_holding_registers
File "build/bdist.linux-armv7l/egg/pymodbus/client/sync.py", line 82, in execute
pymodbus.exceptions.ConnectionException: Modbus Error: [Connection] Failed to connect[10.0.0.237:502]
テスト クライアントのコードは次のとおりです。
from pymodbus.client.sync import ModbusTcpClient
#modbus connection
client = ModbusTcpClient(host='10.0.0.237')
connection = client.connect()
#test print
print "Got here 1"
#read register
request = client.read_holding_registers(0,1)
print request
client.close()
PLC のイーサネット カード (10.0.0.237) の IP アドレスに問題なく ping を実行できます。(PLC はオンで、RSLinx と RSLogix5000 に表示されます。)しかし、コマンドでポート 502 (Modbus が使用する) をチェックしようとすると:
telnet 10.0.0.237 502
エラーが発生します:
Trying 10.0.0.237...
telnet: Unable to connect to remote host: Connection refused
私が行った調査では、そのポートが開いているかどうかを確認するように言われましたが、それは PC の場合です。PLC のポートを確認/構成する方法がわかりません。
さらに、Modbus を使用して Raspbery Pi と PLC の間を移動しようとしていることが問題なのかどうか疑問に思っています。インターフェイスを行うプロソフト ゲートウェイを見つけました。しかし、それらが単なる別のオプションなのか、必要なのかについての情報は見つかりませんでした。
私はPLCとネットワークに慣れていないので、助けていただければ幸いです。