Skip to main content

Python bindings for libiec61850 - IEC 61850 protocol implementation

Project description

pyiec61850-ng

This library is experimental. Use at your own risk. No warranty of any kind is provided.

Next Generation Python bindings for libiec61850, packaged as a Python wheel.

Build and Test PyPI version Python Versions

This repository provides Python bindings for the libiec61850 library, which is an open-source implementation of the IEC 61850 standard for communication networks and systems in substations.

Installation

Install from PyPI (Recommended)

pip install pyiec61850-ng

Install from GitHub Release

pip install pyiec61850-ng --find-links https://github.com/f0rw4rd/pyiec61850-ng/releases/latest/download/

Install directly from GitHub

pip install git+https://github.com/f0rw4rd/pyiec61850-ng.git

Install from local wheel

pip install pyiec61850-ng-*.whl

Usage

Quick Start (Recommended - Safe API)

from pyiec61850.mms import MMSClient

# Use context manager for automatic cleanup
with MMSClient() as client:
    client.connect("192.168.1.100", 102)
    print("Connected successfully!")

    # Get server identity
    identity = client.get_server_identity()
    print(f"Server: {identity.vendor} {identity.model}")

    # Discover logical devices
    devices = client.get_logical_devices()
    for device in devices:
        print(f"Device: {device}")

        # Get logical nodes
        nodes = client.get_logical_nodes(device)
        for node in nodes:
            print(f"  Node: {node}")

# Connection automatically closed

Low-Level API

For advanced use cases, you can use the raw bindings directly:

import pyiec61850.pyiec61850 as pyiec61850

# Create and connect to an IEC 61850 server
connection = pyiec61850.IedConnection_create()
error = pyiec61850.IedConnection_connect(connection, "192.168.1.100", 102)

if error == pyiec61850.IED_ERROR_OK:
    print("Connected successfully!")
    # Perform operations...
    pyiec61850.IedConnection_close(connection)

pyiec61850.IedConnection_destroy(connection)

Examples

For comprehensive examples, see the examples directory:

Run examples:

python examples/01_basic_connection.py 192.168.1.100
python examples/02_device_discovery.py 192.168.1.100

Building from Source

The wheel package is built using Docker:

docker build -t pyiec61850-builder --build-arg LIBIEC61850_VERSION=v1.6 .

To extract the wheel file:

mkdir -p ./dist
docker create --name wheel-container pyiec61850-builder
docker cp wheel-container:/wheels/. ./dist/
docker rm wheel-container

Versioning

This package uses the format: LIBIEC61850_VERSION.REVISION

  • Example: 1.6.0.1 = libiec61850 v1.6.0, first package revision
  • 1.6.0: The exact libiec61850 version included (static)
  • .1: Package revision for bug fixes, rebuilds, binding improvements

This clearly shows which libiec61850 version you're getting and our package iteration.

Check current version:

python version.py        # Package version: 1.6.0.1
python version.py --libiec61850  # libiec61850 version: v1.6.0

TASE.2/ICCP Support (Highly Experimental)

Warning: TASE.2 support is highly experimental and may change significantly.

pyiec61850-ng includes support for TASE.2 (IEC 60870-6), also known as ICCP (Inter-Control Center Communications Protocol), used for real-time data exchange between control centers in the electric utility industry.

TASE.2 Quick Start

from pyiec61850.tase2 import TASE2Client

client = TASE2Client(
    local_ap_title="1.1.1.999",
    remote_ap_title="1.1.1.998"
)
client.connect("192.168.1.100", port=102)

# Discover domains (VCC/ICC)
domains = client.get_domains()
for domain in domains:
    print(f"Domain: {domain.name} ({domain.domain_type})")

# Read a data point
value = client.read_point("ICC1", "Voltage")
print(f"Value: {value.value}, Quality: {value.quality}")

# Security analysis
security = client.analyze_security()
print(f"Readable points: {security['readable_points']}")
print(f"Concerns: {security['concerns']}")

client.disconnect()

