Auto: s7-c1 — surface negotiated PDU size via DriverHealth.Diagnostics

Closes #294
This commit is contained in:
Joseph Doherty
2026-04-26 00:35:49 -04:00
parent f469cf7e0d
commit 6540bbe1ef
6 changed files with 165 additions and 1 deletions

View File

@@ -44,6 +44,10 @@ The driver ctor change that made this possible:
bool-with-bit in one batch call; proves typed decode per S7DataType
- `S7_1500SmokeTests.Driver_write_then_read_round_trip_on_scratch_word`
`DB1.DBW100` write → read-back; proves write path + buffer visibility
- `S7_1500DiagnosticsTests.Driver_exposes_negotiated_pdu_size_post_init`
asserts `DriverHealth.Diagnostics["S7.NegotiatedPduSize"]` is non-zero
after `InitializeAsync`; proves the negotiated PDU size surfaces in
driver health (Snap7 fixture pins this at 240 bytes — see fixture README)
### Unit

View File

@@ -548,6 +548,31 @@ under the standard `<DriverType>.<Counter>` naming convention:
Observe via the `driver-diagnostics` RPC (`/api/v2/drivers/{id}/diagnostics`)
or the Admin UI's per-driver dashboard.
### Diagnostics surfacing
Beyond the coalescing counters above, the S7 driver also surfaces the
**negotiated PDU size** captured during the COTP/S7comm handshake under the
same `<DriverType>.<Counter>` naming convention:
- `S7.NegotiatedPduSize` — the PDU envelope size advertised by the CPU
during `Plc.OpenAsync`. Default S7-1500 CPUs negotiate **240 bytes**;
CPUs running the extended PDU advertise **480 or 960 bytes**. The value
is `0` before the first successful connect and is reset to `0` on
driver shutdown so an operator inspecting the Admin UI dashboard can
immediately tell whether the driver is currently online.
Together these counters answer the most common operator questions about
S7 driver health without reaching for a Wireshark capture:
- "Is the driver actually connected?" → `S7.NegotiatedPduSize > 0`
- "Is coalescing working?" → `S7.TotalBlockReads` climbing while
`S7.TotalMultiVarBatches` stays flat
- "Why is throughput poor?" → `S7.NegotiatedPduSize` is 240 instead of 960
(operator can switch the CPU to extended PDU if the project allows)
The values render alongside Modbus / OPC UA Client metrics in the Admin
UI driver-diagnostics panel — same RPC, same dashboard row layout.
## References
1. Siemens Industry Online Support, *Modbus/TCP Communication between SIMATIC S7-1500 / S7-1200 and Modbus/TCP Controllers with Instructions `MB_CLIENT` and `MB_SERVER`*, Entry ID 102020340, V6 (Feb 2021). https://cache.industry.siemens.com/dl/files/340/102020340/att_118119/v6/net_modbus_tcp_s7-1500_s7-1200_en.pdf