snap7-cli-0.1.6 is not a library.
snap7-cli
Command-line tool for communicating with Siemens S7 PLCs. Pure Rust — no FFI, no native C dependency. Read/write data blocks, watch tags, query SZL, upload blocks, and run an OPC-UA gateway — all from the terminal.
Part of the rs-snap7 workspace.
Install
# Main CLI
# Simulated PLC (for local testing)
# Sensor simulator (live-updating REAL values)
# OPC-UA tools (requires opcua feature)
Global flags
snap7 [FLAGS] <SUBCOMMAND>
-H, --host <HOST> PLC IP address
-p, --port <PORT> TCP port [default: 102]
-r, --rack <RACK> Rack number [default: 0]
-s, --slot <SLOT> Slot number [default: 1]
-f, --format <FORMAT> Output format: text|json|csv [default: text]
-t, --timeout-secs <SECS> Connect timeout [default: 5]
--tls Use TLS (S7CommPlus encrypted mode)
--tls-ca <PATH> PEM CA cert for TLS verification
--udp Use UDP transport
Subcommands
read — raw DB read
write — raw DB write (hex bytes)
tag — typed read/write
Supports DB, Merker (M), Timer (T), and Counter (C) tags:
# DB tags
# Merker tags
# Timer and Counter
watch — poll a DB region
block — block operations
# List all blocks grouped by type
# List all block numbers of a given type
# Show detailed info for a block
# Upload a block to file
szl — query system status list
plc-control — PLC state management
info — PLC information
password — session password
diag — connection diagnostics
serve — OPC-UA gateway (requires opcua feature)
See snap7-opcua-gateway for config format.
Output formats
All subcommands honour -f:
Local testing with the simulator
# Terminal 1 — simulated PLC on port 10200
# Terminal 2
# → DE AD BE EF
Tag address syntax
DB tags use a comma or dot separator:
DB<n>,<type><byte-offset>
DB<n>.<type><byte-offset> # dot separator, same result
DB<n>,<byte-offset>.<bit> # bit access
Merker, Timer, Counter tags are single-part — no separator:
M<byte>.<bit> MX<byte>.<bit> MB<byte> MW<byte> MD<byte>
T<n> C<n>
| Area | Type | Width | Example |
|---|---|---|---|
| DB | REAL |
4 B | DB1,REAL0 |
| DB | DINT |
4 B | DB1,DINT4 |
| DB | DWORD |
4 B | DB1,DWORD4 |
| DB | INT |
2 B | DB1,INT8 |
| DB | WORD |
2 B | DB1,WORD8 |
| DB | BYTE |
1 B | DB1,BYTE10 |
| DB | bit | 1 bit | DB1,332.0 |
| Merker | bit | 1 bit | M10.3 / MX10.3 |
| Merker | byte | 1 B | MB10 |
| Merker | word | 2 B | MW20 |
| Merker | dword | 4 B | MD4 |
| Timer | S5Time | 2 B | T5 |
| Counter | BCD | 2 B | C3 |
License
MIT — see LICENSE.