PROFINET IO-Controller library for Python
Project description
profinet-py
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:
ProfinetDeviceclass andscan()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
send_discover(sock, src_mac)
responses = read_response(sock, src_mac, timeout_sec=5)
sock.close()
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
Support
If you find this project useful, consider supporting development:
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file profinet_py-0.6.1.tar.gz.
File metadata
- Download URL: profinet_py-0.6.1.tar.gz
- Upload date:
- Size: 217.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7393fc5ac12219474365863c3e56a659ec7ea388e894e4e5d2a557d7d9d4dbe
|
|
| MD5 |
54ce632cbe086f9e504a9c891aae4471
|
|
| BLAKE2b-256 |
5fa697dc004a8e480ec6ef54a5f12b5cacb961924770e137e1101d7fbb4893e5
|
Provenance
The following attestation bundles were made for profinet_py-0.6.1.tar.gz:
Publisher:
release.yml on f0rw4rd/profinet-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
profinet_py-0.6.1.tar.gz -
Subject digest:
e7393fc5ac12219474365863c3e56a659ec7ea388e894e4e5d2a557d7d9d4dbe - Sigstore transparency entry: 958559123
- Sigstore integration time:
-
Permalink:
f0rw4rd/profinet-py@1f46e41393a8f73c9e3808663f5f8e596108752f -
Branch / Tag:
refs/tags/v0.6.1 - Owner: https://github.com/f0rw4rd
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1f46e41393a8f73c9e3808663f5f8e596108752f -
Trigger Event:
push
-
Statement type:
File details
Details for the file profinet_py-0.6.1-py3-none-any.whl.
File metadata
- Download URL: profinet_py-0.6.1-py3-none-any.whl
- Upload date:
- Size: 166.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e033fbf4e3e49434bcf52e55b357e67de6e8ea01d94672d3972f8dd13ecd9b0
|
|
| MD5 |
8dbe4f6553dd9946570f5932eeaff7e4
|
|
| BLAKE2b-256 |
951ab0cbc4663aa2d9a3c37e483a59041e0e0f32260de83b5c8af6e4beac7890
|
Provenance
The following attestation bundles were made for profinet_py-0.6.1-py3-none-any.whl:
Publisher:
release.yml on f0rw4rd/profinet-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
profinet_py-0.6.1-py3-none-any.whl -
Subject digest:
9e033fbf4e3e49434bcf52e55b357e67de6e8ea01d94672d3972f8dd13ecd9b0 - Sigstore transparency entry: 958559286
- Sigstore integration time:
-
Permalink:
f0rw4rd/profinet-py@1f46e41393a8f73c9e3808663f5f8e596108752f -
Branch / Tag:
refs/tags/v0.6.1 - Owner: https://github.com/f0rw4rd
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@1f46e41393a8f73c9e3808663f5f8e596108752f -
Trigger Event:
push
-
Statement type: