Skip to main content

A Python module to simulate SCADA and RTU communication over protocol 60870-5-104 to research ICT behavior in power grids.

Project description

iec104-python

Table of contents

  1. Introduction
  2. Licensing
  3. System requirements
  4. Installation
  5. Wiki
  6. Contribution

Introduction

This software provides an object-oriented high-level python module to simulate scada systems and remote terminal units communicating via 60870-5-104 protocol.

The python module c104 combines the use of lib60870-C with state structures and python callback handlers.

Example remote terminal unit

import c104

# server and station preparation
server = c104.Server(ip="0.0.0.0", port=2404)

# add local station and points
station = server.add_station(common_address=47)
measurement_point = station.add_point(io_address=11, type=c104.Type.M_ME_NC_1, report_ms=1000)
command_point = station.add_point(io_address=12, type=c104.Type.C_RC_TA_1)

server.start()

Example scada unit

import c104

client = c104.Client(tick_rate_ms=1000, command_timeout_ms=5000)

# add RTU with station and points
connection = client.add_connection(ip="127.0.0.1", port=2404, init=c104.Init.INTERROGATION)
station = connection.add_station(common_address=47)
measurement_point = station.add_point(io_address=11, type=c104.Type.M_ME_NC_1, report_ms=1000)
command_point = station.add_point(io_address=12, type=c104.Type.C_RC_TA_1)

client.start()

See examples folder for more detailed examples.

Licensing