TASE.2 Features

  • Domain Discovery: VCC (Virtual Control Center) and ICC (Indication Control Center)
  • Variable Enumeration: List and read data points with quality information
  • Data Point Access: Read/write individual points or bulk enumeration
  • Transfer Sets (Block 2): RBE (Report-by-Exception) management
  • Device Control (Block 5): Select-Before-Operate, commands, setpoints
  • Bilateral Tables: Access control configuration queries
  • Security Analysis: Automated security assessment and recommendations

TASE.2 Data Types

from pyiec61850.tase2 import (
    Domain,          # VCC/ICC domain
    PointValue,      # Data point with value and quality
    TransferSet,     # Block 2 transfer set
    BilateralTable,  # Access control table
    ServerInfo,      # Server information
)

MMS Module (Safe Wrappers)

The pyiec61850.mms module provides safe Python wrappers around the raw SWIG bindings, preventing common crashes from NULL pointer dereferences and memory leaks.

Why Use the Safe Wrappers?

The raw pyiec61850 bindings require careful memory management:

  • LinkedList_destroy() must be called after iteration
  • MmsValue_delete() must be called after reading values
  • toCharP() crashes on NULL pointers

The MMS module handles all of this automatically.

MMS Client Example

from pyiec61850.mms import MMSClient, ConnectionFailedError

with MMSClient() as client:
    try:
        client.connect("192.168.1.100", 102)

        # All memory management is automatic
        for device in client.get_logical_devices():
            for node in client.get_logical_nodes(device):
                print(f"{device}/{node}")

    except ConnectionFailedError as e:
        print(f"Connection failed: {e}")

Safe Utilities for Raw Bindings

If you need to use raw bindings, use the safe utilities:

from pyiec61850.mms.utils import (
    safe_to_char_p,        # NULL-safe string conversion
    LinkedListGuard,       # Auto-cleanup context manager
    MmsValueGuard,         # Auto-cleanup for MmsValue
)
import pyiec61850.pyiec61850 as iec61850

# Safe iteration with automatic cleanup
result = iec61850.IedConnection_getLogicalDeviceList(connection)
device_list, error = result

with LinkedListGuard(device_list) as guard:
    for device_name in guard:  # NULL pointers automatically skipped
        print(device_name)
# LinkedList automatically destroyed

License

This project is licensed under the GNU General Public License v3.0 (GPLv3) - see the LICENSE file for details.

Third-Party Components

  • libiec61850 by MZ Automation GmbH - GPLv3 (commercial license available)
  • Mbed TLS - Apache License 2.0

The compiled libiec61850.so and SWIG bindings included in wheel distributions are built from the libiec61850 source code. See the NOTICE file for full attribution details.

For commercial use cases where GPLv3 is not suitable, a commercial license for libiec61850 is available from MZ Automation GmbH.

Trademarks

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyiec61850_ng-1.6.1.4-cp314-cp314-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.14Windows x86-64

pyiec61850_ng-1.6.1.4-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.26+ x86-64manylinux: glibc 2.28+ x86-64

pyiec61850_ng-1.6.1.4-cp313-cp313-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.13Windows x86-64

pyiec61850_ng-1.6.1.4-cp313-cp313-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.26+ x86-64manylinux: glibc 2.28+ x86-64

pyiec61850_ng-1.6.1.4-cp312-cp312-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.12Windows x86-64

pyiec61850_ng-1.6.1.4-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.26+ x86-64manylinux: glibc 2.28+ x86-64

pyiec61850_ng-1.6.1.4-cp311-cp311-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.11Windows x86-64

pyiec61850_ng-1.6.1.4-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.26+ x86-64manylinux: glibc 2.28+ x86-64

pyiec61850_ng-1.6.1.4-cp310-cp310-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.10Windows x86-64

pyiec61850_ng-1.6.1.4-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.26+ x86-64manylinux: glibc 2.28+ x86-64

pyiec61850_ng-1.6.1.4-cp39-cp39-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.9Windows x86-64

pyiec61850_ng-1.6.1.4-cp39-cp39-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.26+ x86-64manylinux: glibc 2.28+ x86-64

File details

