Discovery

PROFINET DCP network discovery for finding Siemens PLCs.

Uses the pnio-dcp library for the underlying DCP protocol. Install with: pip install python-snap7[discovery]

class snap7.discovery.Device(name: str, ip: str, mac: str, netmask: str = '', gateway: str = '', family: str = '')[source]

Bases: object

A discovered PROFINET device on the network.

family: str = ''
gateway: str = ''
ip: str
mac: str
name: str
netmask: str = ''
snap7.discovery.discover(ip: str, timeout: float = 5.0) list[Device][source]

Discover PROFINET devices on the network using DCP Identify All.

Parameters:
  • ip – IP address of the local network interface to use for discovery.

  • timeout – How long to listen for responses in seconds (default 5.0).

Returns:

List of discovered devices.

Raises:
  • ImportError – If pnio-dcp is not installed.

  • NotImplementedError – If the current platform is not supported by pnio-dcp.

snap7.discovery.identify(ip: str, mac: str) Device[source]

Identify a specific device by MAC address.

Parameters:
  • ip – IP address of the local network interface to use.

  • mac – MAC address of the target device (colon-separated, e.g. “00:1b:1b:12:34:56”).

Returns:

The identified device.

Raises:
  • ImportError – If pnio-dcp is not installed.

  • TimeoutError – If the device does not respond.