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.0.tar.gz (7.8 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.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: snap7_db_sync-0.1.0.tar.gz
  • Upload date:
  • Size: 7.8 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.0.tar.gz
Algorithm Hash digest
SHA256 cf1da5b2be3e0a161f24f96f2a8b1a5ad66f8a2109de9725aff4bcc7a825ca8f
MD5 4a4125ff31ef1926c6a6d8501a4b2f15
BLAKE2b-256 9c8562c5de00abe76ff98cf3d42b9321f9d714142b8f24b4b1a8268e88990772

See more details on using hashes here.

File details

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

File metadata

  • Download URL: snap7_db_sync-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d5045a5b5cc78a7f1bdd0fb92c21ca788ec0d36444236d16c2e51f8b77b0993e
MD5 1b1f0c3ffec65cb54ed2d858f6ece7b1
BLAKE2b-256 d3b659442f68e950c2693d5467da15b0bd1670dd67686402fd30057b94b892a9

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