Pymodbus Failed to Connect with PLC Slave and Raspberry Pi Master
<p>I am trying to use a Raspberry Pi 3 Model B to read values from an Allen Bradly PLC. I'm using the Pymodbus Modbus TCP protocol to communicate between them.</p>

<p>When I run a test client I get the following error:</p>

<pre><code>pi@raspberrypi:/var $ python test1.py
Got here 1
Traceback (most recent call last):
File "test1.py", line 12, in &lt;module&gt;
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]
</code></pre>

<p>Here is the code for the test client:</p>

<pre><code>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()
</code></pre>

<p>I can ping the IP address of the PLC's ethernet card (10.0.0.237) just fine. (The PLC is on and shows up in RSLinx and RSLogix5000.) But when I try to check port 502 (which Modbus uses) with the command:</p>

<pre><code>telnet 10.0.0.237 502
</code></pre>

<p>I get the error:</p>

<pre><code>Trying 10.0.0.237...
telnet: Unable to connect to remote host: Connection refused
</code></pre>

<p>The research I've done told me to check whether that port is open, but that is for PCs, I don't know how you check/configure the ports on a PLC.</p>

<p>In addition, I am wondering if the problem is that I am trying to just use Modbus to go between the Raspbery Pi and PLC. I have found prosoft gateways that do the interfacing. But I couldn't find any information on whether those were just another option or whether they were required.</p>

<p>I am new to PLCs and networking, so any help would be appreciated.</p>