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

Uploaded Source

Built Distributions

c104-2.0.2-cp312-cp312-win_amd64.whl (485.1 kB view details)

Uploaded CPython 3.12 Windows x86-64

c104-2.0.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (551.0 kB view details)

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

c104-2.0.2-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (518.5 kB view details)

Uploaded CPython 3.12 manylinux: glibc 2.27+ ARM64 manylinux: glibc 2.28+ ARM64

c104-2.0.2-cp311-cp311-win_amd64.whl (483.9 kB view details)

Uploaded CPython 3.11 Windows x86-64

c104-2.0.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (551.0 kB view details)

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

c104-2.0.2-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (518.8 kB view details)

Uploaded CPython 3.11 manylinux: glibc 2.27+ ARM64 manylinux: glibc 2.28+ ARM64

c104-2.0.2-cp310-cp310-win_amd64.whl (483.2 kB view details)

Uploaded CPython 3.10 Windows x86-64

c104-2.0.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (550.4 kB view details)

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

c104-2.0.2-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (517.5 kB view details)

Uploaded CPython 3.10 manylinux: glibc 2.27+ ARM64 manylinux: glibc 2.28+ ARM64

c104-2.0.2-cp39-cp39-win_amd64.whl (483.4 kB view details)

Uploaded CPython 3.9 Windows x86-64

c104-2.0.2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (550.6 kB view details)

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