Details for the file pyiec61850_ng-1.6.1.4-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.4-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 8d57ef95879446901b200a264e9ccfdb0da1c67f814e076677f8120af646c999
MD5 3ac194db4252ee84a1075d2885ffdab1
BLAKE2b-256 5a2d6c16229208c0017ab8f04fc4ecd4ee1ae3b47d01b5c8270bd5ecc1846341

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.4-cp314-cp314-win_amd64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.4-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.4-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 de01dd29e9380709ffd9f957d99678955546b9a3ca8a9040c34272649212ddf3
MD5 eb7be69ec184379db1d8a60a8cb4d963
BLAKE2b-256 08210b77916962f213dc54d2c27bb7d8d46ee927964fe6757ac1de129f2e8e7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.4-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.4-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 0158f0a45d4360dc104fb220fbf1bcc2fa134a1df0211f868959a6cbb02b2e12
MD5 451905e836bd42e332cf0c03180d693a
BLAKE2b-256 dc835c367b9a13ddbe9fca5041eea8448cc372f854cfebb4bf52c5f751454f86

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.4-cp313-cp313-win_amd64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.4-cp313-cp313-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.4-cp313-cp313-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 762de0ca257261936a55f78dd65f818511efa774760cebce7e9a4bda85f34519
MD5 20aad181f1d3405dae1dffd0da1e5c30
BLAKE2b-256 8633a7ce881f4c900ea8424be5cbb00cbe5ab42dc9c3cc0f1a3368e7073b6d30

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.4-cp313-cp313-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.4-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 40e821830829f90a975e86fc218a3ade3055e4c0a01b5b60f2fa8bc4a9ba23f3
MD5 af2b31cd96d7b372ab3538cfeebfc43b
BLAKE2b-256 3ee70debff075731313b447a6e4c635458d53baccaa1732d45571247fc23f1d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.4-cp312-cp312-win_amd64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.4-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.4-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8604d0f386390ce1e612471779ed0b2a9a7ecff6546e737cdaa21b736b57048c
MD5 c480156eb2d8f485cf6b6dee30a46038
BLAKE2b-256 3d6a6c3ac61e92bcb56e61a3b512e1ae2ed966a26a006c74444678dbe97ae597

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.4-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.4-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 fa08bf159dc905ae095685d09c4f84b3ae4cd168ce6ba8055485e349019c2275
MD5 4e450c84e6f0b617c205da79bf5e76d4
BLAKE2b-256 182e3dc4ca6d3a02dda4638193619b3b99013996bd46f2e87ba8f0567fe8a924

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.4-cp311-cp311-win_amd64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.4-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.4-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0f5fef6087314720675b7d17273776d50b66b762d3205e4ada13daacf1b978d8
MD5 7530a708a8c2c3c8fdbe218fc1870388
BLAKE2b-256 a4f626b1f5c276dbc6956a3142d718f3bdeb87713ebe9d7cb9fef5d6f83fa15e

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.4-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.4-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 112fe2916211426acc222e4ef1694f676b109287341a1acd0079442165cd79ff
MD5 45679b20a8328ee12cac113c33f1a251
BLAKE2b-256 2c07c811d2b92c2a1a3237482c14a59cf1d3e6605416bdcb0be10c73ab3bab6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.4-cp310-cp310-win_amd64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.4-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.4-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 14c851ef56a80ea3de0fb76f92f34071f703653812f01a04d6c97a9e6b1be92d
MD5 aabb98c96713ebc949b426aff8e5d589
BLAKE2b-256 08a79ced74cc353f4d3050da520f745be757f80c21cd4bc00ba022542e0cb508

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.4-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.4-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 58055749168e2c4649fdb309f72027283e13cc6b7026eef607b35dd838881b4d
MD5 7880234eccbb0af6a8bec727d78208d5
BLAKE2b-256 2e4f4964b90ad902ce17ed66caaa61f7c729676fb86fb569b37c7dc81cecc2cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.4-cp39-cp39-win_amd64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyiec61850_ng-1.6.1.4-cp39-cp39-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.4-cp39-cp39-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9683a53877046e6400fd98213167392beec25e05c764599043e81dd0095d105d
MD5 32faa4caf4025aa477ea98b13962abc3
BLAKE2b-256 58c3994382e69f00a1f789df21e7e538a348e2da2a9216407b35db999bab58aa

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.4-cp39-cp39-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl:

Publisher: build-wheel.yml on f0rw4rd/pyiec61850-ng

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page