Darra Profinet Slave · Python SDK
把 Windows / Linux 主机作为 PROFINET IO 从站设备使用,受主站系统(如西门子 PLC)控制:RT Class 1 实时周期,DCP 设备发现 / 命名 / 地址分配,过程数据 IO,报警与诊断(含 I&M),GSDML 导入 TIA V15+;SDK 以服务模式使用。
Use a Windows or Linux host as a PROFINET IO device under a master (e.g. a Siemens PLC) — RT Class 1, DCP, process-data IO, alarms and diagnostics (I&M), GSDML for TIA V15+. The SDK is used in service mode.
能力 · Capabilities
- 从站设备 — Windows / Linux 主机作为 PROFINET IO Device,受 PLC 等主站控制
- 实时周期 — RT Class 1
- 发现与组态 — DCP 发现 / 命名 / 地址;GSDML 导入 TIA V15+
- 过程数据 — 写 Q、读 I;报警、诊断、I&M
- 0 拷贝 — 过程映像映射成结构体,供高性能直接读写(读可并发;写请调用方串行化)
开始 · Get started
- 先安装官方安装包:下载页 · https://download.darra.xyz/profinet/client/Darra-Profinet-Setup.exe
- 本包是 Python SDK:
pip install darra-profinet-slave
升级 / 重装:先卸载旧版 → 重启电脑 → 再安装新版。操作前请先保存好工程和配置文件。
Linux · 服务模式
Windows / Linux 是同一套 API。Linux 上的服务由 systemd 单元管理(全系统唯一单元
darra-pns,由运行时安装包交付),SDK 不复制服务逻辑:
-
查状态 —
is_service_ready()/service_connected()只读本机127.0.0.1:18840;服务未运行时返回False,last_error()给出systemctl提示,不会替你拉起已停止的单元。 -
显式启动 —
PnSService().start()执行systemctl start darra-pns。无权限时异常带 systemctl stderr 原文与 polkit 授权提示;驱动未装(/dev/darrart_pns缺失)时单元会被 systemd 条件跳过,异常里如实指出。 -
停止从站 —
svc.stop()/stop_checked()走POST /api/stop,服务端要求本机内部密钥config/.internal-api。Linux 上该文件是LinuxDataProtection(HKDF-SHA256 + AES-256-GCM)密文,解密需要可选依赖(未安装时stop_checked()返回PnSErr.NOT_AVAILABLE,last_service_error带安装命令;密钥读不到时带文件路径与systemctl status darra-pns):pip install 'Darra-Profinet-Slave[linux-service]'
-
运维动作 — 停止 / 重启服务不经 SDK:
sudo systemctl stop|restart|status darra-pns。
错误码:NO_DEVICE = 服务未运行或 systemctl 启动失败(last_error() 含 stderr 原文);NOT_AVAILABLE = 缺解密依赖或内部密钥不可读。
最佳用法 · 0 拷贝
Start 后把 I / Q 映射成结构体,之后当普通变量读写即可——读是当前周期,写下个周期发出。
import ctypes
from darra_pns import PnSService
class FromPlc(ctypes.BigEndianStructure): # I:控制器 → 设备
_pack_ = 1
_fields_ = [("present", ctypes.c_uint8),
("recipe", ctypes.c_int16)]
class ToPlc(ctypes.BigEndianStructure): # Q:设备 → 控制器
_pack_ = 1
_fields_ = [("ready", ctypes.c_uint8),
("busy", ctypes.c_uint8)]
svc = PnSService() # 构造随时可调
svc.start() # 启动服务 + 建立过程数据通道
inp = svc.process_data.inputs_mapping(FromPlc) # 映射一次(I 只读)
outp = svc.process_data.outputs_mapping(ToPlc) # 映射一次(Q 可写)
outp.ready = 1 # 写下的下个周期发出
present = inp.present # 读到的永远是当前周期
要整段一次读出用 svc.read()(一次调用取一份,同一拍自洽)。
i = svc.read() # I 区整段字节
连本机服务 127.0.0.1:18840,启动后读 connected,再读诊断里的 iocr_active 和 rx_rt_frames。
from darra_pns import PnSService
svc = PnSService() # 本机服务 127.0.0.1:18840
svc.start()
print(svc.connected)
diag = svc.diag_snapshot
print(diag.connected, diag.iocr_active, diag.rx_rt_frames)
变量表 · Variables
从运行配置 XML 解析变量名→地址映射,支持层级前缀联想:
svc.set_config_xml("config.xml")
vars = svc.variables
print(vars.count)
v = svc.get_variable("Module1.Sub1.Item1")
list = svc.suggest_variables("Module1.")
API 速查 · API Reference
| 属性 | 类型 | 类别 | 读写 |
|---|---|---|---|
connected |
bool |
状态 | 只读 |
state |
PnSState |
状态 | 只读 |
is_running |
bool |
状态 | 只读 |
wait_reason |
str |
状态 | 只读 |
error_code |
PnSRuntimeErrorCode |
诊断 | 只读 |
error_message |
str |
诊断 | 只读 |
process_data |
ProcessData |
过程数据 | 只读 |
alarms |
list[PnSServiceAlarm] |
报警 | 只读 |
alarm_count |
int |
报警 | 只读 |
events |
PnSEvents |
事件 | 只读 |
variables |
PnSVariables |
变量 | 只读 |
其它语言 · Other SDKs
| 语言 / Language | 包 / Package | 来源 / Source |
|---|---|---|
| C | darra_profinet_c-win-x64.zip |
下载页 |
| C++ | darra_profinet_cpp-win-x64.zip |
下载页 |
| C# | Darra.Profinet.Slave |
NuGet |
| Java | xyz.darra:darra-profinet-slave |
Maven Central |
| Python | darra-profinet-slave |
PyPI(本包 / this SDK) |
| Rust | darra-profinet-slave |
crates.io |
许可 · License
专有软件 · Proprietary — © Darra Technology,使用须遵守随产品提供的许可协议。
Metadata
Release files for Darra-Profinet-Slave 1.6.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| darra_profinet_slave-1.6.1-cp312-cp312-win_amd64.whl | CPython 3.12 | CPython 3.12 | Windows x86-64 | Details for darra_profinet_slave-1.6.1-cp312-cp312-win_amd64.whl |
Release files / darra_profinet_slave-1.6.1-cp312-cp312-win_amd64.whl
| Download URL | darra_profinet_slave-1.6.1-cp312-cp312-win_amd64.whl |
|---|---|
| Size | 25.8 MB |
| Tags | CPython 3.12 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
b6ac1947a1316eac2cb37d473cd8d8ccbbb139a09ac1dda90575880fe3b0646c
|
|
BLAKE2b-256 checksum How to use checksums |
d657de042bcb2f96790db6b6c6006a91871de1b7e55db2ace195108bd9571176
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Security for Darra-Profinet-Slave 1.6.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.