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. Documentation
  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=5000)
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()

# 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)
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.1.tar.gz (1.5 MB view details)

Uploaded Source

Built Distributions

c104-2.0.1-cp312-cp312-win_amd64.whl (484.1 kB view details)

Uploaded CPython 3.12 Windows x86-64

c104-2.0.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (549.8 kB view details)

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

c104-2.0.1-cp311-cp311-win_amd64.whl (483.1 kB view details)

Uploaded CPython 3.11 Windows x86-64

c104-2.0.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (550.0 kB view details)

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

c104-2.0.1-cp310-cp310-win_amd64.whl (482.4 kB view details)

Uploaded CPython 3.10 Windows x86-64

c104-2.0.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (549.5 kB view details)

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

c104-2.0.1-cp39-cp39-win_amd64.whl (482.5 kB view details)

Uploaded CPython 3.9 Windows x86-64

c104-2.0.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (549.6 kB view details)

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

c104-2.0.1-cp38-cp38-win_amd64.whl (482.4 kB view details)

Uploaded CPython 3.8 Windows x86-64

c104-2.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (588.7 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

c104-2.0.1-cp37-cp37m-win_amd64.whl (479.2 kB view details)

Uploaded CPython 3.7m Windows x86-64

c104-2.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (582.9 kB view details)

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

File details

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

File metadata

  • Download URL: c104-2.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 075e7467e568f1ee683452057c433d3eb05c0da19c3ec0aa3898b9e51b191a2a
MD5 82f14402cf2c50ae6a0d744a89b98810
BLAKE2b-256 6c3c2c773507c19a708a8def0c3dfb7799aa13f2bea73c1890a69d995bb0e124

See more details on using hashes here.

File details

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

File metadata

  • Download URL: c104-2.0.1-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 484.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.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 5f85ca4e7088f7989df136a87b9dec534207918b33ef6699150c7615db8191e8
MD5 77ad0ea4740967eee9c533fc0039601f
BLAKE2b-256 17d32fb5bfde989af3a940ba72414cf7c8311d75024e343ff3f8c97fd0b5da30

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for c104-2.0.1-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0fde58fe05de400c24a43749108aceaf88a86781e81782e6cde4fefc31482928
MD5 643692a9b13a3af409b56effee9f77b5
BLAKE2b-256 ab4daba00efa8bd36e793f8cd353658c8fbbfb1b92dbfec462d14e0b1e694ea2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: c104-2.0.1-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 483.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.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 13ba0b4d0a3feed87b49bf9f7ef160f00be9496e919fd49c33784975728cdf95
MD5 dd0dc421944429250613784a1264895b
BLAKE2b-256 bc079c37809fd28878d0511b4e598977c336f04fe7b3dd025da73891b86dc42b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for c104-2.0.1-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 82a3e53a21f56bf2df172662387d3c72cfcf7bfadb6940283066d6ad6b16adcd
MD5 7820c39f9d85f9bb38353d758d19e40e
BLAKE2b-256 9ee3c75c96a95860fa2245509ada123d96ca7054fa6de4cff56400ba48af247e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: c104-2.0.1-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 482.4 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.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e05d408d27bb81b6d6786af6e03fe7cd0b3a69b78f9d09a5a33ee4205be45959
MD5 27e46220c0d4cfdf47d7a1db483fac2d
BLAKE2b-256 f1d06e2cf5bf011bd1b3af0f6c3095829b0a796ca6c6f6cba13eba682a63043d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for c104-2.0.1-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 320d0f860eabd7d1c6b7fae5eecc20c30f091940272abe1a9e24f0ab38cf20d9
MD5 9f93d302ea91f6a5dd4fb093ff65d1fc
BLAKE2b-256 80e63adbeecdfc6ca50c6db82e0048ac1d78b916460301ed24533506b29c4c12

See more details on using hashes here.

File details

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

File metadata

  • Download URL: c104-2.0.1-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 482.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.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 932bded1a6a58edd5b5b61527f6c30fe9162057771ffe41d0fbc02eeb14f8ccd
MD5 ff25cb1d35e5b6c0dc0ca2b148c6adcf
BLAKE2b-256 5496d49b1bcb479c5cf3cdf0a4b1a2aa91254338776688aa6352677caaa7849b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for c104-2.0.1-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 431837210596ad98fdb05106d7781b0feb99c7a954acf9f14f947062df638b52
MD5 863374b16c2936ec5924ef3f5a07231b
BLAKE2b-256 a3888b4aac250b0d862313bb3d6261fb15a72da5a0fb8f7634e8261f1808da17

See more details on using hashes here.

File details

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

File metadata

  • Download URL: c104-2.0.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 482.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.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 ffbb954cd5cd9dac94b9fe56d6a412b6144a9e69cad98cdf9b5ad32e2c1d6067
MD5 aa1b4ae7a4eddacf11b78c9a1e0cf669
BLAKE2b-256 bd7afe6cabfdbdbd3d0d3c96d1f5d91cfe0e330ce7446c46823aec315436ff26

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for c104-2.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f0402cd8cd1551c5d2cd6ceb64dc51c358b14f995cdd340a6f539dd218bbc686
MD5 2007fbc32201172ee1243ec273a7ee95
BLAKE2b-256 8040b419c1e1161cb901d3dc5ebe32069b66a6d5670de40e86bb42c2657992f3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: c104-2.0.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 479.2 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.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 af736db02ffcb72a678a53c1a431c4db096087142a0f42c52f05d47629421747
MD5 971736cc9866598bff39ec44d6220058
BLAKE2b-256 6d0a083eabf53d21e605d4c15ddee409f1386cd0ca3f2264a54a7cd9847cf99e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for c104-2.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ed1b6cd66e7329c63826e5d26334b8fc880233984b532cf942d1466d59f3140b
MD5 5f4a11425feb753ac956a2fa4ed6072f
BLAKE2b-256 95f510ee043ca6610b415d621a23aef4b4dbdbddf3eee15ad9344d5106c9d651

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