snap7-client
Async Rust client for Siemens S7 PLCs over ISO-on-TCP. Pure Rust — no FFI, no native C dependency.
Part of the rs-snap7 workspace.
Features
| Capability | Status |
|---|---|
| S7Comm (S7-300/400) — read/write DB, multi-area, blocks, SZL | ✅ |
| S7CommPlus (S7-1200/1500 integrity mode) | ✅ |
Connection pool (S7Pool) with RAII checkout |
✅ |
| Multi-read / multi-write with automatic PDU batching | ✅ |
Typed tag addressing — DB1,REAL4, DB70,332.0, DB1,INT8 |
✅ |
| Tag read/write with type decoding/encoding | ✅ |
| Area absolute addressing — Merker, PA, PI, etc. | ✅ |
| Block operations — list, info, upload, download, delete, fill | ✅ |
| PLC control — stop, hot-start, cold-start, status | ✅ |
| PLC information — order code, CPU info, CP info, module list | ✅ |
| Session password — set, clear, read protection level | ✅ |
| SZL queries — system status list, clock, protection | ✅ |
| Copy RAM → ROM, compress memory | ✅ |
TLS transport (S7CommPlus encrypted via tokio-rustls) |
✅ |
| UDP transport | ✅ |
Sync (blocking) API — via sync feature |
✅ |
| Pure Rust, zero native dependencies | ✅ |
Add to your project
[]
= "0.1"
= { = "1", = ["rt-multi-thread", "macros"] }
Quick start
Single connection
use ;
use TcpTransport;
use SocketAddr;
async
Multi-read (single PDU round-trip)
use MultiReadItem;
let items = vec!;
let results = client.read_multi_vars.await?;
// results[0] and results[1] — automatically batched across PDUs when needed
Connection pool
use ;
use SocketAddr;
let pool = new;
let guard = pool.acquire.await?;
guard.client.db_read.await?;
// connection returned to pool on drop
Typed tag read/write
use parse_tag;
let tag = parse_tag?; // REAL at byte offset 4
let tag = parse_tag?;
let tag = parse_tag?; // bit 0 of byte 332
TLS (S7CommPlus encrypted)
use tls_connect;
let stream = tls_connect.await?;
let client = from_transport.await?;
Sync (blocking) API
Enable the sync feature and use snap7_client::client_sync::S7ClientSync.
= { = "0.1", = ["sync"] }
Tag address syntax
DB<n>,<type><byte-offset>
DB<n>,<byte-offset>.<bit>
| Type | Width | Example |
|---|---|---|
REAL |
4 B | DB1,REAL0 |
DINT |
4 B | DB1,DINT4 |
DWORD |
4 B | DB1,DWORD4 |
INT |
2 B | DB1,INT8 |
WORD |
2 B | DB1,WORD8 |
BYTE |
1 B | DB1,BYTE10 |
| bit | 1 bit | DB1,332.0 |
License
MIT — see LICENSE.