Skip to content

Symbolic addressing (read/write by tag name) #616

@gijzelaerr

Description

@gijzelaerr

Summary

Add support for reading and writing PLC data by symbolic tag names instead of raw DB number + byte offset.

Background

In TIA Portal projects, engineers define symbolic names for variables (e.g., Motor1.Speed, Tank.Level). Currently, users must manually map these names to raw addresses (DB1.DBD4, etc.), which is error-prone and breaks when the PLC program is reorganized.

What needs to be done

  • Define a tag/symbol table format (or support multiple formats)
  • Implement a parser for TIA Portal export files (.xml symbol table exports)
  • Implement a parser for CSV/JSON symbol table formats (for manual definitions)
  • Create a SymbolicClient wrapper or mixin that resolves tag names to addresses before read/write
  • Handle nested UDT (User-Defined Type) structures
  • Support array indexing in symbolic paths (e.g., Motors[3].Speed)
  • Cache resolved addresses for performance
  • Add tests with sample symbol tables
  • Add documentation and examples

API Design Ideas

from snap7 import Client, SymbolTable

# Load symbols from TIA Portal export
symbols = SymbolTable.from_tia_xml("project_tags.xml")

client = Client()
client.connect("192.168.1.10", 0, 1)

# Read by tag name
speed = symbols.read(client, "Motor1.Speed")  # returns float
level = symbols.read(client, "Tank.Level")

# Write by tag name
symbols.write(client, "Motor1.Speed", 1500.0)

Notes

  • TIA Portal can export symbol tables as XML or in AWL format
  • The existing DB/Row classes in snap7/util/db.py already provide layout-based access — this feature could build on that
  • Consider supporting L5X (Rockwell) format too for broader appeal, but Siemens formats are the priority

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions