Unreachable Peer and Address out of range when reading Siemens S7-1500 PLC using Python

263 views Asked by At

When I'm reading PLC (Siemens S7-1500) data using Profinet protocol in Python, it's getting 'Unreachable peer' and enter image description here'Address out of range' errors. So, I can't read the values. Why is this?

Here I'm adding a part of the Python code. I'm not revealing my IP address but it is accessible.

import snap7
from snap7.exceptions import Snap7Exception

rack = 0
slot = 1

def profinet(plc_ip_address, rack, slot, r_db_number, Plant, Packet):
    while True:
        try:
            # Connect to the PLC
            plc = snap7.client.Client()
            plc.connect(plc_ip_address, rack, slot, 102)

I did the same process for Siemens S7-300 PLC and read the values. I just changed the IP, Rack=0, Slot=1 in the program. But its continuously giving these errors.

1

There are 1 answers

0
PiotrBzdrega On

Snap7 is just simple S7-protocol connection via TCP/IP (it is not Profinet tool).
Those two are important:

  1. Please check if PUT/GET communication is enabled.
  2. If you polling DB, make sure that it doesn't have optimized access.