Summary
Add configurable request rate limiting to prevent overwhelming PLCs with too many requests, especially older/smaller models with limited processing capacity.
Background
Siemens S7-200 and S7-300 PLCs have limited communication resources. Sending requests too fast can cause the PLC to drop connections, queue requests, or even affect scan cycle times. A built-in rate limiter would protect against this, especially in polling loops.
What needs to be done
API Design Ideas
client = snap7.Client(
max_requests_per_second=10, # 0 for unlimited (default)
rate_limit_behavior="block", # "block", "raise", or "drop"
)
client.connect("192.168.1.10", 0, 1)
# Operations are automatically throttled
for i in range(1000):
data = client.db_read(1, 0, 4) # Will not exceed 10 req/s
Notes
- Different PLC models have different limits:
- S7-200: ~10 requests/second
- S7-300: ~20-50 requests/second
- S7-400: ~100+ requests/second
- S7-1200/1500: ~100+ requests/second
- Could provide sensible defaults per PLC model (auto-detected from CPU info)
- Rate limiting should account for multi-variable operations (one multi-read = one request, not N)
- Should work with both sync and future async clients
Summary
Add configurable request rate limiting to prevent overwhelming PLCs with too many requests, especially older/smaller models with limited processing capacity.
Background
Siemens S7-200 and S7-300 PLCs have limited communication resources. Sending requests too fast can cause the PLC to drop connections, queue requests, or even affect scan cycle times. A built-in rate limiter would protect against this, especially in polling loops.
What needs to be done
API Design Ideas
Notes