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.7-cp314-cp314-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.14Windows x86-64

pyiec61850_ng-1.6.1.7-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.7-cp313-cp313-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.13Windows x86-64

pyiec61850_ng-1.6.1.7-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.7-cp312-cp312-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.12Windows x86-64

pyiec61850_ng-1.6.1.7-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.7-cp311-cp311-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.11Windows x86-64

pyiec61850_ng-1.6.1.7-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.7-cp310-cp310-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.10Windows x86-64

pyiec61850_ng-1.6.1.7-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.7-cp39-cp39-win_amd64.whl (1.1 MB view details)

Uploaded CPython 3.9Windows x86-64

pyiec61850_ng-1.6.1.7-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.7-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.7-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 19c45e5235e9f42b95e5260118904e47d5255627c8f1c42041076cf94dc24444
MD5 2352d0375cd5819836a2acb44f58c036
BLAKE2b-256 133c02886d92614cf88c6ea08f4e132308f2b787d7c0c539479aaa2e6ac1f4ec

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.7-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.7-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.7-cp314-cp314-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ff65768e59710659d3fe7418019b3f7bdc007890412c01699c2b0e741b374190
MD5 641af2617310dcb99b50b1f26104a00d
BLAKE2b-256 c7a30a0a0ba8afbcad3b098501e2298cdf263d45aa5bde01f7cd28f31d640bae

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.7-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.7-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 adbf4491b7c05175ee1522dcaece2f55f4577b960af372b232f9664bc4da94f7
MD5 b7e472ae18c8e8cc5821d56cc067b5f8
BLAKE2b-256 52aaf38f6d41edc7d0d457cac2561310034150d12bbb8fe786ee0c69555e9edb

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.7-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.7-cp313-cp313-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.7-cp313-cp313-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 96e8df47aa8a6e496734f7adccd19a8a09f3d86411d34a6ce196417190a3196d
MD5 dc5ea2a89d44776e41617eb2c895498e
BLAKE2b-256 cd3688d420c3122c0fc482620bce1818b5659dd6e1e378190c86dd7e67e279e1

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.7-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.7-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 bbf0026c54bc26ff772e383d8fd0137bf65b230dde8b502bc74fbe7e82e639a6
MD5 11e16f99f6549f78fefad6920224d6d4
BLAKE2b-256 de7efb80cafc09c3eb77775ab2ab32014bff8152bcacc406b5a796fba59bcab9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.7-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.7-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.7-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fa120345885f02b5bf5816f554bb9128da9170629a64e67eb386bc69b71a1355
MD5 f34be78f92f84ebb39a2e53663adbb55
BLAKE2b-256 03b49532b4f012bd5b234b51e9ca3dd7ebf0514ab3391022f22b76c4fe44dc3a

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.7-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.7-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 cfc4557613df6182cc7899c133c5b9dcd1d9c9bf56352b55f42548f8ee28ac2d
MD5 956cad7deaa5dd84613e8a7aaf7741fe
BLAKE2b-256 cf0ab4fe09a6b8a384bef4b212544bec0e2a63a1a1d564e1e27cfc7b0a83b833

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.7-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.7-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.7-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 407595ba8d48413f80a3da3434d4cbb3b4e43987718c1722155ba0574470d671
MD5 8a8a5641b0fe83b26259699d9f5d31a2
BLAKE2b-256 b0b2b55f230b025be3d56728454fd434c10089c63639fb13daafa3ef5b3dfb68

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.7-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.7-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c191b36b0535042854084e635543cdda7cf6fe07a04da21b4e7ef8b066161ff0
MD5 9688d299beed95edc1e9f6b964cdf045
BLAKE2b-256 6c496800b3e16f0d41c5edb02abfc0eaf819acdee222f8d6ad691eb7be0b8694

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.7-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.7-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.7-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 aca7c31a611a0eaa41eec74c6f4649eb2af71ecfca1a427825552644ee8aa9f2
MD5 d288048f57747124b66f8bfbcc2343df
BLAKE2b-256 197d230ec2ce60c9561356240a8a313b9c32794a0ab3a3859441b98f624292b7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.7-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.7-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.7-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e3c5afde16cd6b5334898554b44c9e93913042d8ea89106721aeed8011c0ef4d
MD5 3d46c99db37db0754fce208cc6400952
BLAKE2b-256 be1e5bb45d4f06f0254264467b98235676c03e65ae5ab7c7c002faa3dc931ac9

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.7-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.7-cp39-cp39-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for pyiec61850_ng-1.6.1.7-cp39-cp39-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6cd8f9c087092e7ef05c344e90fc43ff7cc91d9fe60993006f1698a46c611eba
MD5 ba4f262b4737ed554f08dc7cb8a306ca
BLAKE2b-256 ac7583f2b6a71e03c25fb07868a7ac770fb7453c6eca980a929f14df02205afc

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyiec61850_ng-1.6.1.7-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