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
S7Client— async read/write for S7-300/400/1200/1500 via S7CommS7PlusClient— S7CommPlus (S7-1200/1500 newer firmware)S7Pool— bounded connection pool with RAII checkout- Multi-read / multi-write — batched PDU packing, automatic splitting at PDU limit
- Typed tag access —
DB1,REAL4,DB70,332.0(bit),DB1,INT8, etc. - TLS transport — encrypted S7CommPlus via
tokio-rustls - UDP transport
syncfeature — blocking wrapper around the async client
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.