python-snap7 2.1.0__tar.gz → 3.1.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.
- python_snap7-3.1.0/PKG-INFO +131 -0
- python_snap7-3.1.0/README.rst +81 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/pyproject.toml +7 -2
- python_snap7-3.1.0/python_snap7.egg-info/PKG-INFO +131 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/python_snap7.egg-info/SOURCES.txt +25 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/python_snap7.egg-info/entry_points.txt +1 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/python_snap7.egg-info/requires.txt +11 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/snap7/__init__.py +11 -0
- python_snap7-3.1.0/snap7/async_client.py +1176 -0
- python_snap7-3.1.0/snap7/cli.py +416 -0
- python_snap7-3.1.0/snap7/client.py +2665 -0
- python_snap7-3.1.0/snap7/client_base.py +252 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/snap7/connection.py +130 -3
- {python_snap7-2.1.0 → python_snap7-3.1.0}/snap7/datatypes.py +22 -21
- python_snap7-3.1.0/snap7/demo.py +471 -0
- python_snap7-3.1.0/snap7/discovery.py +137 -0
- python_snap7-3.1.0/snap7/error.py +444 -0
- python_snap7-3.1.0/snap7/log.py +144 -0
- python_snap7-3.1.0/snap7/optimizer.py +293 -0
- python_snap7-3.1.0/snap7/partner.py +1109 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/snap7/s7protocol.py +221 -30
- {python_snap7-2.1.0 → python_snap7-3.1.0}/snap7/server/__init__.py +144 -82
- python_snap7-3.1.0/snap7/szl.py +115 -0
- python_snap7-3.1.0/snap7/tags.py +820 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/snap7/type.py +3 -3
- {python_snap7-2.1.0 → python_snap7-3.1.0}/snap7/util/__init__.py +36 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/snap7/util/db.py +30 -3
- {python_snap7-2.1.0 → python_snap7-3.1.0}/snap7/util/getters.py +116 -58
- python_snap7-3.1.0/snap7/util/setters.py +868 -0
- python_snap7-3.1.0/snap7/util/symbols.py +547 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/tests/test_api_surface.py +4 -0
- python_snap7-3.1.0/tests/test_async_client.py +384 -0
- python_snap7-3.1.0/tests/test_cli.py +170 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/tests/test_client.py +245 -4
- {python_snap7-2.1.0 → python_snap7-3.1.0}/tests/test_client_e2e.py +7 -1
- python_snap7-3.1.0/tests/test_demo.py +163 -0
- python_snap7-3.1.0/tests/test_discovery.py +167 -0
- python_snap7-3.1.0/tests/test_finalize.py +33 -0
- python_snap7-3.1.0/tests/test_hypothesis.py +570 -0
- python_snap7-3.1.0/tests/test_logging.py +99 -0
- python_snap7-3.1.0/tests/test_logo_client.py +371 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/tests/test_multipacket.py +98 -2
- python_snap7-3.1.0/tests/test_optimizer.py +345 -0
- python_snap7-3.1.0/tests/test_partner.py +752 -0
- python_snap7-3.1.0/tests/test_property.py +234 -0
- python_snap7-3.1.0/tests/test_reconnect.py +447 -0
- python_snap7-3.1.0/tests/test_routing.py +225 -0
- python_snap7-3.1.0/tests/test_s7protocol.py +580 -0
- python_snap7-3.1.0/tests/test_server.py +596 -0
- python_snap7-3.1.0/tests/test_stress.py +127 -0
- python_snap7-3.1.0/tests/test_tags.py +554 -0
- python_snap7-3.1.0/tests/test_typed_access.py +202 -0
- python_snap7-3.1.0/tests/test_util.py +1480 -0
- python_snap7-2.1.0/PKG-INFO +0 -59
- python_snap7-2.1.0/README.rst +0 -18
- python_snap7-2.1.0/python_snap7.egg-info/PKG-INFO +0 -59
- python_snap7-2.1.0/snap7/client.py +0 -1965
- python_snap7-2.1.0/snap7/error.py +0 -202
- python_snap7-2.1.0/snap7/partner.py +0 -680
- python_snap7-2.1.0/snap7/util/setters.py +0 -535
- python_snap7-2.1.0/tests/test_logo_client.py +0 -128
- python_snap7-2.1.0/tests/test_partner.py +0 -120
- python_snap7-2.1.0/tests/test_server.py +0 -244
- python_snap7-2.1.0/tests/test_util.py +0 -631
- {python_snap7-2.1.0 → python_snap7-3.1.0}/LICENSE +0 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/MANIFEST.in +0 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/python_snap7.egg-info/dependency_links.txt +0 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/python_snap7.egg-info/top_level.txt +0 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/setup.cfg +0 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/snap7/logo.py +0 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/snap7/py.typed +0 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/snap7/server/__main__.py +0 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/tests/test_behavioral_compatibility.py +0 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/tests/test_datatypes.py +0 -0
- {python_snap7-2.1.0 → python_snap7-3.1.0}/tests/test_mainloop.py +0 -0
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-snap7
|
|
3
|
+
Version: 3.1.0
|
|
4
|
+
Summary: Pure Python S7 communication library for Siemens PLCs
|
|
5
|
+
Author-email: Gijs Molenaar <gijsmolenaar@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/gijzelaerr/python-snap7
|
|
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-asyncio; extra == "test"
|
|
27
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
28
|
+
Requires-Dist: pytest-html; extra == "test"
|
|
29
|
+
Requires-Dist: hypothesis; extra == "test"
|
|
30
|
+
Requires-Dist: mypy; extra == "test"
|
|
31
|
+
Requires-Dist: types-setuptools; extra == "test"
|
|
32
|
+
Requires-Dist: ruff; extra == "test"
|
|
33
|
+
Requires-Dist: tox; extra == "test"
|
|
34
|
+
Requires-Dist: tox-uv; extra == "test"
|
|
35
|
+
Requires-Dist: types-click; extra == "test"
|
|
36
|
+
Requires-Dist: uv; extra == "test"
|
|
37
|
+
Provides-Extra: cli
|
|
38
|
+
Requires-Dist: rich; extra == "cli"
|
|
39
|
+
Requires-Dist: click; extra == "cli"
|
|
40
|
+
Provides-Extra: demo
|
|
41
|
+
Requires-Dist: psutil; extra == "demo"
|
|
42
|
+
Requires-Dist: rich; extra == "demo"
|
|
43
|
+
Requires-Dist: click; extra == "demo"
|
|
44
|
+
Provides-Extra: doc
|
|
45
|
+
Requires-Dist: sphinx; extra == "doc"
|
|
46
|
+
Requires-Dist: sphinx_rtd_theme; extra == "doc"
|
|
47
|
+
Provides-Extra: discovery
|
|
48
|
+
Requires-Dist: pnio-dcp; extra == "discovery"
|
|
49
|
+
Dynamic: license-file
|
|
50
|
+
|
|
51
|
+
About
|
|
52
|
+
=====
|
|
53
|
+
|
|
54
|
+
Python-snap7 is a pure Python S7 communication library for interfacing with Siemens S7 PLCs.
|
|
55
|
+
|
|
56
|
+
The name "python-snap7" is historical — the library originally started as a Python wrapper
|
|
57
|
+
around the `Snap7 <http://snap7.sourceforge.net/>`_ C library. As of version 3.0, the C
|
|
58
|
+
library is no longer used, but the name is kept for backwards compatibility.
|
|
59
|
+
|
|
60
|
+
Python-snap7 is tested with Python 3.10+, on Windows, Linux and OS X.
|
|
61
|
+
|
|
62
|
+
The full documentation is available on `Read The Docs <https://python-snap7.readthedocs.io/en/latest/>`_.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
Quick Start
|
|
66
|
+
===========
|
|
67
|
+
|
|
68
|
+
Connect to any S7 PLC::
|
|
69
|
+
|
|
70
|
+
import snap7
|
|
71
|
+
|
|
72
|
+
client = snap7.Client()
|
|
73
|
+
client.connect("192.168.1.10", 0, 1)
|
|
74
|
+
data = client.db_read(1, 0, 4)
|
|
75
|
+
client.disconnect()
|
|
76
|
+
|
|
77
|
+
No native libraries or platform-specific dependencies are required.
|
|
78
|
+
|
|
79
|
+
Async support::
|
|
80
|
+
|
|
81
|
+
import asyncio
|
|
82
|
+
import snap7
|
|
83
|
+
|
|
84
|
+
async def main():
|
|
85
|
+
async with snap7.AsyncClient() as client:
|
|
86
|
+
await client.connect("192.168.1.10", 0, 1)
|
|
87
|
+
data = await client.db_read(1, 0, 4)
|
|
88
|
+
|
|
89
|
+
asyncio.run(main())
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
What's New in 3.1
|
|
93
|
+
=================
|
|
94
|
+
|
|
95
|
+
* **AsyncClient** for ``asyncio`` support
|
|
96
|
+
* **Tag API** -- read/write by name: ``client.read_tag("DB1.DBD0:REAL")``
|
|
97
|
+
with PLC4X and nodeS7 dialect support
|
|
98
|
+
* **Multi-variable read optimizer** -- merges scattered reads into minimal
|
|
99
|
+
PDU exchanges
|
|
100
|
+
* **S7 routing** -- connect to PLCs on remote subnets via a gateway PLC
|
|
101
|
+
* **Heartbeat monitoring** and auto-reconnect with exponential backoff
|
|
102
|
+
* **Structured logging** with PLC connection context
|
|
103
|
+
* **PROFINET DCP** network discovery
|
|
104
|
+
* **CLI tools** for PLC interaction (``pip install "python-snap7[cli]"``)
|
|
105
|
+
* Numerous bug fixes -- see `CHANGES.md <https://github.com/gijzelaerr/python-snap7/blob/master/CHANGES.md>`_
|
|
106
|
+
for the full list
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
Version 3.0 -- Pure Python Rewrite
|
|
110
|
+
====================================
|
|
111
|
+
|
|
112
|
+
Version 3.0 was a ground-up rewrite of python-snap7. The library no longer wraps
|
|
113
|
+
the C snap7 shared library -- instead, the entire S7 protocol stack (TPKT, COTP,
|
|
114
|
+
and S7) is implemented in pure Python.
|
|
115
|
+
|
|
116
|
+
* **Portability**: No more platform-specific shared libraries (``.dll``, ``.so``, ``.dylib``).
|
|
117
|
+
Works on any platform that runs Python -- including ARM, Alpine Linux, and other
|
|
118
|
+
environments where the C library was difficult or impossible to install.
|
|
119
|
+
* **Easier installation**: Just ``pip install python-snap7``. No native dependencies,
|
|
120
|
+
no compiler toolchains, no manual library setup.
|
|
121
|
+
* **Easier to extend**: New features and protocol support can be added directly in Python.
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
Installation
|
|
125
|
+
============
|
|
126
|
+
|
|
127
|
+
Install using pip::
|
|
128
|
+
|
|
129
|
+
$ pip install python-snap7
|
|
130
|
+
|
|
131
|
+
No native libraries or platform-specific dependencies are required — python-snap7 is a pure Python package that works on all platforms.
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
About
|
|
2
|
+
=====
|
|
3
|
+
|
|
4
|
+
Python-snap7 is a pure Python S7 communication library for interfacing with Siemens S7 PLCs.
|
|
5
|
+
|
|
6
|
+
The name "python-snap7" is historical — the library originally started as a Python wrapper
|
|
7
|
+
around the `Snap7 <http://snap7.sourceforge.net/>`_ C library. As of version 3.0, the C
|
|
8
|
+
library is no longer used, but the name is kept for backwards compatibility.
|
|
9
|
+
|
|
10
|
+
Python-snap7 is tested with Python 3.10+, on Windows, Linux and OS X.
|
|
11
|
+
|
|
12
|
+
The full documentation is available on `Read The Docs <https://python-snap7.readthedocs.io/en/latest/>`_.
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
Quick Start
|
|
16
|
+
===========
|
|
17
|
+
|
|
18
|
+
Connect to any S7 PLC::
|
|
19
|
+
|
|
20
|
+
import snap7
|
|
21
|
+
|
|
22
|
+
client = snap7.Client()
|
|
23
|
+
client.connect("192.168.1.10", 0, 1)
|
|
24
|
+
data = client.db_read(1, 0, 4)
|
|
25
|
+
client.disconnect()
|
|
26
|
+
|
|
27
|
+
No native libraries or platform-specific dependencies are required.
|
|
28
|
+
|
|
29
|
+
Async support::
|
|
30
|
+
|
|
31
|
+
import asyncio
|
|
32
|
+
import snap7
|
|
33
|
+
|
|
34
|
+
async def main():
|
|
35
|
+
async with snap7.AsyncClient() as client:
|
|
36
|
+
await client.connect("192.168.1.10", 0, 1)
|
|
37
|
+
data = await client.db_read(1, 0, 4)
|
|
38
|
+
|
|
39
|
+
asyncio.run(main())
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
What's New in 3.1
|
|
43
|
+
=================
|
|
44
|
+
|
|
45
|
+
* **AsyncClient** for ``asyncio`` support
|
|
46
|
+
* **Tag API** -- read/write by name: ``client.read_tag("DB1.DBD0:REAL")``
|
|
47
|
+
with PLC4X and nodeS7 dialect support
|
|
48
|
+
* **Multi-variable read optimizer** -- merges scattered reads into minimal
|
|
49
|
+
PDU exchanges
|
|
50
|
+
* **S7 routing** -- connect to PLCs on remote subnets via a gateway PLC
|
|
51
|
+
* **Heartbeat monitoring** and auto-reconnect with exponential backoff
|
|
52
|
+
* **Structured logging** with PLC connection context
|
|
53
|
+
* **PROFINET DCP** network discovery
|
|
54
|
+
* **CLI tools** for PLC interaction (``pip install "python-snap7[cli]"``)
|
|
55
|
+
* Numerous bug fixes -- see `CHANGES.md <https://github.com/gijzelaerr/python-snap7/blob/master/CHANGES.md>`_
|
|
56
|
+
for the full list
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
Version 3.0 -- Pure Python Rewrite
|
|
60
|
+
====================================
|
|
61
|
+
|
|
62
|
+
Version 3.0 was a ground-up rewrite of python-snap7. The library no longer wraps
|
|
63
|
+
the C snap7 shared library -- instead, the entire S7 protocol stack (TPKT, COTP,
|
|
64
|
+
and S7) is implemented in pure Python.
|
|
65
|
+
|
|
66
|
+
* **Portability**: No more platform-specific shared libraries (``.dll``, ``.so``, ``.dylib``).
|
|
67
|
+
Works on any platform that runs Python -- including ARM, Alpine Linux, and other
|
|
68
|
+
environments where the C library was difficult or impossible to install.
|
|
69
|
+
* **Easier installation**: Just ``pip install python-snap7``. No native dependencies,
|
|
70
|
+
no compiler toolchains, no manual library setup.
|
|
71
|
+
* **Easier to extend**: New features and protocol support can be added directly in Python.
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
Installation
|
|
75
|
+
============
|
|
76
|
+
|
|
77
|
+
Install using pip::
|
|
78
|
+
|
|
79
|
+
$ pip install python-snap7
|
|
80
|
+
|
|
81
|
+
No native libraries or platform-specific dependencies are required — python-snap7 is a pure Python package that works on all platforms.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "python-snap7"
|
|
7
|
-
version = "
|
|
7
|
+
version = "3.1.0"
|
|
8
8
|
description = "Pure Python S7 communication library for Siemens PLCs"
|
|
9
9
|
readme = "README.rst"
|
|
10
10
|
authors = [
|
|
@@ -32,9 +32,11 @@ Homepage = "https://github.com/gijzelaerr/python-snap7"
|
|
|
32
32
|
Documentation = "https://python-snap7.readthedocs.io/en/latest/"
|
|
33
33
|
|
|
34
34
|
[project.optional-dependencies]
|
|
35
|
-
test = ["pytest", "pytest-html", "mypy", "types-setuptools", "ruff", "tox", "tox-uv", "types-click", "uv"]
|
|
35
|
+
test = ["pytest", "pytest-asyncio", "pytest-cov", "pytest-html", "hypothesis", "mypy", "types-setuptools", "ruff", "tox", "tox-uv", "types-click", "uv"]
|
|
36
36
|
cli = ["rich", "click" ]
|
|
37
|
+
demo = ["psutil", "rich", "click"]
|
|
37
38
|
doc = ["sphinx", "sphinx_rtd_theme"]
|
|
39
|
+
discovery = ["pnio-dcp"]
|
|
38
40
|
|
|
39
41
|
[tool.setuptools.package-data]
|
|
40
42
|
snap7 = ["py.typed"]
|
|
@@ -44,6 +46,7 @@ include = ["snap7*"]
|
|
|
44
46
|
|
|
45
47
|
[project.scripts]
|
|
46
48
|
snap7-server = "snap7.server:mainloop"
|
|
49
|
+
s7 = "snap7.cli:main"
|
|
47
50
|
|
|
48
51
|
[tool.pytest.ini_options]
|
|
49
52
|
testpaths = ["tests"]
|
|
@@ -51,9 +54,11 @@ markers =[
|
|
|
51
54
|
"client",
|
|
52
55
|
"common",
|
|
53
56
|
"e2e: end-to-end tests requiring a real PLC connection",
|
|
57
|
+
"hypothesis: property-based tests using Hypothesis",
|
|
54
58
|
"logo",
|
|
55
59
|
"mainloop",
|
|
56
60
|
"partner",
|
|
61
|
+
"routing",
|
|
57
62
|
"server",
|
|
58
63
|
"util"
|
|
59
64
|
]
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-snap7
|
|
3
|
+
Version: 3.1.0
|
|
4
|
+
Summary: Pure Python S7 communication library for Siemens PLCs
|
|
5
|
+
Author-email: Gijs Molenaar <gijsmolenaar@gmail.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/gijzelaerr/python-snap7
|
|
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-asyncio; extra == "test"
|
|
27
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
28
|
+
Requires-Dist: pytest-html; extra == "test"
|
|
29
|
+
Requires-Dist: hypothesis; extra == "test"
|
|
30
|
+
Requires-Dist: mypy; extra == "test"
|
|
31
|
+
Requires-Dist: types-setuptools; extra == "test"
|
|
32
|
+
Requires-Dist: ruff; extra == "test"
|
|
33
|
+
Requires-Dist: tox; extra == "test"
|
|
34
|
+
Requires-Dist: tox-uv; extra == "test"
|
|
35
|
+
Requires-Dist: types-click; extra == "test"
|
|
36
|
+
Requires-Dist: uv; extra == "test"
|
|
37
|
+
Provides-Extra: cli
|
|
38
|
+
Requires-Dist: rich; extra == "cli"
|
|
39
|
+
Requires-Dist: click; extra == "cli"
|
|
40
|
+
Provides-Extra: demo
|
|
41
|
+
Requires-Dist: psutil; extra == "demo"
|
|
42
|
+
Requires-Dist: rich; extra == "demo"
|
|
43
|
+
Requires-Dist: click; extra == "demo"
|
|
44
|
+
Provides-Extra: doc
|
|
45
|
+
Requires-Dist: sphinx; extra == "doc"
|
|
46
|
+
Requires-Dist: sphinx_rtd_theme; extra == "doc"
|
|
47
|
+
Provides-Extra: discovery
|
|
48
|
+
Requires-Dist: pnio-dcp; extra == "discovery"
|
|
49
|
+
Dynamic: license-file
|
|
50
|
+
|
|
51
|
+
About
|
|
52
|
+
=====
|
|
53
|
+
|
|
54
|
+
Python-snap7 is a pure Python S7 communication library for interfacing with Siemens S7 PLCs.
|
|
55
|
+
|
|
56
|
+
The name "python-snap7" is historical — the library originally started as a Python wrapper
|
|
57
|
+
around the `Snap7 <http://snap7.sourceforge.net/>`_ C library. As of version 3.0, the C
|
|
58
|
+
library is no longer used, but the name is kept for backwards compatibility.
|
|
59
|
+
|
|
60
|
+
Python-snap7 is tested with Python 3.10+, on Windows, Linux and OS X.
|
|
61
|
+
|
|
62
|
+
The full documentation is available on `Read The Docs <https://python-snap7.readthedocs.io/en/latest/>`_.
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
Quick Start
|
|
66
|
+
===========
|
|
67
|
+
|
|
68
|
+
Connect to any S7 PLC::
|
|
69
|
+
|
|
70
|
+
import snap7
|
|
71
|
+
|
|
72
|
+
client = snap7.Client()
|
|
73
|
+
client.connect("192.168.1.10", 0, 1)
|
|
74
|
+
data = client.db_read(1, 0, 4)
|
|
75
|
+
client.disconnect()
|
|
76
|
+
|
|
77
|
+
No native libraries or platform-specific dependencies are required.
|
|
78
|
+
|
|
79
|
+
Async support::
|
|
80
|
+
|
|
81
|
+
import asyncio
|
|
82
|
+
import snap7
|
|
83
|
+
|
|
84
|
+
async def main():
|
|
85
|
+
async with snap7.AsyncClient() as client:
|
|
86
|
+
await client.connect("192.168.1.10", 0, 1)
|
|
87
|
+
data = await client.db_read(1, 0, 4)
|
|
88
|
+
|
|
89
|
+
asyncio.run(main())
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
What's New in 3.1
|
|
93
|
+
=================
|
|
94
|
+
|
|
95
|
+
* **AsyncClient** for ``asyncio`` support
|
|
96
|
+
* **Tag API** -- read/write by name: ``client.read_tag("DB1.DBD0:REAL")``
|
|
97
|
+
with PLC4X and nodeS7 dialect support
|
|
98
|
+
* **Multi-variable read optimizer** -- merges scattered reads into minimal
|
|
99
|
+
PDU exchanges
|
|
100
|
+
* **S7 routing** -- connect to PLCs on remote subnets via a gateway PLC
|
|
101
|
+
* **Heartbeat monitoring** and auto-reconnect with exponential backoff
|
|
102
|
+
* **Structured logging** with PLC connection context
|
|
103
|
+
* **PROFINET DCP** network discovery
|
|
104
|
+
* **CLI tools** for PLC interaction (``pip install "python-snap7[cli]"``)
|
|
105
|
+
* Numerous bug fixes -- see `CHANGES.md <https://github.com/gijzelaerr/python-snap7/blob/master/CHANGES.md>`_
|
|
106
|
+
for the full list
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
Version 3.0 -- Pure Python Rewrite
|
|
110
|
+
====================================
|
|
111
|
+
|
|
112
|
+
Version 3.0 was a ground-up rewrite of python-snap7. The library no longer wraps
|
|
113
|
+
the C snap7 shared library -- instead, the entire S7 protocol stack (TPKT, COTP,
|
|
114
|
+
and S7) is implemented in pure Python.
|
|
115
|
+
|
|
116
|
+
* **Portability**: No more platform-specific shared libraries (``.dll``, ``.so``, ``.dylib``).
|
|
117
|
+
Works on any platform that runs Python -- including ARM, Alpine Linux, and other
|
|
118
|
+
environments where the C library was difficult or impossible to install.
|
|
119
|
+
* **Easier installation**: Just ``pip install python-snap7``. No native dependencies,
|
|
120
|
+
no compiler toolchains, no manual library setup.
|
|
121
|
+
* **Easier to extend**: New features and protocol support can be added directly in Python.
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
Installation
|
|
125
|
+
============
|
|
126
|
+
|
|
127
|
+
Install using pip::
|
|
128
|
+
|
|
129
|
+
$ pip install python-snap7
|
|
130
|
+
|
|
131
|
+
No native libraries or platform-specific dependencies are required — python-snap7 is a pure Python package that works on all platforms.
|
|
@@ -9,14 +9,23 @@ python_snap7.egg-info/entry_points.txt
|
|
|
9
9
|
python_snap7.egg-info/requires.txt
|
|
10
10
|
python_snap7.egg-info/top_level.txt
|
|
11
11
|
snap7/__init__.py
|
|
12
|
+
snap7/async_client.py
|
|
13
|
+
snap7/cli.py
|
|
12
14
|
snap7/client.py
|
|
15
|
+
snap7/client_base.py
|
|
13
16
|
snap7/connection.py
|
|
14
17
|
snap7/datatypes.py
|
|
18
|
+
snap7/demo.py
|
|
19
|
+
snap7/discovery.py
|
|
15
20
|
snap7/error.py
|
|
21
|
+
snap7/log.py
|
|
16
22
|
snap7/logo.py
|
|
23
|
+
snap7/optimizer.py
|
|
17
24
|
snap7/partner.py
|
|
18
25
|
snap7/py.typed
|
|
19
26
|
snap7/s7protocol.py
|
|
27
|
+
snap7/szl.py
|
|
28
|
+
snap7/tags.py
|
|
20
29
|
snap7/type.py
|
|
21
30
|
snap7/server/__init__.py
|
|
22
31
|
snap7/server/__main__.py
|
|
@@ -24,14 +33,30 @@ snap7/util/__init__.py
|
|
|
24
33
|
snap7/util/db.py
|
|
25
34
|
snap7/util/getters.py
|
|
26
35
|
snap7/util/setters.py
|
|
36
|
+
snap7/util/symbols.py
|
|
27
37
|
tests/test_api_surface.py
|
|
38
|
+
tests/test_async_client.py
|
|
28
39
|
tests/test_behavioral_compatibility.py
|
|
40
|
+
tests/test_cli.py
|
|
29
41
|
tests/test_client.py
|
|
30
42
|
tests/test_client_e2e.py
|
|
31
43
|
tests/test_datatypes.py
|
|
44
|
+
tests/test_demo.py
|
|
45
|
+
tests/test_discovery.py
|
|
46
|
+
tests/test_finalize.py
|
|
47
|
+
tests/test_hypothesis.py
|
|
48
|
+
tests/test_logging.py
|
|
32
49
|
tests/test_logo_client.py
|
|
33
50
|
tests/test_mainloop.py
|
|
34
51
|
tests/test_multipacket.py
|
|
52
|
+
tests/test_optimizer.py
|
|
35
53
|
tests/test_partner.py
|
|
54
|
+
tests/test_property.py
|
|
55
|
+
tests/test_reconnect.py
|
|
56
|
+
tests/test_routing.py
|
|
57
|
+
tests/test_s7protocol.py
|
|
36
58
|
tests/test_server.py
|
|
59
|
+
tests/test_stress.py
|
|
60
|
+
tests/test_tags.py
|
|
61
|
+
tests/test_typed_access.py
|
|
37
62
|
tests/test_util.py
|
|
@@ -3,13 +3,24 @@
|
|
|
3
3
|
rich
|
|
4
4
|
click
|
|
5
5
|
|
|
6
|
+
[demo]
|
|
7
|
+
psutil
|
|
8
|
+
rich
|
|
9
|
+
click
|
|
10
|
+
|
|
11
|
+
[discovery]
|
|
12
|
+
pnio-dcp
|
|
13
|
+
|
|
6
14
|
[doc]
|
|
7
15
|
sphinx
|
|
8
16
|
sphinx_rtd_theme
|
|
9
17
|
|
|
10
18
|
[test]
|
|
11
19
|
pytest
|
|
20
|
+
pytest-asyncio
|
|
21
|
+
pytest-cov
|
|
12
22
|
pytest-html
|
|
23
|
+
hypothesis
|
|
13
24
|
mypy
|
|
14
25
|
types-setuptools
|
|
15
26
|
ruff
|
|
@@ -8,19 +8,30 @@ Siemens S7 PLCs without requiring the native Snap7 C library.
|
|
|
8
8
|
from importlib.metadata import version, PackageNotFoundError
|
|
9
9
|
|
|
10
10
|
from .client import Client
|
|
11
|
+
from .async_client import AsyncClient
|
|
11
12
|
from .server import Server
|
|
12
13
|
from .partner import Partner
|
|
13
14
|
from .logo import Logo
|
|
14
15
|
from .util.db import Row, DB
|
|
16
|
+
from .tags import NodeS7Tag, PLC4XTag, Tag, from_browse, load_csv, load_json, load_tia_xml, parse_tag
|
|
15
17
|
from .type import Area, Block, WordLen, SrvEvent, SrvArea
|
|
16
18
|
|
|
17
19
|
__all__ = [
|
|
18
20
|
"Client",
|
|
21
|
+
"AsyncClient",
|
|
19
22
|
"Server",
|
|
20
23
|
"Partner",
|
|
21
24
|
"Logo",
|
|
22
25
|
"Row",
|
|
23
26
|
"DB",
|
|
27
|
+
"Tag",
|
|
28
|
+
"PLC4XTag",
|
|
29
|
+
"NodeS7Tag",
|
|
30
|
+
"parse_tag",
|
|
31
|
+
"load_csv",
|
|
32
|
+
"load_json",
|
|
33
|
+
"load_tia_xml",
|
|
34
|
+
"from_browse",
|
|
24
35
|
"Area",
|
|
25
36
|
"Block",
|
|
26
37
|
"WordLen",
|