c104-2.0.2-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (517.8 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.27+ ARM64 manylinux: glibc 2.28+ ARM64

c104-2.0.2-cp38-cp38-win_amd64.whl (483.1 kB view details)

Uploaded CPython 3.8 Windows x86-64

c104-2.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (589.4 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

c104-2.0.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (560.6 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

c104-2.0.2-cp37-cp37m-win_amd64.whl (480.2 kB view details)

Uploaded CPython 3.7m Windows x86-64

c104-2.0.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (583.8 kB view details)

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

c104-2.0.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (555.5 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

File details

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

File metadata

  • Download URL: c104-2.0.2.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.2.tar.gz
Algorithm Hash digest
SHA256 a31c7ed85e82aa026a620b08ea1ebf36ee740d5bda74fe42117d7b044f5ead07
MD5 c043a4033b0b347bc3191446cf4a7991
BLAKE2b-256 70ce6a6a35d8aa95ab9e78e8fa1948da1ae55827e7605585b24d0e380429b31b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: c104-2.0.2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 485.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.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2699c69d8ee40f7b825509b88b0ef5a7f8dad9bfa4bd4abec6e0abeb7a6b1fd5
MD5 b46bc0f0ed30af97f5eb563527f63863
BLAKE2b-256 b9da615c59b0bb3333fb129d8bef4849f35a4401ace08a37079e46121bb50947

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for c104-2.0.2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6ff571cbf0858839c2a8e9b946c01d851c817f339c8a50a558b7a9246bc60017
MD5 ef1fc244fc2c1bf65b642fa3885f7b0d
BLAKE2b-256 10f8ea32f942fe688160244464b4d9d4b919c1a45e27166fc3c3ab3ffec3c4d0

See more details on using hashes here.

File details

Details for the file c104-2.0.2-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for c104-2.0.2-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 41a387b97ed797f6bcbde5863f15a17ebc8372b5c7159845b3d70565d8a2ce3f
MD5 6af2e0f476f94049135eee468452320d
BLAKE2b-256 4a4a936892bfaafce424ad37b7dbe7162e59cc904b6374bc7cddd13d25de8738

See more details on using hashes here.

File details

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

File metadata

  • Download URL: c104-2.0.2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 483.9 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.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c5c4ece99d981040eaf4b45aed464a03ecf0bbf4468e30136897877da21d8c40
MD5 5e07f19c459557231824775626837932
BLAKE2b-256 5e23b831303fde69c3b7b0a74dadc23943d3709e7914b9776436dbe859065c34

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for c104-2.0.2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6924fd256b9d4fe7ba30f91200c41cf7d78937ad94cb313a317421e1c45313cf
MD5 01822a342e0f0b8154675f26f90c2003
BLAKE2b-256 e6a8bfa418e52005d1ec602abf65a0bf9b420c31a461e4cefec26a85d22e646f

See more details on using hashes here.

File details

Details for the file c104-2.0.2-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for c104-2.0.2-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 92ab9202cddef46a848e7ddd36b73f8e15524a469f3e5af9ad318c726d546a11
MD5 fa09672d6acb27dcf412f7d2d89cda52
BLAKE2b-256 cc1b112a9a97ea3bf0931e13abd37f9c6bd46920ce9c2468a10709b8175a7b6e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: c104-2.0.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 483.2 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.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9a3c8aa395dce606c0c59b86fe557e2255746e1c634d6d30c1024f2814782951
MD5 f8e2380a75027080da3c10ac3f11ae7b
BLAKE2b-256 20d70834769f60002f7cc8d146747bbc25079446dc490fa7def37fce3410c653

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for c104-2.0.2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 61767b3ff2534029f45d333cf904add14ac825ba8ad24a4e97001bd45881335c
MD5 8899065f5596ff9aeb4580dfdf221632
BLAKE2b-256 d67789872fc493b5e8e3ef0dd659f9a85b37cf502b859dd1622eb2c9b8f4c76a

See more details on using hashes here.

File details

Details for the file c104-2.0.2-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for c104-2.0.2-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 ecd2defe6d2ad942a8a3de451d43b584df1bd195ef6a22eb1023e29a0027d6e8
MD5 c29c239fc8babbbae65fe4ee7138e6b1
BLAKE2b-256 08f236066d860415c1ed32257547e028598566d922aade9ddfa9ea89c8c423d1

See more details on using hashes here.

File details

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

File metadata

  • Download URL: c104-2.0.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 483.4 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.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ae6e6a027092cc71572b476bc5cc6c29cb9931e05259d92bc7752ee319386581
MD5 a0c5e8c2a073ba9135827026f56b7c27
BLAKE2b-256 362131c38a4b2890a3880c2b1b08180a086757b95a3bd2e52d66ba35a0944f3b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for c104-2.0.2-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c13cc10dc0f481d73894f8960d867e10fb67b49f2682c19e164f240835402c68
MD5 e44c9c0f76b5c73013e42c290436d3ac
BLAKE2b-256 272d679a28d4123a0c877663c5f36f4b6eed049c1577c1076e417c728aa074b6

See more details on using hashes here.

File details

Details for the file c104-2.0.2-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for c104-2.0.2-cp39-cp39-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6df59fb0254e2e66d97cfe7cf380af83a9e64e3ffccd031da1be9391ca7c9d75
MD5 61f995fa682ed40a42bd234b911bbd7d
BLAKE2b-256 b98ab6c6c7bc0e690a8fcb8c207fab52039d9bc6a796857638534af7af447355

See more details on using hashes here.

File details

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

File metadata

  • Download URL: c104-2.0.2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 483.1 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.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 dbd2b9c266af005fa59dc03afb5a5cc4db85d5f9c72459fd1ad0c012d55f91fe
MD5 756f36f021a679ebe91b47132cdb5916
BLAKE2b-256 7a819cd2e70395edcaed6e55556200d3069c700384ec3dbedcad3929823a2423

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for c104-2.0.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6daf43314373ff8d14f41e89d874d26f7a0967ced5669150842751b35455ec96
MD5 3749633494825a6032d1c685a09bb33a
BLAKE2b-256 3584a12af22d04bb563c1e53c2d23dc46d575a9391318327b0c1d8d4ceffe70f

See more details on using hashes here.

File details

Details for the file c104-2.0.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for c104-2.0.2-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 058b0ef89134500184d862305c6d4fc94ad3ca61f616ba993d7ef67db4027027
MD5 af107a125c57938bdd019b7c37e86fdf
BLAKE2b-256 fb7e14e59a63f872cb0ed2a00fec1ac3390383be3e3c7c17764adc997a3e97fe

See more details on using hashes here.

File details

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

File metadata

  • Download URL: c104-2.0.2-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 480.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.2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 6b6f61982715b3b42ab2d2c79c7f9c08835c0a482693f8aded1837e7cadc5675
MD5 26df35d22abde0aa1a09142b3980bb66
BLAKE2b-256 c7bd89570a6d252d6b8ea33d342b3cc828e5fef6a92fe7dde42d85fffb26d575

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for c104-2.0.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a01cc3550b58f36ff8ebe52dd9b3dd49c09e24e60594cd43432ae28d0939a263
MD5 05338b8dd264018d85ddfd2133bcdceb
BLAKE2b-256 86f1f231d0f8f7e796d23e04403b0ac291e648b52a402aaa03513c5e8723a63e

See more details on using hashes here.

File details

Details for the file c104-2.0.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for c104-2.0.2-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f173f7d7dae9b1585481e1c60aa07c91c0effdc7861291b4d7195c30ff0955d0
MD5 bd7696b398f023639080b9bb8bba9238
BLAKE2b-256 65258f10ea1fba5670ea1bdd696ed781fa4179bc56b9e8532156d667dfdadd76

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