Skip to main content

A high-performance bridge for syncing Siemens S7 DBs to Shared Memory

Project description

Snap7 DB Sync

A high-performance bridge to synchronize Siemens S7 PLC Data Blocks (DB) into Python Shared Memory (SHM).

🚀 Key Features

Zero-Config Parser: Automatically calculates offsets and word-alignment from TIA Portal text exports (SCL or Table-copy).

Shared Memory IPC: Stores PLC data as a JSON string in a shared memory segment for fast access by other processes.

Lifecycle Managed: Shared memory is only allocated when connect() is called and is cleaned up properly on exit.

Thread-Safe: Uses internal locking to prevent crashes during simultaneous PLC read/write operations.

🛠 Usage

1. Get your Blueprint

Copy your Data Block structure from TIA Portal (Right-click > "Copy as text" or "Select All" > "Copy") and save it as db_blueprint.txt.

Run the Sync

Python

from snap7_db_sync import Snap7DBSync

Initialize metadata

sync = Snap7DBSync(
    ip_addr="192.168.0.1",
    db_num=10,
    db_bluprint_txt="db_blueprint.txt"
    )

Connect (Allocates Shared Memory and connects to PLC)

if sync.connect():
    # Start background logging at 50ms intervals
    sync.start_logging(cycle_time_ms=50)
    
    # Write values back to PLC safely
    sync.write_to_plc({"MySensorValue": 123.4})
    
    # Clean up when done
    sync.close_connection()

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

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

snap7_db_sync-0.1.1.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

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

snap7_db_sync-0.1.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file snap7_db_sync-0.1.1.tar.gz.

File metadata

  • Download URL: snap7_db_sync-0.1.1.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for snap7_db_sync-0.1.1.tar.gz
Algorithm Hash digest
SHA256 98eaec35b5eddeca7b0fae16e6c96d656eafd3b1774dc0be544cb0b717b2d7c1
MD5 9fb71e5b9016af2023b5964280d5efce
BLAKE2b-256 0e499838b9f30d717a1d9a7562638c506c63cd2047dfb43967efe8d2fce98ee0

See more details on using hashes here.

File details

Details for the file snap7_db_sync-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: snap7_db_sync-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 8.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for snap7_db_sync-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2d5156c3bd2d28d7c0bcd92759c533e9a3e49ba861ef55d4422ce9482f029af0
MD5 3b873fa194c8462eaecfe0b9c2a939bd
BLAKE2b-256 32fae35e415e6ce73c63850dc96b508e8b3c79fb5340b6ca23ef1ddf533f56fd

See more details on using hashes here.

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