Skip to content

Add diagnostic buffer reading and data change subscriptions#690

Merged
gijzelaerr merged 1 commit intomasterfrom
feature/alarms-and-subscriptions
Apr 15, 2026
Merged

Add diagnostic buffer reading and data change subscriptions#690
gijzelaerr merged 1 commit intomasterfrom
feature/alarms-and-subscriptions

Conversation

@gijzelaerr
Copy link
Copy Markdown
Owner

Summary

Implements the last two 4.0 milestone features.

Diagnostic buffer (#683):

from s7 import Client

client = Client()
client.connect("192.168.1.10", 0, 1)
entries = client.read_diagnostic_buffer()
for entry in entries:
    print(f"{entry['timestamp']} event={entry['event_id']:#06x}")

Reads SZL 0x00A0, parses 20-byte entries with BCD timestamps. Works via legacy S7 protocol.

Data change subscriptions (#684, experimental):

sub_id = client.create_subscription([(1, 0, 4), (1, 10, 4)], cycle_ms=100)
# ... PLC pushes updates ...
client.delete_subscription(sub_id)

Creates subscription objects via S7CommPlus CREATE_OBJECT. Requires S7CommPlus connection. Full notification receive loop needs real PLC testing.

Test plan

  • All 1441 existing tests pass
  • mypy and ruff clean
  • Test diagnostic buffer against real PLC
  • Test create/delete subscription against real PLC

Closes #683, closes #684.

🤖 Generated with Claude Code

Implements #683 (diagnostic buffer) and #684 (data subscriptions):

Diagnostic buffer (#683):
- read_diagnostic_buffer() on snap7.Client: reads SZL 0x00A0, parses
  20-byte entries with BCD timestamps into structured dicts
- Exposed through s7.Client.read_diagnostic_buffer() via legacy fallback

Data change subscriptions (#684, experimental):
- create_subscription(items, cycle_ms): builds a CREATE_OBJECT request
  with subscription-class attributes (cycle time, credit limit,
  reference list) — PLC pushes updates for monitored variables
- delete_subscription(subscription_id): sends DELETE_OBJECT to clean up
- Exposed through s7.Client with S7CommPlus requirement check

All subscription methods marked experimental. The subscription protocol
is modeled after S7CommPlusDriver's alarm subscription pattern, adapted
for data variable monitoring.

Closes #683, closes #684.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gijzelaerr gijzelaerr added this to the 4.0 milestone Apr 15, 2026
@gijzelaerr gijzelaerr merged commit 701cdd6 into master Apr 15, 2026
39 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Data change subscriptions (S7CommPlus) Read PLC alarm and diagnostic buffer

1 participant