snap7-optimized 3.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- snap7_optimized-3.0.0/LICENSE +20 -0
- snap7_optimized-3.0.0/MANIFEST.in +1 -0
- snap7_optimized-3.0.0/PKG-INFO +104 -0
- snap7_optimized-3.0.0/README.rst +62 -0
- snap7_optimized-3.0.0/pyproject.toml +74 -0
- snap7_optimized-3.0.0/setup.cfg +4 -0
- snap7_optimized-3.0.0/snap7/__init__.py +34 -0
- snap7_optimized-3.0.0/snap7/client.py +2123 -0
- snap7_optimized-3.0.0/snap7/connection.py +471 -0
- snap7_optimized-3.0.0/snap7/datatypes.py +312 -0
- snap7_optimized-3.0.0/snap7/error.py +444 -0
- snap7_optimized-3.0.0/snap7/logo.py +222 -0
- snap7_optimized-3.0.0/snap7/optimizer.py +319 -0
- snap7_optimized-3.0.0/snap7/partner.py +680 -0
- snap7_optimized-3.0.0/snap7/py.typed +0 -0
- snap7_optimized-3.0.0/snap7/s7protocol.py +1604 -0
- snap7_optimized-3.0.0/snap7/server/__init__.py +2729 -0
- snap7_optimized-3.0.0/snap7/server/__main__.py +41 -0
- snap7_optimized-3.0.0/snap7/type.py +391 -0
- snap7_optimized-3.0.0/snap7/util/__init__.py +108 -0
- snap7_optimized-3.0.0/snap7/util/db.py +789 -0
- snap7_optimized-3.0.0/snap7/util/getters.py +766 -0
- snap7_optimized-3.0.0/snap7/util/setters.py +733 -0
- snap7_optimized-3.0.0/snap7_optimized.egg-info/PKG-INFO +104 -0
- snap7_optimized-3.0.0/snap7_optimized.egg-info/SOURCES.txt +39 -0
- snap7_optimized-3.0.0/snap7_optimized.egg-info/dependency_links.txt +1 -0
- snap7_optimized-3.0.0/snap7_optimized.egg-info/entry_points.txt +2 -0
- snap7_optimized-3.0.0/snap7_optimized.egg-info/requires.txt +20 -0
- snap7_optimized-3.0.0/snap7_optimized.egg-info/top_level.txt +1 -0
- snap7_optimized-3.0.0/tests/test_api_surface.py +444 -0
- snap7_optimized-3.0.0/tests/test_behavioral_compatibility.py +401 -0
- snap7_optimized-3.0.0/tests/test_client.py +1505 -0
- snap7_optimized-3.0.0/tests/test_client_e2e.py +790 -0
- snap7_optimized-3.0.0/tests/test_datatypes.py +252 -0
- snap7_optimized-3.0.0/tests/test_logo_client.py +128 -0
- snap7_optimized-3.0.0/tests/test_mainloop.py +190 -0
- snap7_optimized-3.0.0/tests/test_multipacket.py +628 -0
- snap7_optimized-3.0.0/tests/test_optimizer.py +340 -0
- snap7_optimized-3.0.0/tests/test_partner.py +120 -0
- snap7_optimized-3.0.0/tests/test_server.py +244 -0
- snap7_optimized-3.0.0/tests/test_util.py +805 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013 Gijs Molenaar, Stephan Preeker
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
include README.rst
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: snap7-optimized
|
|
3
|
+
Version: 3.0.0
|
|
4
|
+
Summary: Pure Python S7 communication library for Siemens PLCs with read optimization pipeline
|
|
5
|
+
Author-email: Gijs Molenaar <gijsmolenaar@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/QuakeString/python-snap7-optimized
|
|
8
|
+
Project-URL: Documentation, https://python-snap7.readthedocs.io/en/latest/
|
|
9
|
+
Keywords: snap7,s7,siemens,plc
|
|
10
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
11
|
+
Classifier: Environment :: Console
|
|
12
|
+
Classifier: Topic :: System :: Hardware
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Intended Audience :: Manufacturing
|
|
15
|
+
Classifier: Operating System :: POSIX
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/x-rst
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Provides-Extra: test
|
|
25
|
+
Requires-Dist: pytest; extra == "test"
|
|
26
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
27
|
+
Requires-Dist: pytest-html; extra == "test"
|
|
28
|
+
Requires-Dist: mypy; extra == "test"
|
|
29
|
+
Requires-Dist: types-setuptools; extra == "test"
|
|
30
|
+
Requires-Dist: ruff; extra == "test"
|
|
31
|
+
Requires-Dist: tox; extra == "test"
|
|
32
|
+
Requires-Dist: tox-uv; extra == "test"
|
|
33
|
+
Requires-Dist: types-click; extra == "test"
|
|
34
|
+
Requires-Dist: uv; extra == "test"
|
|
35
|
+
Provides-Extra: cli
|
|
36
|
+
Requires-Dist: rich; extra == "cli"
|
|
37
|
+
Requires-Dist: click; extra == "cli"
|
|
38
|
+
Provides-Extra: doc
|
|
39
|
+
Requires-Dist: sphinx; extra == "doc"
|
|
40
|
+
Requires-Dist: sphinx_rtd_theme; extra == "doc"
|
|
41
|
+
Dynamic: license-file
|
|
42
|
+
|
|
43
|
+
About
|
|
44
|
+
=====
|
|
45
|
+
|
|
46
|
+
Python-snap7 is a pure Python S7 communication library for interfacing with Siemens S7 PLCs.
|
|
47
|
+
|
|
48
|
+
Python-snap7 is tested with Python 3.10+, on Windows, Linux and OS X.
|
|
49
|
+
|
|
50
|
+
The full documentation is available on `Read The Docs <https://python-snap7.readthedocs.io/en/latest/>`_.
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
Version 3.0 - Breaking Changes
|
|
54
|
+
===============================
|
|
55
|
+
|
|
56
|
+
Version 3.0 is a major release that rewrites python-snap7 as a pure Python
|
|
57
|
+
implementation. The C snap7 library is no longer required.
|
|
58
|
+
|
|
59
|
+
This release may contain breaking changes. If you experience issues, you can
|
|
60
|
+
pin to the last pre-3.0 release::
|
|
61
|
+
|
|
62
|
+
$ pip install "python-snap7<3"
|
|
63
|
+
|
|
64
|
+
The latest stable pre-3.0 release is version 2.1.0.
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
Fork: Optimized Multi-Read Pipeline
|
|
68
|
+
=====================================
|
|
69
|
+
|
|
70
|
+
This fork (`python-snap7-optimized <https://github.com/QuakeString/python-snap7-optimized>`_)
|
|
71
|
+
adds a transparent **nodeS7-style read optimization pipeline** to the upstream
|
|
72
|
+
`python-snap7 <https://github.com/gijzelaerr/python-snap7>`_ library.
|
|
73
|
+
|
|
74
|
+
When ``read_multi_vars()`` is called with multiple items targeting standard memory
|
|
75
|
+
areas (DB, M, I, Q), the library now automatically:
|
|
76
|
+
|
|
77
|
+
1. **Sorts** requests by area, DB number, and byte offset.
|
|
78
|
+
2. **Merges** adjacent or nearby requests (gap ≤ 5 bytes) into contiguous blocks,
|
|
79
|
+
eliminating redundant reads of overlapping or neighboring addresses.
|
|
80
|
+
3. **Packetizes** merged blocks into minimal S7 PDU-sized packets, respecting both
|
|
81
|
+
request and reply budget limits.
|
|
82
|
+
|
|
83
|
+
The result is dramatically fewer network round-trips — hundreds of scattered variable
|
|
84
|
+
reads can collapse into just a few multi-item S7 protocol exchanges.
|
|
85
|
+
|
|
86
|
+
**No API changes required.** Existing code using ``read_multi_vars()`` benefits
|
|
87
|
+
automatically. Counter/Timer areas (CT/TM) fall back to individual reads due to
|
|
88
|
+
their different addressing semantics.
|
|
89
|
+
|
|
90
|
+
New modules:
|
|
91
|
+
|
|
92
|
+
- ``snap7/optimizer.py`` — Pure-logic 3-stage pipeline (sort → merge → packetize).
|
|
93
|
+
- Extended ``snap7/s7protocol.py`` — Multi-item S7 read request building and response parsing.
|
|
94
|
+
- Extended ``snap7/server/__init__.py`` — Server-side multi-item read support for testing.
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
Installation
|
|
98
|
+
============
|
|
99
|
+
|
|
100
|
+
Install using pip::
|
|
101
|
+
|
|
102
|
+
$ pip install python-snap7
|
|
103
|
+
|
|
104
|
+
No native libraries or platform-specific dependencies are required - python-snap7 is a pure Python package that works on all platforms.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
About
|
|
2
|
+
=====
|
|
3
|
+
|
|
4
|
+
Python-snap7 is a pure Python S7 communication library for interfacing with Siemens S7 PLCs.
|
|
5
|
+
|
|
6
|
+
Python-snap7 is tested with Python 3.10+, on Windows, Linux and OS X.
|
|
7
|
+
|
|
8
|
+
The full documentation is available on `Read The Docs <https://python-snap7.readthedocs.io/en/latest/>`_.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
Version 3.0 - Breaking Changes
|
|
12
|
+
===============================
|
|
13
|
+
|
|
14
|
+
Version 3.0 is a major release that rewrites python-snap7 as a pure Python
|
|
15
|
+
implementation. The C snap7 library is no longer required.
|
|
16
|
+
|
|
17
|
+
This release may contain breaking changes. If you experience issues, you can
|
|
18
|
+
pin to the last pre-3.0 release::
|
|
19
|
+
|
|
20
|
+
$ pip install "python-snap7<3"
|
|
21
|
+
|
|
22
|
+
The latest stable pre-3.0 release is version 2.1.0.
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
Fork: Optimized Multi-Read Pipeline
|
|
26
|
+
=====================================
|
|
27
|
+
|
|
28
|
+
This fork (`python-snap7-optimized <https://github.com/QuakeString/python-snap7-optimized>`_)
|
|
29
|
+
adds a transparent **nodeS7-style read optimization pipeline** to the upstream
|
|
30
|
+
`python-snap7 <https://github.com/gijzelaerr/python-snap7>`_ library.
|
|
31
|
+
|
|
32
|
+
When ``read_multi_vars()`` is called with multiple items targeting standard memory
|
|
33
|
+
areas (DB, M, I, Q), the library now automatically:
|
|
34
|
+
|
|
35
|
+
1. **Sorts** requests by area, DB number, and byte offset.
|
|
36
|
+
2. **Merges** adjacent or nearby requests (gap ≤ 5 bytes) into contiguous blocks,
|
|
37
|
+
eliminating redundant reads of overlapping or neighboring addresses.
|
|
38
|
+
3. **Packetizes** merged blocks into minimal S7 PDU-sized packets, respecting both
|
|
39
|
+
request and reply budget limits.
|
|
40
|
+
|
|
41
|
+
The result is dramatically fewer network round-trips — hundreds of scattered variable
|
|
42
|
+
reads can collapse into just a few multi-item S7 protocol exchanges.
|
|
43
|
+
|
|
44
|
+
**No API changes required.** Existing code using ``read_multi_vars()`` benefits
|
|
45
|
+
automatically. Counter/Timer areas (CT/TM) fall back to individual reads due to
|
|
46
|
+
their different addressing semantics.
|
|
47
|
+
|
|
48
|
+
New modules:
|
|
49
|
+
|
|
50
|
+
- ``snap7/optimizer.py`` — Pure-logic 3-stage pipeline (sort → merge → packetize).
|
|
51
|
+
- Extended ``snap7/s7protocol.py`` — Multi-item S7 read request building and response parsing.
|
|
52
|
+
- Extended ``snap7/server/__init__.py`` — Server-side multi-item read support for testing.
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
Installation
|
|
56
|
+
============
|
|
57
|
+
|
|
58
|
+
Install using pip::
|
|
59
|
+
|
|
60
|
+
$ pip install python-snap7
|
|
61
|
+
|
|
62
|
+
No native libraries or platform-specific dependencies are required - python-snap7 is a pure Python package that works on all platforms.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "snap7-optimized"
|
|
7
|
+
version = "3.0.0"
|
|
8
|
+
description = "Pure Python S7 communication library for Siemens PLCs with read optimization pipeline"
|
|
9
|
+
readme = "README.rst"
|
|
10
|
+
authors = [
|
|
11
|
+
{name = "Gijs Molenaar", email = "gijsmolenaar@gmail.com"},
|
|
12
|
+
]
|
|
13
|
+
classifiers = [
|
|
14
|
+
"Development Status :: 5 - Production/Stable",
|
|
15
|
+
"Environment :: Console",
|
|
16
|
+
"Topic :: System :: Hardware",
|
|
17
|
+
"Intended Audience :: Developers",
|
|
18
|
+
"Intended Audience :: Manufacturing",
|
|
19
|
+
"Operating System :: POSIX",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Programming Language :: Python :: 3.13",
|
|
24
|
+
"Programming Language :: Python :: 3.14",
|
|
25
|
+
]
|
|
26
|
+
license = {text = "MIT"}
|
|
27
|
+
requires-python = ">=3.10"
|
|
28
|
+
keywords = ["snap7", "s7", "siemens", "plc"]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/QuakeString/python-snap7-optimized"
|
|
32
|
+
Documentation = "https://python-snap7.readthedocs.io/en/latest/"
|
|
33
|
+
|
|
34
|
+
[project.optional-dependencies]
|
|
35
|
+
test = ["pytest", "pytest-cov", "pytest-html", "mypy", "types-setuptools", "ruff", "tox", "tox-uv", "types-click", "uv"]
|
|
36
|
+
cli = ["rich", "click" ]
|
|
37
|
+
doc = ["sphinx", "sphinx_rtd_theme"]
|
|
38
|
+
|
|
39
|
+
[tool.setuptools.package-data]
|
|
40
|
+
snap7 = ["py.typed"]
|
|
41
|
+
|
|
42
|
+
[tool.setuptools.packages.find]
|
|
43
|
+
include = ["snap7*"]
|
|
44
|
+
|
|
45
|
+
[project.scripts]
|
|
46
|
+
snap7-server = "snap7.server:mainloop"
|
|
47
|
+
|
|
48
|
+
[tool.pytest.ini_options]
|
|
49
|
+
testpaths = ["tests"]
|
|
50
|
+
markers =[
|
|
51
|
+
"client",
|
|
52
|
+
"common",
|
|
53
|
+
"e2e: end-to-end tests requiring a real PLC connection",
|
|
54
|
+
"logo",
|
|
55
|
+
"mainloop",
|
|
56
|
+
"partner",
|
|
57
|
+
"server",
|
|
58
|
+
"util"
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
[tool.mypy]
|
|
62
|
+
ignore_missing_imports = true
|
|
63
|
+
strict = true
|
|
64
|
+
# https://github.com/python/mypy/issues/2427#issuecomment-1419206807
|
|
65
|
+
disable_error_code = ["method-assign", "attr-defined"]
|
|
66
|
+
|
|
67
|
+
[tool.ruff]
|
|
68
|
+
output-format = "full"
|
|
69
|
+
line-length = 130
|
|
70
|
+
target-version = "py310"
|
|
71
|
+
|
|
72
|
+
[tool.ruff.lint]
|
|
73
|
+
ignore = []
|
|
74
|
+
mccabe.max-complexity = 10
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"""
|
|
2
|
+
The Snap7 Python library.
|
|
3
|
+
|
|
4
|
+
Pure Python implementation of the S7 protocol for communicating with
|
|
5
|
+
Siemens S7 PLCs without requiring the native Snap7 C library.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
9
|
+
|
|
10
|
+
from .client import Client
|
|
11
|
+
from .server import Server
|
|
12
|
+
from .partner import Partner
|
|
13
|
+
from .logo import Logo
|
|
14
|
+
from .util.db import Row, DB
|
|
15
|
+
from .type import Area, Block, WordLen, SrvEvent, SrvArea
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"Client",
|
|
19
|
+
"Server",
|
|
20
|
+
"Partner",
|
|
21
|
+
"Logo",
|
|
22
|
+
"Row",
|
|
23
|
+
"DB",
|
|
24
|
+
"Area",
|
|
25
|
+
"Block",
|
|
26
|
+
"WordLen",
|
|
27
|
+
"SrvEvent",
|
|
28
|
+
"SrvArea",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
try:
|
|
32
|
+
__version__ = version("python-snap7")
|
|
33
|
+
except PackageNotFoundError:
|
|
34
|
+
__version__ = "0.0rc0"
|