python-snap7 3.1.2__tar.gz → 3.2.1__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.2.1/CHANGES.md +373 -0
- python_snap7-3.2.1/MANIFEST.in +9 -0
- python_snap7-3.2.1/PKG-INFO +107 -0
- python_snap7-3.2.1/README.rst +54 -0
- python_snap7-3.2.1/doc/API/client-base.rst +9 -0
- python_snap7-3.2.1/doc/API/client.rst +45 -0
- python_snap7-3.2.1/doc/API/connection.rst +8 -0
- python_snap7-3.2.1/doc/API/datatypes.rst +7 -0
- python_snap7-3.2.1/doc/API/demo.rst +9 -0
- python_snap7-3.2.1/doc/API/discovery.rst +7 -0
- python_snap7-3.2.1/doc/API/error.rst +5 -0
- python_snap7-3.2.1/doc/API/log.rst +33 -0
- python_snap7-3.2.1/doc/API/logo.rst +5 -0
- python_snap7-3.2.1/doc/API/optimizer.rst +79 -0
- python_snap7-3.2.1/doc/API/partner.rst +24 -0
- python_snap7-3.2.1/doc/API/ppi.rst +10 -0
- python_snap7-3.2.1/doc/API/rate-limiter.rst +10 -0
- python_snap7-3.2.1/doc/API/s7protocol.rst +7 -0
- python_snap7-3.2.1/doc/API/server.rst +19 -0
- python_snap7-3.2.1/doc/API/szl.rst +8 -0
- python_snap7-3.2.1/doc/API/tags.rst +97 -0
- python_snap7-3.2.1/doc/API/type.rst +5 -0
- python_snap7-3.2.1/doc/API/util.rst +24 -0
- python_snap7-3.2.1/doc/Makefile +153 -0
- python_snap7-3.2.1/doc/advanced.rst +90 -0
- python_snap7-3.2.1/doc/cli.rst +191 -0
- python_snap7-3.2.1/doc/conf.py +92 -0
- python_snap7-3.2.1/doc/connecting.rst +183 -0
- python_snap7-3.2.1/doc/connection-issues.rst +190 -0
- python_snap7-3.2.1/doc/development.rst +86 -0
- python_snap7-3.2.1/doc/error-reference.rst +57 -0
- python_snap7-3.2.1/doc/index.rst +76 -0
- python_snap7-3.2.1/doc/installation.rst +60 -0
- python_snap7-3.2.1/doc/introduction.rst +65 -0
- python_snap7-3.2.1/doc/limitations.rst +29 -0
- python_snap7-3.2.1/doc/multi-variable.rst +51 -0
- python_snap7-3.2.1/doc/plc-support.rst +93 -0
- python_snap7-3.2.1/doc/ppi.rst +67 -0
- python_snap7-3.2.1/doc/reading-writing.rst +437 -0
- python_snap7-3.2.1/doc/real-plc-testing.rst +89 -0
- python_snap7-3.2.1/doc/server.rst +113 -0
- python_snap7-3.2.1/doc/thread-safety.rst +39 -0
- python_snap7-3.2.1/doc/tia-portal-config.rst +56 -0
- python_snap7-3.2.1/example/boolean.py +46 -0
- python_snap7-3.2.1/example/db1_layout.txt +46 -0
- python_snap7-3.2.1/example/db_layouts.py +123 -0
- python_snap7-3.2.1/example/example.py +201 -0
- python_snap7-3.2.1/example/logo_7_8.py +53 -0
- python_snap7-3.2.1/example/ppi.py +13 -0
- python_snap7-3.2.1/example/prometheus_metrics.py +166 -0
- python_snap7-3.2.1/example/read_multi.py +68 -0
- python_snap7-3.2.1/example/s7_symbols.py +38 -0
- python_snap7-3.2.1/example/write_multi.py +52 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/pyproject.toml +20 -4
- python_snap7-3.2.1/python_snap7.egg-info/PKG-INFO +107 -0
- python_snap7-3.2.1/python_snap7.egg-info/SOURCES.txt +139 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/python_snap7.egg-info/requires.txt +4 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/python_snap7.egg-info/top_level.txt +1 -0
- python_snap7-3.2.1/s7/__init__.py +52 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/__init__.py +15 -4
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/async_client.py +231 -81
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/cli.py +2 -3
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/client.py +322 -128
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/client_base.py +102 -26
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/connection.py +21 -10
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/datatypes.py +24 -3
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/error.py +6 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/logo.py +48 -6
- python_snap7-3.2.1/snap7/ppi.py +421 -0
- python_snap7-3.2.1/snap7/py.typed +0 -0
- python_snap7-3.2.1/snap7/rate_limiter.py +110 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/s7protocol.py +350 -130
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/server/__init__.py +420 -310
- python_snap7-3.2.1/snap7/szl.py +212 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/tags.py +6 -6
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/type.py +14 -1
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/util/getters.py +26 -9
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/util/setters.py +4 -1
- python_snap7-3.2.1/tests/__init__.py +0 -0
- python_snap7-3.2.1/tests/conftest.py +189 -0
- python_snap7-3.2.1/tests/features/real_plc/connection.feature +17 -0
- python_snap7-3.2.1/tests/features/real_plc/lifecycle.feature +19 -0
- python_snap7-3.2.1/tests/features/real_plc/read.feature +19 -0
- python_snap7-3.2.1/tests/features/real_plc/report.schema.json +32 -0
- python_snap7-3.2.1/tests/features/real_plc/write.feature +23 -0
- python_snap7-3.2.1/tests/plc_setup/e2e_test_dbs.scl +160 -0
- python_snap7-3.2.1/tests/real_plc/__init__.py +1 -0
- python_snap7-3.2.1/tests/real_plc/reporting.py +123 -0
- python_snap7-3.2.1/tests/real_plc/support.py +228 -0
- python_snap7-3.2.1/tests/real_plc/test_acceptance.py +218 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_async_client.py +68 -6
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_client.py +84 -3
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_client_e2e.py +59 -62
- python_snap7-3.2.1/tests/test_conformance.py +526 -0
- python_snap7-3.2.1/tests/test_connection.py +540 -0
- python_snap7-3.2.1/tests/test_coverage_gaps.py +144 -0
- python_snap7-3.2.1/tests/test_error.py +181 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_hypothesis.py +3 -4
- python_snap7-3.2.1/tests/test_lean_regressions.py +288 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_logging.py +8 -6
- python_snap7-3.2.1/tests/test_logo_reconnect_options.py +44 -0
- python_snap7-3.2.1/tests/test_operation_hook.py +201 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_optimizer.py +3 -2
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_partner.py +360 -2
- python_snap7-3.2.1/tests/test_ppi.py +261 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_property.py +2 -2
- python_snap7-3.2.1/tests/test_rate_limiter.py +148 -0
- python_snap7-3.2.1/tests/test_real_plc_support.py +117 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_s7protocol.py +292 -52
- python_snap7-3.2.1/tests/test_server.py +1282 -0
- python_snap7-3.2.1/tests/test_server_cli.py +30 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_stress.py +3 -2
- python_snap7-3.2.1/tox.ini +36 -0
- python_snap7-3.1.2/MANIFEST.in +0 -1
- python_snap7-3.1.2/PKG-INFO +0 -131
- python_snap7-3.1.2/README.rst +0 -81
- python_snap7-3.1.2/python_snap7.egg-info/PKG-INFO +0 -131
- python_snap7-3.1.2/python_snap7.egg-info/SOURCES.txt +0 -62
- python_snap7-3.1.2/snap7/szl.py +0 -115
- python_snap7-3.1.2/snap7/util/symbols.py +0 -547
- python_snap7-3.1.2/tests/test_server.py +0 -703
- {python_snap7-3.1.2 → python_snap7-3.2.1}/LICENSE +0 -0
- /python_snap7-3.1.2/snap7/py.typed → /python_snap7-3.2.1/doc/_static/.phony +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/python_snap7.egg-info/dependency_links.txt +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/python_snap7.egg-info/entry_points.txt +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/setup.cfg +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/demo.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/discovery.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/log.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/optimizer.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/partner.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/server/__main__.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/util/__init__.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/snap7/util/db.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_api_surface.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_behavioral_compatibility.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_cli.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_datatypes.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_demo.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_discovery.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_finalize.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_logo_client.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_mainloop.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_multipacket.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_reconnect.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_routing.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_tags.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_typed_access.py +0 -0
- {python_snap7-3.1.2 → python_snap7-3.2.1}/tests/test_util.py +0 -0
|
@@ -0,0 +1,373 @@
|
|
|
1
|
+
CHANGES
|
|
2
|
+
========
|
|
3
|
+
|
|
4
|
+
3.2.1
|
|
5
|
+
-----
|
|
6
|
+
|
|
7
|
+
Bug-fix and packaging release, with a few small additions.
|
|
8
|
+
|
|
9
|
+
### Packaging
|
|
10
|
+
|
|
11
|
+
* Include the full test suite (`tests/__init__.py`, `tests/conftest.py`, PLC setup
|
|
12
|
+
files), examples, docs, and `CHANGES.md` in the source distribution (#912, #913).
|
|
13
|
+
* Remove leftover HarpoS7 test fixtures and transpiler from the S7CommPlus
|
|
14
|
+
split (#914).
|
|
15
|
+
|
|
16
|
+
### New features
|
|
17
|
+
|
|
18
|
+
* Add an `on_operation` callback to the synchronous and asynchronous clients,
|
|
19
|
+
invoked after each PLC operation with its name, duration, and whether it
|
|
20
|
+
raised, plus an example Prometheus metrics exporter (#843, #901).
|
|
21
|
+
* Add a safe, Gherkin-based real-PLC acceptance program with restored scratch
|
|
22
|
+
writes and sanitized JSON/JUnit reports (#840, #892, #908).
|
|
23
|
+
|
|
24
|
+
### Bug fixes
|
|
25
|
+
|
|
26
|
+
* Match the classic Snap7 upload wire layout, collect every upload fragment, and
|
|
27
|
+
reject malformed, truncated, or mismatched S7/USERDATA responses (#903).
|
|
28
|
+
* Use the PLC-driven request/response sequence for block download and match
|
|
29
|
+
classic S7 wire vectors for list-blocks-of-type, set clock, get block info,
|
|
30
|
+
and password requests (#904).
|
|
31
|
+
* Fix the return type annotations of `snap7.util.get_byte` and `get_word`, which
|
|
32
|
+
return `int`, not `bytes`/`bytearray` (#910).
|
|
33
|
+
|
|
34
|
+
3.2.0
|
|
35
|
+
-----
|
|
36
|
+
|
|
37
|
+
Feature and robustness release for the classic S7 protocol implementation.
|
|
38
|
+
|
|
39
|
+
### Packaging
|
|
40
|
+
|
|
41
|
+
* Move S7CommPlus support to the standalone
|
|
42
|
+
[`s7commplus`](https://github.com/gijzelaerr/s7commplus) package. The `s7`
|
|
43
|
+
import remains available as an alias for the classic `snap7` package.
|
|
44
|
+
|
|
45
|
+
### New features
|
|
46
|
+
|
|
47
|
+
* Add configurable request rate limiting to synchronous and asynchronous
|
|
48
|
+
clients, including fixed-interval and token-bucket modes (#823).
|
|
49
|
+
* Add synchronous and asynchronous APIs for forcing I/O bits, cancelling
|
|
50
|
+
forces, and reading the PLC force table (#796, #800).
|
|
51
|
+
* Add synchronous and asynchronous session password set/clear APIs for
|
|
52
|
+
password-protected PLCs (#792, #799).
|
|
53
|
+
* Support LOGO reconnection, heartbeat, rate-limiting, and connection callback
|
|
54
|
+
options while preserving explicit TSAPs (#875).
|
|
55
|
+
* Add an experimental serial PPI client for S7-200 PLCs, including V-memory,
|
|
56
|
+
system-memory, I/O, counter, and timer access (#824).
|
|
57
|
+
|
|
58
|
+
### Bug fixes
|
|
59
|
+
|
|
60
|
+
* Parse structured and flat SZL 0x0011 records correctly when reading order
|
|
61
|
+
codes and firmware versions from S7-1500 and classic PLCs (#783, #789).
|
|
62
|
+
* Dispatch server callbacks and queue protocol events for client requests
|
|
63
|
+
instead of reporting only the server start event (#853, #856).
|
|
64
|
+
* Validate classic S7 TPKT bounds and COTP Class 0 headers in synchronous and
|
|
65
|
+
asynchronous clients (#874).
|
|
66
|
+
* Reject incomplete reads and mismatched or missing read/write
|
|
67
|
+
acknowledgements (#874).
|
|
68
|
+
* Size read/write chunks in whole elements and preserve ctypes write
|
|
69
|
+
datatypes; correct BIT lengths and timer/counter index addressing (#874).
|
|
70
|
+
* Validate `write_multi_vars()` inputs consistently and preserve each item's
|
|
71
|
+
declared datatype (#855, #874).
|
|
72
|
+
* Echo the calling and called TSAP values in server connection confirmations,
|
|
73
|
+
and restart the receive deadline after each complete TPKT header (#893).
|
|
74
|
+
* Return S7 item errors for reads from unregistered server areas or addresses
|
|
75
|
+
outside registered memory instead of returning fabricated data (#896).
|
|
76
|
+
|
|
77
|
+
3.1.2
|
|
78
|
+
-----
|
|
79
|
+
|
|
80
|
+
Corrective bug fix and robustness release replacing the yanked 3.1.1 release.
|
|
81
|
+
|
|
82
|
+
### Corrections
|
|
83
|
+
|
|
84
|
+
* Withdraw the vulnerability and CWE characterizations published with 3.1.1.
|
|
85
|
+
Independent review found that those descriptions overstated or incorrectly
|
|
86
|
+
described the affected code paths.
|
|
87
|
+
|
|
88
|
+
### Robustness fixes
|
|
89
|
+
|
|
90
|
+
* Bound the server to 64 simultaneous clients by default, enforce the existing
|
|
91
|
+
`MaxClients` parameter, and allow `max_clients` configuration.
|
|
92
|
+
* Validate block-download targets and declared sizes before allocating transfer
|
|
93
|
+
state, cap accumulated data at the declared size and registered area's
|
|
94
|
+
capacity, and clean up abandoned upload/download state on disconnect.
|
|
95
|
+
* Correct block-download address parsing so the requested DB number is used
|
|
96
|
+
instead of silently falling back to DB1.
|
|
97
|
+
* Bound COTP request reassembly to 1 MiB and apply one absolute deadline across
|
|
98
|
+
all fragments of a request.
|
|
99
|
+
* Apply COTP TPDU-size validation consistently to sync and async clients.
|
|
100
|
+
* Add regression tests for invalid PDU negotiation, TPDU-size validation,
|
|
101
|
+
connection limits, request reassembly, and block-download limits.
|
|
102
|
+
|
|
103
|
+
3.1.1 (yanked)
|
|
104
|
+
----------------
|
|
105
|
+
|
|
106
|
+
This release was yanked because its security descriptions were inaccurate and
|
|
107
|
+
some of its input-hardening changes were incomplete. Use 3.1.2 instead.
|
|
108
|
+
|
|
109
|
+
### Robustness changes
|
|
110
|
+
|
|
111
|
+
* Validate COTP TPDU-size encodings in the synchronous client.
|
|
112
|
+
* Normalize implausibly small negotiated PDU lengths and ensure read/write
|
|
113
|
+
chunk sizes remain positive.
|
|
114
|
+
* Stop finalizing downloads into unregistered server memory areas. This did not
|
|
115
|
+
bound the download accumulator and was completed in 3.1.2.
|
|
116
|
+
|
|
117
|
+
### Bug fixes
|
|
118
|
+
|
|
119
|
+
* Fix `connection_type` not applied in TSAP composition during
|
|
120
|
+
`connect()` (#766)
|
|
121
|
+
* Fix auto-reconnect not triggered on multi-block read path (#787)
|
|
122
|
+
* Support multi-byte string encodings (GBK, UTF-8) in `get_string`,
|
|
123
|
+
`set_string`, `get_fstring`, `set_fstring` (#788)
|
|
124
|
+
* Thread encoding parameter through `read_tag` / `write_tag` /
|
|
125
|
+
`read_tags` (#786)
|
|
126
|
+
* Server: reassemble COTP-fragmented requests; include TPDU size
|
|
127
|
+
parameter in Connection Confirm so clients don't fall back to the
|
|
128
|
+
128-byte ISO 8073 default (#804)
|
|
129
|
+
* Server: fix `INT` and `DINT` word lengths returning wrong byte count
|
|
130
|
+
in read requests (#804)
|
|
131
|
+
|
|
132
|
+
### Thanks
|
|
133
|
+
|
|
134
|
+
* [@b1163646804](https://github.com/b1163646804) — multi-byte encoding
|
|
135
|
+
support and testing (#788)
|
|
136
|
+
* [@domelg](https://github.com/domelg) — server COTP fragmentation and
|
|
137
|
+
INT/DINT byte count bug reports (#804)
|
|
138
|
+
|
|
139
|
+
3.1.0
|
|
140
|
+
-----
|
|
141
|
+
|
|
142
|
+
Feature and bug fix release for the pure Python S7 communication library.
|
|
143
|
+
|
|
144
|
+
### New features
|
|
145
|
+
|
|
146
|
+
* **AsyncClient** for `asyncio` support (#593)
|
|
147
|
+
* **Unified Tag API**: `client.read_tag("DB1.DBD0:REAL")` with PLC4X /
|
|
148
|
+
Siemens STEP7 syntax (#697)
|
|
149
|
+
* **Dual-dialect tag parsing**: PLC4X and nodeS7 tag formats with
|
|
150
|
+
auto-detection (#701)
|
|
151
|
+
* **Multi-variable read optimizer** with parallel dispatch (experimental, #641)
|
|
152
|
+
* **S7 routing** for multi-subnet PLC access (experimental, #639)
|
|
153
|
+
* **Heartbeat monitoring** and auto-reconnect with exponential backoff (#635)
|
|
154
|
+
* **Structured logging** with PLC connection context (`snap7.log`, #688)
|
|
155
|
+
* **PROFINET DCP** network discovery (#634)
|
|
156
|
+
* **CLI tools** for PLC interaction (`pip install "python-snap7[cli]"`, #631)
|
|
157
|
+
* **Demo server** exposing real host metrics (#704)
|
|
158
|
+
* Typed DB access methods (`db_read_bool`, `db_read_int`, etc., #632)
|
|
159
|
+
* Symbolic addressing — read/write by tag name (experimental, #638)
|
|
160
|
+
* Diagnostic buffer reading (#690)
|
|
161
|
+
* Array read/write helpers (`db_read_array`, `db_write_array`, #693)
|
|
162
|
+
* Missing data type setters: `set_lint`, `set_ulint`, `set_ltime`, `set_ltod`, `set_ldt` (#693)
|
|
163
|
+
* Property-based testing with Hypothesis (#636)
|
|
164
|
+
|
|
165
|
+
### Bug fixes
|
|
166
|
+
|
|
167
|
+
* Fix `AttributeError` from `__del__` during interpreter shutdown (#707)
|
|
168
|
+
* Fix server SZL 0x001C response to match real PLC format (#694)
|
|
169
|
+
* Fix `connection_type` in TSAP composition during connect (#766)
|
|
170
|
+
* Accept `memoryview` in setter and getter type annotations (#647)
|
|
171
|
+
* Zero-pad milliseconds in `get_time` (#716)
|
|
172
|
+
* Fix PI service PDU format for PLC control commands (#743)
|
|
173
|
+
* Fix `get_cpu_info` and `S7SZL.__str__` (#692)
|
|
174
|
+
* Fix partner S7 Communication Setup and bsend/brecv PDU format (#669)
|
|
175
|
+
* Fix `get_dtl` microsecond parsing (4-byte nanosecond field)
|
|
176
|
+
* Fix `set_date` unsigned short for day count
|
|
177
|
+
* Fix `set_tod` float precision loss
|
|
178
|
+
* Validate BMP range in `set_wstring`
|
|
179
|
+
* Fix async `get_cpu_info` SZL offsets (#702)
|
|
180
|
+
* Fix demo primary-IP guess with VPN/tunnel interfaces (#708)
|
|
181
|
+
* Fix mypy errors in server SZL list (#695)
|
|
182
|
+
* Robustness: 210+ S7 error codes, auto PDU splitting, stale packet retry (#580)
|
|
183
|
+
|
|
184
|
+
### Improvements
|
|
185
|
+
|
|
186
|
+
* Set `TCP_NODELAY` and `SO_KEEPALIVE` on all sockets (#677)
|
|
187
|
+
* Export `get_ulint`, `get_lint`, `get_date_time_object` from `snap7.util` (#652)
|
|
188
|
+
* Documentation restructured: API Reference + Internals sections
|
|
189
|
+
|
|
190
|
+
### Thanks
|
|
191
|
+
|
|
192
|
+
* [@hs2bws-hash](https://github.com/hs2bws-hash) — extensive real PLC testing of Partner BSend/BRecv (#668)
|
|
193
|
+
* [@QuakeString](https://github.com/QuakeString) — read optimizer inspiration via python-snap7-optimized fork
|
|
194
|
+
|
|
195
|
+
3.0.0
|
|
196
|
+
-----
|
|
197
|
+
|
|
198
|
+
Major release: python-snap7 is now a pure Python S7 communication library.
|
|
199
|
+
This version completely breaks with the previous approach of wrapping the C snap7
|
|
200
|
+
shared library. The entire S7 protocol stack is now implemented in pure Python,
|
|
201
|
+
greatly improving portability and making it easier to install and extend.
|
|
202
|
+
|
|
203
|
+
* **Breaking**: The C snap7 library is no longer required or used
|
|
204
|
+
* Complete rewrite of the S7 protocol stack in pure Python
|
|
205
|
+
* Native Python implementation of TPKT (RFC 1006) and COTP (ISO 8073) layers
|
|
206
|
+
* Native S7 protocol PDU encoding/decoding
|
|
207
|
+
* Pure Python server implementation for testing and simulation
|
|
208
|
+
* No platform-specific binary dependencies — works on any platform that runs Python
|
|
209
|
+
* Improved error handling and connection management
|
|
210
|
+
* Full type annotations with mypy strict mode
|
|
211
|
+
* CLI interface for running an S7 server emulator (`pip install "python-snap7[cli]"`)
|
|
212
|
+
|
|
213
|
+
If you experience issues with 3.0, please report them on the
|
|
214
|
+
[issue tracker](https://github.com/gijzelaerr/python-snap7/issues) with a clear
|
|
215
|
+
description and the version you are using. As a workaround, pin to the last
|
|
216
|
+
pre-3.0 release:
|
|
217
|
+
|
|
218
|
+
$ pip install "python-snap7<3"
|
|
219
|
+
|
|
220
|
+
### Thanks
|
|
221
|
+
|
|
222
|
+
Special thanks to the following people for testing, reporting issues, and providing
|
|
223
|
+
feedback during the 3.0 development:
|
|
224
|
+
|
|
225
|
+
* [@lupaulus](https://github.com/lupaulus) — extensive testing and bug reports
|
|
226
|
+
* [@spreeker](https://github.com/spreeker) — testing and feedback
|
|
227
|
+
* [@nikteliy](https://github.com/nikteliy) — review and feedback on the rewrite
|
|
228
|
+
* [@amorelettronico](https://github.com/amorelettronico) — testing
|
|
229
|
+
* [@razour08](https://github.com/razour08) — testing
|
|
230
|
+
* [@core-engineering](https://github.com/core-engineering) — bug reports (#553)
|
|
231
|
+
* [@AndreasScharf](https://github.com/AndreasScharf) — bug reports (#572)
|
|
232
|
+
* [@Robatronic](https://github.com/Robatronic) — bug reports (#574)
|
|
233
|
+
* [@hirotasoshu](https://github.com/hirotasoshu) — feedback (#545)
|
|
234
|
+
* [@PoitrasJ](https://github.com/PoitrasJ) — bug reports (#479)
|
|
235
|
+
|
|
236
|
+
1.2
|
|
237
|
+
---
|
|
238
|
+
|
|
239
|
+
* fix wheel tag for linux x86_64 by @nikteliy in https://github.com/gijzelaerr/python-snap7/pull/297
|
|
240
|
+
* Fixed typo area doesn't exist areas does by @Ofloo in https://github.com/gijzelaerr/python-snap7/pull/306
|
|
241
|
+
* add get_time and set_time in util by @Yingliangzhe in https://github.com/gijzelaerr/python-snap7/pull/308
|
|
242
|
+
* modification of TIME data type by @Yingliangzhe in https://github.com/gijzelaerr/python-snap7/pull/311
|
|
243
|
+
* added DATE_AND_TIME Value as Datetime object by @zsisamci in https://github.com/gijzelaerr/python-snap7/pull/312
|
|
244
|
+
* #273 by @nikteliy in https://github.com/gijzelaerr/python-snap7/pull/321
|
|
245
|
+
* Add byte type parsing to DB_Row API + set parsing case insensitive by @LoicGRENON in https://github.com/gijzelaerr/python-snap7/pull/315
|
|
246
|
+
* added missing types in WordLen by @zsisamci in https://github.com/gijzelaerr/python-snap7/pull/326
|
|
247
|
+
* Add support for read/write unsigned value from bytearray by @LoicGRENON in https://github.com/gijzelaerr/python-snap7/pull/316
|
|
248
|
+
* fixing ip string paramters to c function by @zsisamci in https://github.com/gijzelaerr/python-snap7/pull/329
|
|
249
|
+
* Add py.typed marker file by @mthuurne in https://github.com/gijzelaerr/python-snap7/pull/342
|
|
250
|
+
* require correct package name, fixes issue #344 by @gijzelaerr in https://github.com/gijzelaerr/python-snap7/pull/345
|
|
251
|
+
* Fix warnings by @nikteliy in https://github.com/gijzelaerr/python-snap7/pull/350
|
|
252
|
+
* Update license identifier by @Shortfinga in https://github.com/gijzelaerr/python-snap7/pull/349
|
|
253
|
+
* Update client db_write docs by @pwablito in https://github.com/gijzelaerr/python-snap7/pull/352
|
|
254
|
+
* Fix db_offset calculation error by @lubbbert in https://github.com/gijzelaerr/python-snap7/pull/351
|
|
255
|
+
* fix #355 by @swamper123 in https://github.com/gijzelaerr/python-snap7/pull/359
|
|
256
|
+
* fix #272 by @swamper123 in https://github.com/gijzelaerr/python-snap7/pull/360
|
|
257
|
+
* fix get_time for small values by @swamper123 in https://github.com/gijzelaerr/python-snap7/pull/358
|
|
258
|
+
* add more getter methods for utils by @swamper123 in https://github.com/gijzelaerr/python-snap7/pull/357
|
|
259
|
+
* Prepare for 1.2 by @gijzelaerr in https://github.com/gijzelaerr/python-snap7/pull/364
|
|
260
|
+
|
|
261
|
+
### New Contributors
|
|
262
|
+
|
|
263
|
+
* @Ofloo made their first contribution in https://github.com/gijzelaerr/python-snap7/pull/306
|
|
264
|
+
* @zsisamci made their first contribution in https://github.com/gijzelaerr/python-snap7/pull/312
|
|
265
|
+
* @LoicGRENON made their first contribution in https://github.com/gijzelaerr/python-snap7/pull/315
|
|
266
|
+
* @mthuurne made their first contribution in https://github.com/gijzelaerr/python-snap7/pull/342
|
|
267
|
+
* @Shortfinga made their first contribution in https://github.com/gijzelaerr/python-snap7/pull/349
|
|
268
|
+
* @pwablito made their first contribution in https://github.com/gijzelaerr/python-snap7/pull/352
|
|
269
|
+
* @lubbbert made their first contribution in https://github.com/gijzelaerr/python-snap7/pull/351
|
|
270
|
+
|
|
271
|
+
**Full Changelog**: https://github.com/gijzelaerr/python-snap7/compare/1.1...1.2
|
|
272
|
+
|
|
273
|
+
1.1
|
|
274
|
+
---
|
|
275
|
+
|
|
276
|
+
* Make a binary wheel for all platforms (#232)
|
|
277
|
+
* Improve doc strings of all functions (#242)
|
|
278
|
+
|
|
279
|
+
Special thanks for this release to
|
|
280
|
+
* Fabian Beitler
|
|
281
|
+
* Nikteliy
|
|
282
|
+
* Lautaro Nahuel Dapino
|
|
283
|
+
|
|
284
|
+
1.0
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
* Drop python 2 support (#214)
|
|
288
|
+
* Feature request: ReadSZL() (#196)
|
|
289
|
+
* Keep argument format across the functions (#193)
|
|
290
|
+
* Drop Python2 Tests (#167)
|
|
291
|
+
* Support for S5TIME (#163)
|
|
292
|
+
* Add type annotations (#157)
|
|
293
|
+
* client.full_upload() return bytearray size 65536 (#127)
|
|
294
|
+
* Some client tests segfault on Linux (#26)
|
|
295
|
+
* Not all functions are implemented yet (#25)
|
|
296
|
+
|
|
297
|
+
special thanks to [Fabian Beitler](https://github.com/swamper123) and
|
|
298
|
+
[Nikteliy](https://github.com/nikteliy>) for their contributions to the 1.0 release!
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
0.11
|
|
304
|
+
----
|
|
305
|
+
|
|
306
|
+
* Update read_multi.py (#132)
|
|
307
|
+
* Added fixes to snap7/client.py read_area function to allow for Counter and Timer Reads (#121)
|
|
308
|
+
* Post to a public docker repository? (#119)
|
|
309
|
+
* Implementation of Cli_SetDateTime, Cli_GetDateTime enhancement (#114)
|
|
310
|
+
|
|
311
|
+
|
|
312
|
+
0.10
|
|
313
|
+
----
|
|
314
|
+
|
|
315
|
+
* Fix OSX travis build #99
|
|
316
|
+
* util.get_int() broken #101
|
|
317
|
+
* Compatibility issue with Python3 #109
|
|
318
|
+
* Logo 8 improvements bug #105
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
0.7
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
* util.get_int() broken (#65, #71)
|
|
325
|
+
* fix Add files via upload bug (#59)
|
|
326
|
+
|
|
327
|
+
Special thanks to Pelle van der Heide for solving issues
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
0.6
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
* Add __del__ to client, server and partner (#69)
|
|
334
|
+
* Add files via upload (#59)
|
|
335
|
+
|
|
336
|
+
Special thanks to xybsoft for solving issues
|
|
337
|
+
|
|
338
|
+
0.5
|
|
339
|
+
---
|
|
340
|
+
|
|
341
|
+
* adding some missing functions
|
|
342
|
+
* fixing Python3 support (issue #43)
|
|
343
|
+
* improving the documentation
|
|
344
|
+
|
|
345
|
+
0.4
|
|
346
|
+
---
|
|
347
|
+
|
|
348
|
+
More functions added:
|
|
349
|
+
|
|
350
|
+
* client.plc_stop
|
|
351
|
+
* client.plc_cold_start
|
|
352
|
+
* client.plc_hot_start
|
|
353
|
+
* client.read_multi_vars
|
|
354
|
+
|
|
355
|
+
0.2.1
|
|
356
|
+
-----
|
|
357
|
+
|
|
358
|
+
Small fix, README.rst was not included in sdist
|
|
359
|
+
|
|
360
|
+
|
|
361
|
+
0.2
|
|
362
|
+
---
|
|
363
|
+
|
|
364
|
+
- Add support for Windows
|
|
365
|
+
- Add functions added in Snap7 1.1.0
|
|
366
|
+
- Add missing client functions
|
|
367
|
+
- fix some partner functions
|
|
368
|
+
- simplified API
|
|
369
|
+
|
|
370
|
+
0.1
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
- Initial release.
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-snap7
|
|
3
|
+
Version: 3.2.1
|
|
4
|
+
Summary: Pure Python S7 communication library for Siemens PLCs
|
|
5
|
+
Author-email: Gijs Molenaar <gijsmolenaar@gmail.com>
|
|
6
|
+
License-Expression: 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-bdd<9,>=8.1; extra == "test"
|
|
28
|
+
Requires-Dist: pytest-cov; extra == "test"
|
|
29
|
+
Requires-Dist: pytest-html; extra == "test"
|
|
30
|
+
Requires-Dist: hypothesis; extra == "test"
|
|
31
|
+
Requires-Dist: mypy; extra == "test"
|
|
32
|
+
Requires-Dist: types-setuptools; extra == "test"
|
|
33
|
+
Requires-Dist: ruff; extra == "test"
|
|
34
|
+
Requires-Dist: tox; extra == "test"
|
|
35
|
+
Requires-Dist: tox-uv; extra == "test"
|
|
36
|
+
Requires-Dist: types-click; extra == "test"
|
|
37
|
+
Requires-Dist: uv; extra == "test"
|
|
38
|
+
Provides-Extra: cli
|
|
39
|
+
Requires-Dist: rich; extra == "cli"
|
|
40
|
+
Requires-Dist: click; extra == "cli"
|
|
41
|
+
Provides-Extra: demo
|
|
42
|
+
Requires-Dist: psutil; extra == "demo"
|
|
43
|
+
Requires-Dist: rich; extra == "demo"
|
|
44
|
+
Requires-Dist: click; extra == "demo"
|
|
45
|
+
Provides-Extra: doc
|
|
46
|
+
Requires-Dist: sphinx; extra == "doc"
|
|
47
|
+
Requires-Dist: sphinx_rtd_theme; extra == "doc"
|
|
48
|
+
Provides-Extra: discovery
|
|
49
|
+
Requires-Dist: pnio-dcp; extra == "discovery"
|
|
50
|
+
Provides-Extra: ppi
|
|
51
|
+
Requires-Dist: pyserial>=3.5; extra == "ppi"
|
|
52
|
+
Dynamic: license-file
|
|
53
|
+
|
|
54
|
+
.. image:: https://img.shields.io/pypi/v/python-snap7.svg
|
|
55
|
+
:target: https://pypi.org/project/python-snap7/
|
|
56
|
+
|
|
57
|
+
.. image:: https://img.shields.io/pypi/pyversions/python-snap7.svg
|
|
58
|
+
:target: https://pypi.org/project/python-snap7/
|
|
59
|
+
|
|
60
|
+
.. image:: https://img.shields.io/github/license/gijzelaerr/python-snap7.svg
|
|
61
|
+
:target: https://github.com/gijzelaerr/python-snap7/blob/master/LICENSE
|
|
62
|
+
|
|
63
|
+
.. image:: https://github.com/gijzelaerr/python-snap7/actions/workflows/test.yml/badge.svg
|
|
64
|
+
:target: https://github.com/gijzelaerr/python-snap7/actions/workflows/test.yml
|
|
65
|
+
|
|
66
|
+
.. image:: https://readthedocs.org/projects/python-snap7/badge/
|
|
67
|
+
:target: https://python-snap7.readthedocs.io/en/latest/
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
python-snap7
|
|
71
|
+
============
|
|
72
|
+
|
|
73
|
+
python-snap7 is a pure-Python library for communicating with Siemens S7 PLCs
|
|
74
|
+
using the classic S7 protocol. It supports S7-300 and S7-400 controllers, as
|
|
75
|
+
well as S7-1200 and S7-1500 controllers with PUT/GET access enabled. It
|
|
76
|
+
supports Python 3.10+ on Windows, Linux, and macOS without native dependencies.
|
|
77
|
+
|
|
78
|
+
Installation
|
|
79
|
+
============
|
|
80
|
+
|
|
81
|
+
Install from PyPI::
|
|
82
|
+
|
|
83
|
+
pip install python-snap7
|
|
84
|
+
|
|
85
|
+
Quick start
|
|
86
|
+
===========
|
|
87
|
+
|
|
88
|
+
::
|
|
89
|
+
|
|
90
|
+
from s7 import Client
|
|
91
|
+
|
|
92
|
+
client = Client()
|
|
93
|
+
client.connect("192.168.1.10", 0, 1)
|
|
94
|
+
data = client.db_read(1, 0, 4)
|
|
95
|
+
client.disconnect()
|
|
96
|
+
|
|
97
|
+
The ``s7`` package is the recommended import. The ``snap7`` package name is
|
|
98
|
+
also available for backwards compatibility.
|
|
99
|
+
|
|
100
|
+
Documentation
|
|
101
|
+
=============
|
|
102
|
+
|
|
103
|
+
Read the full documentation at
|
|
104
|
+
`python-snap7.readthedocs.io <https://python-snap7.readthedocs.io/en/latest/>`_.
|
|
105
|
+
|
|
106
|
+
The safe volunteer hardware-test procedure is in
|
|
107
|
+
`Real-PLC acceptance testing <doc/real-plc-testing.rst>`_.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
.. image:: https://img.shields.io/pypi/v/python-snap7.svg
|
|
2
|
+
:target: https://pypi.org/project/python-snap7/
|
|
3
|
+
|
|
4
|
+
.. image:: https://img.shields.io/pypi/pyversions/python-snap7.svg
|
|
5
|
+
:target: https://pypi.org/project/python-snap7/
|
|
6
|
+
|
|
7
|
+
.. image:: https://img.shields.io/github/license/gijzelaerr/python-snap7.svg
|
|
8
|
+
:target: https://github.com/gijzelaerr/python-snap7/blob/master/LICENSE
|
|
9
|
+
|
|
10
|
+
.. image:: https://github.com/gijzelaerr/python-snap7/actions/workflows/test.yml/badge.svg
|
|
11
|
+
:target: https://github.com/gijzelaerr/python-snap7/actions/workflows/test.yml
|
|
12
|
+
|
|
13
|
+
.. image:: https://readthedocs.org/projects/python-snap7/badge/
|
|
14
|
+
:target: https://python-snap7.readthedocs.io/en/latest/
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
python-snap7
|
|
18
|
+
============
|
|
19
|
+
|
|
20
|
+
python-snap7 is a pure-Python library for communicating with Siemens S7 PLCs
|
|
21
|
+
using the classic S7 protocol. It supports S7-300 and S7-400 controllers, as
|
|
22
|
+
well as S7-1200 and S7-1500 controllers with PUT/GET access enabled. It
|
|
23
|
+
supports Python 3.10+ on Windows, Linux, and macOS without native dependencies.
|
|
24
|
+
|
|
25
|
+
Installation
|
|
26
|
+
============
|
|
27
|
+
|
|
28
|
+
Install from PyPI::
|
|
29
|
+
|
|
30
|
+
pip install python-snap7
|
|
31
|
+
|
|
32
|
+
Quick start
|
|
33
|
+
===========
|
|
34
|
+
|
|
35
|
+
::
|
|
36
|
+
|
|
37
|
+
from s7 import Client
|
|
38
|
+
|
|
39
|
+
client = Client()
|
|
40
|
+
client.connect("192.168.1.10", 0, 1)
|
|
41
|
+
data = client.db_read(1, 0, 4)
|
|
42
|
+
client.disconnect()
|
|
43
|
+
|
|
44
|
+
The ``s7`` package is the recommended import. The ``snap7`` package name is
|
|
45
|
+
also available for backwards compatibility.
|
|
46
|
+
|
|
47
|
+
Documentation
|
|
48
|
+
=============
|
|
49
|
+
|
|
50
|
+
Read the full documentation at
|
|
51
|
+
`python-snap7.readthedocs.io <https://python-snap7.readthedocs.io/en/latest/>`_.
|
|
52
|
+
|
|
53
|
+
The safe volunteer hardware-test procedure is in
|
|
54
|
+
`Real-PLC acceptance testing <doc/real-plc-testing.rst>`_.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Shared Client Internals
|
|
2
|
+
=======================
|
|
3
|
+
|
|
4
|
+
Pure-computation and compatibility methods shared by ``Client`` and
|
|
5
|
+
``AsyncClient``. Applications normally access these methods through one of the
|
|
6
|
+
concrete clients.
|
|
7
|
+
|
|
8
|
+
.. automodule:: snap7.client_base
|
|
9
|
+
:members:
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Client
|
|
2
|
+
======
|
|
3
|
+
|
|
4
|
+
The ``s7`` package implements the classic S7 protocol for S7-300/400 PLCs and
|
|
5
|
+
PUT/GET access on S7-1200/1500.
|
|
6
|
+
|
|
7
|
+
Use ``Client`` for synchronous applications::
|
|
8
|
+
|
|
9
|
+
from s7 import Client
|
|
10
|
+
|
|
11
|
+
with Client() as client:
|
|
12
|
+
client.connect("192.168.1.10", 0, 1)
|
|
13
|
+
data = client.db_read(1, 0, 4)
|
|
14
|
+
|
|
15
|
+
Use ``AsyncClient`` when the surrounding application uses ``asyncio``::
|
|
16
|
+
|
|
17
|
+
import asyncio
|
|
18
|
+
from s7 import AsyncClient
|
|
19
|
+
|
|
20
|
+
async def main():
|
|
21
|
+
async with AsyncClient() as client:
|
|
22
|
+
await client.connect("192.168.1.10", 0, 1)
|
|
23
|
+
data = await client.db_read(1, 0, 4)
|
|
24
|
+
|
|
25
|
+
asyncio.run(main())
|
|
26
|
+
|
|
27
|
+
Both clients expose the same main PLC operations, including area and DB
|
|
28
|
+
access, block transfer, CPU information and control, clock access, force
|
|
29
|
+
operations, and session passwords. Methods that perform I/O are coroutines on
|
|
30
|
+
``AsyncClient``. See :doc:`../advanced` for the less common operations.
|
|
31
|
+
|
|
32
|
+
s7.Client
|
|
33
|
+
---------
|
|
34
|
+
|
|
35
|
+
.. automodule:: snap7.client
|
|
36
|
+
:members:
|
|
37
|
+
:inherited-members:
|
|
38
|
+
|
|
39
|
+
s7.AsyncClient
|
|
40
|
+
--------------
|
|
41
|
+
|
|
42
|
+
.. automodule:: snap7.async_client
|
|
43
|
+
:members:
|
|
44
|
+
:inherited-members:
|
|
45
|
+
:exclude-members: AsyncISOTCPConnection
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
Demo Server
|
|
2
|
+
===========
|
|
3
|
+
|
|
4
|
+
Implementation of the optional live host-metrics demo used by ``s7 demo``.
|
|
5
|
+
Install ``python-snap7[demo]`` before running it. This module is intended for
|
|
6
|
+
examples and integration testing, not production monitoring.
|
|
7
|
+
|
|
8
|
+
.. automodule:: snap7.demo
|
|
9
|
+
:members:
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Logging
|
|
2
|
+
=======
|
|
3
|
+
|
|
4
|
+
Structured logging with PLC connection context for multi-PLC environments.
|
|
5
|
+
|
|
6
|
+
The :class:`~snap7.log.PLCLoggerAdapter` automatically injects PLC host,
|
|
7
|
+
rack, and slot into every log message:
|
|
8
|
+
|
|
9
|
+
.. code-block:: python
|
|
10
|
+
|
|
11
|
+
import logging
|
|
12
|
+
logging.basicConfig(level=logging.DEBUG)
|
|
13
|
+
|
|
14
|
+
from s7 import Client
|
|
15
|
+
client = Client()
|
|
16
|
+
client.connect("192.168.1.10", 0, 1)
|
|
17
|
+
# Logs: [192.168.1.10 R0/S1] Connected to 192.168.1.10:102 ...
|
|
18
|
+
|
|
19
|
+
For JSON output (ELK, Datadog, Loki):
|
|
20
|
+
|
|
21
|
+
.. code-block:: python
|
|
22
|
+
|
|
23
|
+
from s7.log import JSONFormatter
|
|
24
|
+
|
|
25
|
+
handler = logging.StreamHandler()
|
|
26
|
+
handler.setFormatter(JSONFormatter())
|
|
27
|
+
logging.getLogger("snap7").addHandler(handler)
|
|
28
|
+
|
|
29
|
+
API reference
|
|
30
|
+
-------------
|
|
31
|
+
|
|
32
|
+
.. automodule:: snap7.log
|
|
33
|
+
:members:
|