Commit 154d678
Backport robustness improvements from python-s7comm (#580)
Backports concrete robustness improvements from nikteliy/python-s7comm
to the native Python S7 implementation:
- 210+ S7 protocol error codes from Wireshark's S7 dissector covering
USERDATA parameter errors (0xD0xx), protocol errors (0x8xxx), and
resource errors. parse_response() now raises descriptive S7ProtocolError
on header errors, and USERDATA response parsing logs warnings.
- Stale packet detection with retry: new validate_pdu_reference()
validates response sequence numbers. New _send_receive() helper wraps
the send/receive/parse pattern with automatic retry on stale packets
(up to 3 retries). Refactored ~15 call sites in client.py to use it.
- Automatic PDU splitting for read_area()/write_area(): requests
exceeding the negotiated PDU length are automatically chunked,
preventing PLC rejections on large reads (e.g. db_get() on big DBs).
- TPDUSize enum (ISO 8073) with configurable COTP negotiation: replaces
hardcoded 0x0A with a proper IntEnum (128-8192 bytes).
- MAX_VARS=20 limit on read_multi_vars()/write_multi_vars(): raises
ValueError when exceeding the S7 protocol limit.
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent c246947 commit 154d678
8 files changed
Lines changed: 815 additions & 254 deletions
File renamed without changes.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
16 | 33 | | |
17 | 34 | | |
18 | 35 | | |
| |||
44 | 61 | | |
45 | 62 | | |
46 | 63 | | |
47 | | - | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
48 | 72 | | |
49 | 73 | | |
50 | 74 | | |
| |||
53 | 77 | | |
54 | 78 | | |
55 | 79 | | |
| 80 | + | |
56 | 81 | | |
57 | 82 | | |
58 | 83 | | |
59 | 84 | | |
60 | 85 | | |
| 86 | + | |
61 | 87 | | |
62 | 88 | | |
63 | 89 | | |
| |||
241 | 267 | | |
242 | 268 | | |
243 | 269 | | |
244 | | - | |
245 | | - | |
| 270 | + | |
| 271 | + | |
246 | 272 | | |
247 | 273 | | |
248 | 274 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
17 | 23 | | |
18 | 24 | | |
19 | 25 | | |
| |||
123 | 129 | | |
124 | 130 | | |
125 | 131 | | |
126 | | - | |
| 132 | + | |
127 | 133 | | |
128 | 134 | | |
129 | 135 | | |
130 | 136 | | |
131 | | - | |
| 137 | + | |
132 | 138 | | |
133 | 139 | | |
134 | 140 | | |
| |||
158 | 164 | | |
159 | 165 | | |
160 | 166 | | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
161 | 170 | | |
162 | 171 | | |
163 | 172 | | |
| |||
174 | 183 | | |
175 | 184 | | |
176 | 185 | | |
177 | | - | |
| 186 | + | |
178 | 187 | | |
179 | 188 | | |
180 | 189 | | |
181 | | - | |
| 190 | + | |
182 | 191 | | |
183 | 192 | | |
184 | 193 | | |
| |||
199 | 208 | | |
200 | 209 | | |
201 | 210 | | |
202 | | - | |
| 211 | + | |
203 | 212 | | |
204 | 213 | | |
205 | 214 | | |
| |||
224 | 233 | | |
225 | 234 | | |
226 | 235 | | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
| 236 | + | |
| 237 | + | |
231 | 238 | | |
232 | 239 | | |
233 | 240 | | |
| |||
249 | 256 | | |
250 | 257 | | |
251 | 258 | | |
252 | | - | |
253 | | - | |
254 | | - | |
255 | | - | |
| 259 | + | |
| 260 | + | |
256 | 261 | | |
257 | 262 | | |
258 | 263 | | |
| |||
270 | 275 | | |
271 | 276 | | |
272 | 277 | | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
| 278 | + | |
| 279 | + | |
277 | 280 | | |
278 | 281 | | |
279 | 282 | | |
| |||
291 | 294 | | |
292 | 295 | | |
293 | 296 | | |
294 | | - | |
295 | | - | |
296 | | - | |
297 | | - | |
| 297 | + | |
| 298 | + | |
298 | 299 | | |
299 | 300 | | |
300 | 301 | | |
| |||
0 commit comments