python-snap7 3.1.0
A feature-rich release adding async support, a CLI, symbolic addressing, network discovery, and many quality-of-life improvements to the pure-Python S7 library introduced in 3.0.
New features
- AsyncClient — full asyncio-based client for non-blocking PLC communication (#593)
- CLI tools —
snap7command-line interface for PLC interaction; install withpip install "python-snap7[cli]"(#631) - Typed DB access — convenience methods for reading/writing common S7 data types (BOOL, INT, REAL, etc.) directly (#632)
- PROFINET DCP discovery — discover PLCs on the local network without knowing their IP addresses (#634)
- Heartbeat & auto-reconnect — connection monitoring with configurable heartbeat interval and exponential-backoff reconnection (#635)
- Symbolic addressing (Tags) — read/write PLC variables by name using a unified Tag API with PLC4X and nodeS7 dialect support (#638, #697, #701)
- S7 routing — access PLCs behind gateways across multiple subnets (#639)
- Multi-variable read optimizer — automatically batch multiple reads into minimal PDU exchanges (#641)
- Structured logging — PLC connection context (host/rack/slot) attached to log records, with JSON formatter (#688)
- Diagnostic buffer & data-change subscriptions — read the PLC diagnostic buffer and subscribe to variable changes (#690)
- Block transfer & CPU state control — upload/download blocks, start/stop/hot-start/cold-start the PLC (#693)
- Demo subcommand —
snap7 demostarts a live server exposing real host metrics for quick testing (#704)
Bug fixes
- Fix
get_cpu_infoandS7SZL.__str__(#692) - Fix server SZL 0x001C response to match real PLC format (#694)
- Fix
AttributeErrorfrom__del__during interpreter shutdown (#707) - Use
connection_typein TSAP composition during connect (#766) - Accept
memoryviewin setter/getter type annotations (#647) - Zero-pad milliseconds in
get_timeso 3 ms reads as ".003" (#716) - Use proper PI service PDU format for PLC control commands (#733, #743)
- Set
TCP_NODELAYandSO_KEEPALIVEon all S7 sockets (#677) - Backport robustness improvements from python-s7comm (#580)
- Add
get_ulintandget_lintto snap7.util exports (#652) - Fix async
get_cpu_infoand extract shared SZL/block parsers (#702) - Fix demo primary-IP guess with VPN/tunnel interfaces (#708)
Other improvements
- Property-based testing with Hypothesis (#636)
- Improved documentation with intersphinx cross-references and restructured API docs
- Full type annotations with mypy strict mode (no
type: ignoreneeded) - Python 3.10–3.14 support
Upgrading from 3.0
This is a backwards-compatible release. All existing 3.0 code should work without changes. New features are additive.
If you experience any issues, please report them on the issue tracker.