This software is licensed under the GPLv3 (https://www.gnu.org/licenses/gpl-3.0.en.html).

See LICENSE file for the complete license text.

Dependencies

lib60870-C

This project is build on top of lib60870-C v2 from MZ Automation GmbH, which is licensed under GPLv3.

The library is used for 60870-5-104 protocol based communication.

» Source code

» Documentation

mbedtls

This project is build on top of mbedtls from the Mbed TLS Contributors, which is licensed under Apache-2.0.

The library is used to add transport layer security to the 60870-5-104 protocol based communication.

» Source code

» Documentation

pybind11

This project is build on top of pybind11 from Wenzel Jakob, which is licensed under a BSD-style license.

The library is used to wrap c++ code into a python module and allow seamless operability between python and c++.

» Source code

» Documentation

catch2

This project is build on top of catch2 from the Catch2 Authors, which is licensed under BSL-1.0.

The library is used as testing framework for test-automation.

» Source code

» Documentation

System requirements

Operating systems

  • Manylinux (x86_64): YES
  • Manylinux (aarch64): YES
  • Raspbian (armv7l): YES
  • Windows (x64): YES

Python versions

  • python >= 3.7, < 3.13

Installation

Please adjust the version number to the latest version or use a specific version according to your needs.

Install from pypi.org

python3 -m pip install c104

Install from git with tag

python3 -m pip install c104@git+https://github.com/fraunhofer-fit-dien/iec104-python.git

You need the build requirements, listed under "How to build".

Documentation

Read more about the Classes and their Properties in our read the docs documentation.

Contribution

How to contribute

  1. Add feature requests and report bugs using GitHub's issues

  2. Create pull requests

    
    

How to build (linux)

  1. Install dependencies

    sudo apt-get install build-essential python3-pip python3-dev python3-dbg
    python3 -m pip install --upgrade pip
    
  2. Clone repository

    git clone --depth=1 --branch=main https://github.com/Fraunhofer-FIT-DIEN/iec104-python.git
    cd iec104-python
    git submodule update --init
    
  3. Build wheel

    python3 -m pip wheel .
    

How to build for multiple python versions (linux with docker)

  1. Build wheels via docker (linux)
    /bin/bash ./bin/linux-build.sh
    

How to analyze performance (linux)

  1. Install dependencies

    sudo apt-get install google-perftools valgrind
    sudo pip3 install yep
    
  2. Copy pprof binary

    cd /usr/bin
    sudo wget https://raw.githubusercontent.com/gperftools/gperftools/master/src/pprof
    sudo chmod +x pprof
    
  3. Execute profiler script

    ./bin/profiler.sh
    

How to build (windows)

  1. Install dependencies

  2. Option 1: Build as wheel

    python3 -m pip wheel .
    
  3. Option 2: Build pyd via Powershell

    cmake -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022" -B cmake-build-release -A x64 -DPython_EXECUTABLE=C:\PATH_TO_PYTHON\python.exe
    &"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe" /m /p:Platform=x64 /p:Configuration=Release c104.sln /t:Rebuild
    

    Set a valid PATH_TO_PYTHON, if you have multiple python versions.
    Set a valid path to MSBuild.exe unless msbuild is already in path.

Generate documentation

  1. Build c104 module

  2. Install dependencies

    • python3 -m pip install -r ./docs/requirements.txt
    • doxygen
    • graphviz
  3. Build doxygen xml

    doxygen Doxyfile
    
  4. Build sphinx html

    python3 bin/build-docs.py
    

Change log

Track all changes in our CHANGELOG documentation.

Project details


Download files

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

Source Distribution

c104-2.0.0.tar.gz (1.5 MB view details)

Uploaded Source

Built Distributions

c104-2.0.0-cp312-cp312-win_amd64.whl (482.1 kB view details)

Uploaded CPython 3.12 Windows x86-64

c104-2.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (548.1 kB view details)

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

c104-2.0.0-cp311-cp311-win_amd64.whl (481.1 kB view details)

Uploaded CPython 3.11 Windows x86-64

c104-2.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (548.3 kB view details)

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

c104-2.0.0-cp310-cp310-win_amd64.whl (480.3 kB view details)

Uploaded CPython 3.10 Windows x86-64

c104-2.0.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (547.6 kB view details)

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

c104-2.0.0-cp39-cp39-win_amd64.whl (480.5 kB view details)

Uploaded CPython 3.9 Windows x86-64

c104-2.0.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (547.8 kB view details)

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

c104-2.0.0-cp38-cp38-win_amd64.whl (480.4 kB view details)

Uploaded CPython 3.8 Windows x86-64

c104-2.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (587.0 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

c104-2.0.0-cp37-cp37m-win_amd64.whl (477.3 kB view details)

Uploaded CPython 3.7m Windows x86-64

c104-2.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (581.7 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

File details

Details for the file c104-2.0.0.tar.gz.

File metadata

  • Download URL: c104-2.0.0.tar.gz
  • Upload date:
  • Size: 1.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.5

File hashes

Hashes for c104-2.0.0.tar.gz
Algorithm Hash digest
SHA256 663b9e800b9e9d775e05068e987a22ab18a21aec1957b9279ee9cef69a1aa064
MD5 2f79fd340a9cffbe116e7adc39f61f75
BLAKE2b-256 3b2d7ffd9526fa175132d9dcc39d69991582223dff9e518247915a0eecac5785

See more details on using hashes here.

File details

Details for the file c104-2.0.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: c104-2.0.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 482.1 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.5

File hashes

Hashes for c104-2.0.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c58c11b6363ac63cd3194cfc3771a70683aa03689dd0140b6935bd3df4a4f24e
MD5 f7b031581c3f2cee21a46a5f07d6ac7c
BLAKE2b-256 e10767bc80002c0dccf528c5b162221a43e6582f96f3147ad0cd5ea191d49222

See more details on using hashes here.

File details

Details for the file c104-2.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for c104-2.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 58c875fca51f8054f25331d2ba4c4a9b96b35a1c9f8a4d3ba03391ba67dd98c9
MD5 5fa167d2dee4c020979d8e8f346b2a20
BLAKE2b-256 11e21663e052ba8c6559be2121f719637bd997ccc3a74bf680742f214d8fc375

See more details on using hashes here.

File details

Details for the file c104-2.0.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: c104-2.0.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 481.1 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.5

File hashes

Hashes for c104-2.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c087ba9172d72ee3578974d8ef2078787ad1fc4bb99af467b5b73f62bcd48f58
MD5 e11d70d67fd27b47c23331c16a2a6c12
BLAKE2b-256 1b6ef9afeef9cfe4bf8a8c7bff4c88ef76999ea4d8507d383602d00d588e2145

See more details on using hashes here.

File details

Details for the file c104-2.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for c104-2.0.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 40149946f51d4654758ca9718f9036062684a2153731ccd780298097d27326e0
MD5 39391ad8b4f1527ae9866457c336ab0b
BLAKE2b-256 c6f135b6d38845c247d2be112228c9cd3ef9bb882488233ec05b9c3b90d3d01e

See more details on using hashes here.

File details

Details for the file c104-2.0.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: c104-2.0.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 480.3 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.5

File hashes

Hashes for c104-2.0.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 298f81f5b017240d8ff54c7eba0ac6e5231de0666830aaca86287dcfaa8ef217
MD5 e9819efd256f7c582c5213ce65ad60f3
BLAKE2b-256 7307156ba2a29667bc5d20ee0c00c820910eb09ae633505f08efaa01f3a98913

See more details on using hashes here.

File details

Details for the file c104-2.0.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for c104-2.0.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 14237c9e538e5992e619d1cb86896f58343a7bd822eccb7cfe1f7fc0e4876074
MD5 f602094b1596165ff61c14bc7090723b
BLAKE2b-256 b092cee727e38b5ce15b8c53fdc6864b349f24bbcc52f76911baa8b9beec5048

See more details on using hashes here.

File details

Details for the file c104-2.0.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: c104-2.0.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 480.5 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.5

File hashes

Hashes for c104-2.0.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 b7d6d9bc910efb23ae43912ea400fde21ce84f932504375bb416e8345f025a2d
MD5 1da9ba370919c2ef4ccb095e7a6a1d25
BLAKE2b-256 448024a283cc8f9b419952816697ff1e4bae882fd060133cc446ef788c4a6271

See more details on using hashes here.

File details

Details for the file c104-2.0.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for c104-2.0.0-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b86117d6f5925caf9c99dd4ff26c1a2a0557e927cda6d7aa3b2285bcd0c0d446
MD5 a9e7c34e43632133a20cfc7081eba502
BLAKE2b-256 af5311a616acef9c9f2b714f853a7fa378f2a86145f7a8cef62ff70f1636f86f

See more details on using hashes here.

File details

Details for the file c104-2.0.0-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: c104-2.0.0-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 480.4 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.5

File hashes

Hashes for c104-2.0.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 987ae332004db0ebfef099846bbe6528f5e5240618b80bea588385e8fae13106
MD5 fada7d70ea648887f3c37409f738f32c
BLAKE2b-256 6fd8d232ed8d1836d642c18035420f0a67d24397c227290173e1b81bf741027b

See more details on using hashes here.

File details

Details for the file c104-2.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for c104-2.0.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2c977a6fb6b5c3d81775c1d367dd7d0088ba05f9083fbf145171c00fa30cb71c
MD5 c4ba5afcd445b994678eff1024b304cf
BLAKE2b-256 b1a443238902ee795a75e45b7883e3556cc86dd22d5a40f512678bf5ead4d556

See more details on using hashes here.

File details

Details for the file c104-2.0.0-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: c104-2.0.0-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 477.3 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.5

File hashes

Hashes for c104-2.0.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 35027e039e77302434fcb74a1a70e18dfcbe02b2b460d1c0c055c492c657aa5c
MD5 4a9bfe06cc4d0c89d96a41f88e98d112
BLAKE2b-256 488bb0e95d4a690d12236ac0ad3efbdf6f6dfe945d6d061d61cfd4f670abe8c6

See more details on using hashes here.

File details

Details for the file c104-2.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for c104-2.0.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6cbfcc312fbbf57bb82ac70311059b52f2e278c56097c0def0f2dbad52bd416b
MD5 f8d3b4ef3c65440d959c10ac9a1d88eb
BLAKE2b-256 94da13e65f2d3e1b96b1caf26a5ef5445af13b7d3d7db1708b338f61a5e43d5f

See more details on using hashes here.

Supported by

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