Skip to main content

profinet-py

CI PyPI Python License Code style: ruff CLA

A Python library for PROFINET IO communication, acting as an IO-Controller.

Features

  • DCP Discovery & Configuration: Find devices, set IP/name, signal LEDs, factory reset with full SET response validation
  • DCE/RPC Communication: Establish Application Relationships (AR) and perform acyclic read/write via slot/subslot/index
  • I&M Records: Read/write Identification & Maintenance data (IM0-IM5)
  • Cyclic I/O: Real-time periodic data exchange (RT_CLASS_1) with state machine, double-buffered IO, cycle counter tracking, watchdog fault detection, and graceful shutdown
  • Alarm Handling: Background alarm listener per IEC 61158-6-10
  • Diagnosis Parsing: Channel, extended channel, and qualified channel diagnosis decoding
  • Vendor Registry: 2100+ PROFINET vendor IDs with name lookup
  • Declarative Parsing: Binary protocol parsing via construct library
  • Cross-Platform: Linux (AF_PACKET), Windows (Npcap)
  • High-level API: ProfinetDevice class and scan() for quick device interaction

Requirements

  • Python 3.10+
  • Administrator/root privileges (for raw Ethernet access)
  • construct>=2.10

Platform-specific

Platform Raw Socket Backend Extra Software
Linux AF_PACKET (built-in) None
Windows Npcap (wpcap.dll) Install Npcap with "WinPcap API-compatible Mode" enabled

Installation

pip install profinet-py

From source:

git clone https://github.com/f0rw4rd/profinet-py.git
cd profinet-py
pip install -e ".[dev]"

Usage

import profinet

# Discover all PROFINET devices on the network
for device in profinet.scan("eth0", timeout=5):
    print(f"Found: {device.name} at {device.ip} ({device.mac})")

On Windows, use the adapter's friendly name:

for device in profinet.scan("Ethernet 3", timeout=5):
    print(f"Found: {device.name} at {device.ip}")

Low-level DCP + RPC

from profinet.util import ethernet_socket, get_mac
from profinet.dcp import send_discover, read_response
from profinet.rpc import RPCCon

# Create raw socket on interface
sock = ethernet_socket("eth0")
src_mac = get_mac("eth0")

# Discover PROFINET devices
xid = send_discover(sock, src_mac)
responses = read_response(sock, src_mac, timeout_sec=5, expected_xid=xid)

sock.close()

DCP discovery and GET accept incorrect transaction IDs (XIDs) with a warning by default for compatibility with devices that echo wrong or zero XIDs. This can accept stale replies. Pass strict_xid=True to read_response() (with expected_xid), get_param(), or get_station_info() to reject mismatches. CLI and high-level device discovery use lenient defaults.

CLI

# Discover devices
profinet -i eth0 discover

# Read I&M0 from device
profinet -i eth0 read-inm0 device-name

# Read raw record
profinet -i eth0 read device-name --slot 0 --subslot 1 --index 0xAFF0

# Cyclic IO monitoring (default 32ms cycle)
profinet -i eth0 cyclic device-name --gsdml device.xml

# Custom cycle time
profinet -i eth0 cyclic device-name --gsdml device.xml --cycle-ms 16

# Exclude zero-I/O submodules (device interoperability workaround)
profinet -i eth0 cyclic device-name --gsdml device.xml --exclude-zero-io-submodules

Support

If you find this project useful, consider supporting development:

Ko-fi

License

Dual-licensed under GPL-3.0 and a commercial license.

Free for open source use under GPL-3.0. If you want to use profinet-py in proprietary products without GPL obligations, a commercial license is available — see LICENSE-COMMERCIAL.md for details.

References

Trademarks

All marks belong to their owners; used nominatively to describe interoperability; no endorsement implied.

Metadata

Release files for profinet-py 0.6.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for profinet-py 0.6.5
File Size Uploaded
profinet_py-0.6.5.tar.gz 240.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for profinet-py 0.6.5
File Interpreter ABI Platform
profinet_py-0.6.5-py3-none-any.whl Python 3 none any Details

Total release size: 415.4 kB

Release files / profinet_py-0.6.5.tar.gz

Download URL profinet_py-0.6.5.tar.gz
Size 240.1 kB
Tags Source
SHA-256 checksum
How to use checksums
009a437a9ecc3ed313e89e6fd5520b1ead5cfdc533e8d05007631e2ac2ce4b37
BLAKE2b-256 checksum
How to use checksums
094c7ee5bc2c85c02f2f1cc2b7b7556d873bea16b8b89f4b7b2fc3cf1dc91c1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release files / profinet_py-0.6.5-py3-none-any.whl

Download URL profinet_py-0.6.5-py3-none-any.whl
Size 175.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6d98dd4037b2de6e1b21252600488fe80bc842a361d0c3b78140e60a331de055
BLAKE2b-256 checksum
How to use checksums
1c3286b46acba67845a4d5ec5a25e94d46b939bdcca25996c7f1b11fb6c218c1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 15, 2026.

Transparency log

Release history Release notifications | RSS feed

0.6.6

2 release files

This release

0.6.5 This release

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page