Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
d7556ff
chore(deps): bump the all-dependencies group with 4 updates (#609)
dependabot[bot] Mar 18, 2026
3ae975f
Update documentation for 3.0 release
gijzelaerr Mar 18, 2026
d779ba3
Add note explaining the historical python-snap7 name
gijzelaerr Mar 18, 2026
f880d8c
Add contributors to 3.0.0 release notes
gijzelaerr Mar 18, 2026
4c52bcb
Add coverage badge and coverage threshold (#637)
gijzelaerr Mar 20, 2026
67713e2
Add comprehensive tests for partner.py (57% -> 84% coverage) (#645)
gijzelaerr Mar 20, 2026
60047da
Accept memoryview in setter and getter type annotations (#647)
gijzelaerr Mar 20, 2026
6ccacf5
Add integration tests for server block operations and USERDATA handle…
gijzelaerr Mar 20, 2026
4bded55
Add tests for snap7/logo.py to improve coverage from 53% to 97% (#643)
gijzelaerr Mar 20, 2026
5443402
Add tests to improve coverage from 78% to 84% (#642)
gijzelaerr Mar 20, 2026
fe6df93
Add native AsyncClient with asyncio support (#593)
gijzelaerr Mar 20, 2026
d52b70b
Add S7CommPlus protocol scaffolding for S7-1200/1500 (#603)
gijzelaerr Mar 20, 2026
a2561a2
Enhanced CLI tools for PLC interaction (#631)
gijzelaerr Mar 20, 2026
ab09964
Add typed DB access methods for common S7 data types (#632)
gijzelaerr Mar 20, 2026
108a107
Add protocol conformance test suite (#633)
gijzelaerr Mar 20, 2026
f0634f8
Add examples cookbook and troubleshooting documentation (#610)
gijzelaerr Mar 20, 2026
b16c707
Cleanup: consolidate tests, docs, and README (#648)
gijzelaerr Mar 20, 2026
76acf91
Restructure docs into logical sections (#649)
gijzelaerr Mar 20, 2026
0dbcda4
chore(deps): bump the all-dependencies group with 5 updates (#650)
dependabot[bot] Mar 23, 2026
13da80d
Add property-based testing with Hypothesis (#636)
gijzelaerr Mar 24, 2026
5c012be
Remove Codecov integration (#653)
gijzelaerr Mar 24, 2026
11dbb86
Add get_ulint and get_lint to snap7.util exports (#652)
gijzelaerr Mar 24, 2026
40d21ed
Add S7CommPlus V2 protocol support (TLS + IntegrityId) (#646)
gijzelaerr Mar 24, 2026
175750c
Add PROFINET DCP network discovery (#634)
gijzelaerr Mar 24, 2026
6342133
Add heartbeat monitoring and auto-reconnect with exponential backoff …
gijzelaerr Mar 24, 2026
252a83d
Add .hypothesis to .gitignore
gijzelaerr Mar 25, 2026
c6fdd85
Replace pip with uv across all CI workflows (#658)
gijzelaerr Mar 25, 2026
f48958c
Update documentation for heartbeat, S7CommPlus V2, and discovery (#654)
gijzelaerr Mar 25, 2026
667f97c
Improve test coverage for recent features (#655)
gijzelaerr Mar 25, 2026
2c94acf
Add TLS support to S7CommPlus async client (#656)
gijzelaerr Mar 25, 2026
ceefe5d
Complete S7CommPlus V1 session handshake by echoing ServerSessionVersion
gijzelaerr Mar 27, 2026
bf1ecfd
Complete S7CommPlus V1 session handshake by echoing ServerSessionVers…
gijzelaerr Mar 27, 2026
af94ba3
chore(deps): bump requests from 2.32.5 to 2.33.0 (#660)
dependabot[bot] Mar 27, 2026
d1199f5
Move S7CommPlus into s7/ package, simplify to 2-layer architecture
gijzelaerr Mar 27, 2026
b4f73fe
Merge origin/master into s7-unified-package
gijzelaerr Mar 27, 2026
adacd76
Fix return types for drop-in compatibility and update docs
gijzelaerr Mar 27, 2026
9180d4f
chore(deps): bump cryptography from 46.0.5 to 46.0.6
dependabot[bot] Mar 29, 2026
a4f2921
chore(deps): bump actions/deploy-pages in the all-actions group
dependabot[bot] Mar 30, 2026
8a42362
chore(deps): bump the all-dependencies group with 5 updates
dependabot[bot] Mar 30, 2026
6e3b644
chore(deps): bump pygments from 2.19.2 to 2.20.0
dependabot[bot] Mar 30, 2026
651ca49
Update README with restructured landing page and 3.1 release notes
gijzelaerr Apr 1, 2026
066ba77
Merge pull request #662 from gijzelaerr/s7-unified-package
gijzelaerr Apr 1, 2026
770e695
Merge pull request #663 from gijzelaerr/dependabot/uv/cryptography-46…
gijzelaerr Apr 1, 2026
6b4856c
Merge pull request #664 from gijzelaerr/dependabot/github_actions/all…
gijzelaerr Apr 1, 2026
919ba3f
Merge pull request #665 from gijzelaerr/dependabot/uv/all-dependencie…
gijzelaerr Apr 1, 2026
a2a2044
Merge pull request #666 from gijzelaerr/dependabot/uv/pygments-2.20.0
gijzelaerr Apr 1, 2026
458f200
Fix pre-3.0 documentation link to correct Read The Docs tag
gijzelaerr Apr 1, 2026
62e9fa3
Fix pre-3.0 docs link to 2.1.1
gijzelaerr Apr 1, 2026
f2f5118
Recommend s7 as the primary package in docs and docstrings (#667)
gijzelaerr Apr 3, 2026
029d2ce
chore(deps): bump the all-dependencies group with 8 updates (#670)
dependabot[bot] Apr 7, 2026
21f06dc
Fix partner S7 Communication Setup and bsend/brecv PDU format (#669)
gijzelaerr Apr 13, 2026
3c7b062
chore(deps): bump uv from 0.11.3 to 0.11.6 (#672)
dependabot[bot] Apr 13, 2026
c92faa7
chore(deps): bump cryptography from 46.0.6 to 46.0.7 (#671)
dependabot[bot] Apr 13, 2026
7400469
Restructure API docs for consistency (#674)
gijzelaerr Apr 14, 2026
5f3aff6
chore(deps): bump the all-dependencies group with 8 updates (#675)
dependabot[bot] Apr 14, 2026
310ff53
chore(deps): bump pytest from 9.0.2 to 9.0.3 (#676)
dependabot[bot] Apr 14, 2026
cf3d889
Add Dependabot auto-merge workflow (#680)
gijzelaerr Apr 15, 2026
c3275ac
Add symbolic addressing (read/write by tag name) (#638)
gijzelaerr Apr 15, 2026
7c960f3
Add S7 routing support for multi-subnet PLC access (#639)
gijzelaerr Apr 15, 2026
4f358b7
Set TCP_NODELAY and SO_KEEPALIVE on all S7 sockets (#677)
gijzelaerr Apr 15, 2026
2593978
Add missing S7CommPlus operations: area read/write, explore, invoke (…
gijzelaerr Apr 15, 2026
b9f350e
Add multi-variable read optimizer (#641)
gijzelaerr Apr 15, 2026
5b73d7e
Add structured logging with PLC connection context (#688)
gijzelaerr Apr 15, 2026
6c3d3f8
Add extended S7CommPlus operations: browse, list DBs, TIA XML import …
gijzelaerr Apr 15, 2026
6f4a41d
Prepare 4.0 release: README, docs, changelog, s7 exports (#678)
gijzelaerr Apr 15, 2026
701cdd6
Add diagnostic buffer reading and data change subscriptions (#690)
gijzelaerr Apr 15, 2026
2d95589
Add s7 unified client/server tests, fix EXPLORE parser and server (#691)
gijzelaerr Apr 15, 2026
99c01ff
Fixed "get_cpu_info" and "__str__" in structure "S7SZL" (#692)
qzertywsx Apr 15, 2026
02a87ea
Complete 4.0 feature set: setters, array helpers, block transfer, CPU…
gijzelaerr Apr 15, 2026
94eb573
Fix server SZL 0x001C response to match real PLC format (#694)
gijzelaerr Apr 15, 2026
7423a28
Fix mypy errors in test_symbols and server SZL list (#695)
gijzelaerr Apr 15, 2026
8a0ff08
4.0 polish: docs, examples, property tests, stress tests, optimizer f…
gijzelaerr Apr 16, 2026
e609837
Unified Tag API replacing SymbolTable (#697)
gijzelaerr Apr 20, 2026
7358d20
Add dual-dialect Tag parsing (PLC4X + nodeS7) (#701)
gijzelaerr Apr 21, 2026
2d9d1b8
Fix async get_cpu_info and extract shared SZL/block parsers (#702)
gijzelaerr Apr 21, 2026
8125f93
Replace random.randint port picks with OS-assigned ephemeral ports (#…
gijzelaerr Apr 21, 2026
36f4ef8
chore(deps): bump the all-dependencies group with 4 updates (#699)
dependabot[bot] Apr 21, 2026
376910f
chore(deps): bump actions/upload-pages-artifact in the all-actions gr…
dependabot[bot] Apr 21, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/workflows/dependabot-auto-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: Dependabot auto-merge
on: pull_request

permissions:
contents: write
pull-requests: write

jobs:
dependabot:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{github.event.pull_request.html_url}}
GH_TOKEN: ${{secrets.GITHUB_TOKEN}}
8 changes: 3 additions & 5 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,12 @@ jobs:
with:
enable-cache: true
- name: Install dependencies
run: |
uv venv
uv pip install ".[doc,cli]"
run: uv sync --extra doc --extra cli
- name: Build documentation
run: uv run sphinx-build -N -bhtml doc/ doc/_build -W
- name: Upload Pages artifact
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
uses: actions/upload-pages-artifact@v4
uses: actions/upload-pages-artifact@v5
with:
path: doc/_build
deploy:
Expand All @@ -46,4 +44,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v5
8 changes: 5 additions & 3 deletions .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install build
run: pip install build
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Build distribution
run: python -m build
run: uv build
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/publish-test-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ jobs:
uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install build
run: pip install build
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Build distribution
run: python -m build
run: uv build
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/source-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ jobs:
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
- name: Install build tools
run: |
uv venv
uv pip install build
- name: Create source tarball
run: |
uv run python -m build . --sdist
uv build --sdist

- name: Upload artifacts
uses: actions/upload-artifact@v7
Expand Down
12 changes: 2 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ jobs:
with:
enable-cache: true
- name: Install dependencies
run: |
uv venv --python python${{ matrix.python-version }}
uv pip install ".[test]"
run: uv sync --extra test --extra s7commplus --python python${{ matrix.python-version }}
- name: Run pytest
run: uv run pytest --cov=snap7 --cov-report=xml --cov-report=term
- name: Upload coverage report
if: matrix.python-version == '3.13' && matrix.runs-on == 'ubuntu-24.04'
uses: actions/upload-artifact@v7
with:
name: coverage-report
path: coverage.xml
run: uv run pytest --cov=snap7 --cov-report=term
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,4 @@ venv*/
snap7.dll

.claude/
.hypothesis/
72 changes: 70 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,93 @@
CHANGES
=======

4.0.0 (unreleased)
-------------------

Major release: new `s7` package with S7CommPlus protocol support.

* New `s7` package as recommended entry point with protocol auto-detection
* S7CommPlus V1, V2 (TLS), and V3 support for S7-1200/1500
* S7CommPlus area read/write (M, I, Q, counters, timers)
* S7CommPlus PLC start/stop via INVOKE
* S7CommPlus object browsing via EXPLORE
* S7CommPlus live symbol browsing (`client.browse()`) and datablock listing (experimental)
* TIA Portal XML import for SymbolTable (`SymbolTable.from_tia_xml()`) (experimental)
* Partner BSend/BRecv with correct PBC format, async receive, PDU reference echo
* TCP_NODELAY and SO_KEEPALIVE on all sockets for lower latency
* Structured logging with PLC connection context (`snap7.log`)
* Command-line interface (`snap7-cli` / `s7`)
* Multi-variable read optimizer with parallel dispatch (experimental)
* S7 routing for multi-subnet PLC access (experimental)
* Symbolic addressing via SymbolTable (experimental)
* S7CommPlus CPU state reading and block transfer (upload/download)
* Array read/write helpers (`db_read_array`, `db_write_array`)
* Missing data type setters: `set_lint`, `set_ulint`, `set_ltime`, `set_ltod`, `set_ldt`
* **Unified Tag API**: `client.read_tag("DB1.DBD0:REAL")` with PLC4X /
Siemens STEP7 syntax, replacing the homegrown SymbolTable class.
Loaders: `load_csv`, `load_json`, `load_tia_xml` return `dict[str, Tag]`
* **Dual-dialect tag parsing**: `PLC4XTag` and `NodeS7Tag` subtypes of
`Tag` with dialect-specific `parse()` and `__str__` (round-trip).
`parse_tag(s, *, strict=True)` autodetects dialect from syntax markers
(`,` → nodeS7, `:TYPE` → PLC4X); `strict=False` accepts bare short
forms like `M7.1` or `IW22`. Enables pyS7 / Node-RED tag migration.
* **Symbolic (LID-based) access for optimized DBs** (experimental):
`Tag.from_access_string("8A0E0001.A", "REAL")` creates a symbolic Tag;
`client.read_tag(tag)` routes to S7CommPlus LID-based access via the
PLC's symbol tree. Required for S7-1200/1500 DBs with
"Optimized block access" enabled (the TIA Portal V13+ default).
* Optimizer excludes counter/timer areas from byte-range merging
* Fixed `get_cpu_info` field offsets for real S7-300/1500 (thanks @qzertywsx)
* Fixed `S7SZL.__str__` attribute name typo (thanks @qzertywsx)
* Dependabot auto-merge for dependency updates
* Documentation restructured: API Reference + Internals sections

### Thanks

* [@hs2bws-hash](https://github.com/hs2bws-hash) — extensive real PLC testing of Partner BSend/BRecv (#668)
* [@QuakeString](https://github.com/QuakeString) — read optimizer inspiration via python-snap7-optimized fork

3.0.0
-----

Major release: python-snap7 is now a pure Python S7 communication library.
This version completely breaks with the previous approach of wrapping the C snap7
shared library. The entire S7 protocol stack is now implemented in pure Python,
greatly improving portability and making it easier to install and extend.

* **Breaking**: The C snap7 library is no longer required or used
* Complete rewrite of the S7 protocol stack in pure Python
* Native Python implementation of TPKT (RFC 1006) and COTP (ISO 8073) layers
* Native S7 protocol PDU encoding/decoding
* Pure Python server implementation for testing and simulation
* No platform-specific binary dependencies
* No platform-specific binary dependencies — works on any platform that runs Python
* Improved error handling and connection management
* Full type annotations with mypy strict mode
* CLI interface for running an S7 server emulator (`pip install "python-snap7[cli]"`)

If you experience issues with 3.0, pin to the last pre-3.0 release:
If you experience issues with 3.0, please report them on the
[issue tracker](https://github.com/gijzelaerr/python-snap7/issues) with a clear
description and the version you are using. As a workaround, pin to the last
pre-3.0 release:

$ pip install "python-snap7<3"

### Thanks

Special thanks to the following people for testing, reporting issues, and providing
feedback during the 3.0 development:

* [@lupaulus](https://github.com/lupaulus) — extensive testing and bug reports
* [@spreeker](https://github.com/spreeker) — testing and feedback
* [@nikteliy](https://github.com/nikteliy) — review and feedback on the rewrite
* [@amorelettronico](https://github.com/amorelettronico) — testing
* [@razour08](https://github.com/razour08) — testing
* [@core-engineering](https://github.com/core-engineering) — bug reports (#553)
* [@AndreasScharf](https://github.com/AndreasScharf) — bug reports (#572)
* [@Robatronic](https://github.com/Robatronic) — bug reports (#574)
* [@hirotasoshu](https://github.com/hirotasoshu) — feedback (#545)
* [@PoitrasJ](https://github.com/PoitrasJ) — bug reports (#479)

1.2
---

Expand Down
42 changes: 32 additions & 10 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Python-snap7 is a pure Python S7 communication library for interfacing with Siem

## Key Architecture

### snap7/ — Legacy S7 protocol (S7-300/400, PUT/GET on S7-1200/1500)
- **snap7/client.py**: Main Client class for connecting to S7 PLCs
- **snap7/server.py**: Server implementation for PLC simulation
- **snap7/logo.py**: Logo PLC communication
Expand All @@ -19,6 +20,20 @@ Python-snap7 is a pure Python S7 communication library for interfacing with Siem
- **snap7/type.py**: Type definitions and enums (Area, Block, WordLen, etc.)
- **snap7/error.py**: Error handling and exceptions

### s7/ — Unified client with S7CommPlus + legacy fallback
- **s7/client.py**: Unified Client — tries S7CommPlus, falls back to snap7.Client
- **s7/async_client.py**: Unified AsyncClient — same pattern, async
- **s7/server.py**: Unified Server wrapping both legacy and S7CommPlus
- **s7/_protocol.py**: Protocol enum (AUTO/LEGACY/S7COMMPLUS)
- **s7/_s7commplus_client.py**: Pure S7CommPlus sync client (internal)
- **s7/_s7commplus_async_client.py**: Pure S7CommPlus async client (internal)
- **s7/_s7commplus_server.py**: S7CommPlus server emulator (internal)
- **s7/connection.py**: S7CommPlus low-level connection
- **s7/protocol.py**: S7CommPlus protocol constants/enums
- **s7/codec.py**: S7CommPlus encoding/decoding
- **s7/vlq.py**: Variable-Length Quantity encoding
- **s7/legitimation.py**: Authentication helpers

## Implementation Details

### Protocol Stack
Expand All @@ -41,24 +56,31 @@ The library implements the complete S7 protocol stack:
- Block operations (list, info, upload, download)
- Date/time operations

### Usage
### Usage (unified s7 package — recommended for S7-1200/1500)

```python
from s7 import Client

client = Client()
client.connect("192.168.1.10", 0, 1) # auto-detects S7CommPlus vs legacy
data = client.db_read(1, 0, 4)
client.disconnect()
```

### Usage (legacy snap7 package — S7-300/400)

```python
import snap7

# Create and connect client
client = snap7.Client()
client.connect("192.168.1.10", 0, 1)

# Read/write operations
data = client.db_read(1, 0, 4)
client.db_write(1, 0, bytearray([1, 2, 3, 4]))

# Memory area access
marker_data = client.mb_read(0, 4)
client.mb_write(0, 4, bytearray([1, 2, 3, 4]))

# Disconnect
client.disconnect()
```

Expand Down Expand Up @@ -98,15 +120,15 @@ pytest tests/test_client.py
### Code Quality
```bash
# Type checking
mypy snap7 tests example
mypy snap7 s7 tests example

# Linting and formatting check
ruff check snap7 tests example
ruff format --diff snap7 tests example
ruff check snap7 s7 tests example
ruff format --diff snap7 s7 tests example

# Auto-format code
ruff format snap7 tests example
ruff check --fix snap7 tests example
ruff format snap7 s7 tests example
ruff check --fix snap7 s7 tests example
```

### Development with tox
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ doc: .venv/bin/sphinx-build

.PHONY: check
check: .venv/bin/pytest
uv run ruff check snap7 tests example
uv run ruff format --diff snap7 tests example
uv run ruff check snap7 s7 tests example
uv run ruff format --diff snap7 s7 tests example

.PHONY: ruff
ruff: .venv/bin/tox
Expand Down
Loading