go-s7comm
Siemens S7 client: read and write DBs, inputs, outputs and markers, discovery and SZL diagnostics.
go get github.com/otfabric/go-s7commSiemens S7 command-line client for ISO-on-TCP (port 102).
Linux and macOS
curl -fsSL https://get.otfabric.io/s7commctl | shWindows (PowerShell)
irm https://get.otfabric.io/s7commctl.ps1 | iexCI, containers and device images
curl -fsSL https://get.otfabric.io/s7commctl | env OTF_UNMANAGED_INSTALL=/usr/local/bin shOne static binary for Linux (x86-64, ARM64, ARMv7), macOS (Intel, Apple silicon) and Windows (x86-64, ARM64), with no runtime to install. The installer checks the release's SHA-256 checksum, installs per user without sudo, and upgrades in place when you run it again. Pin a release withOTF_VERSION. All install options. To build from source: make build in a checkout.
# Find S7 devices on a subnet, as JSON
s7commctl discover --cidr 192.168.1.0/24 --format json
# Which rack and slot values does the PLC accept?
s7commctl probe rackslot --ip 192.168.1.10 --format table
# Read 16 bytes from data block 1
s7commctl read --ip 192.168.1.10 --area DB --db 1 --offset 0 --size 16 --format hex
# List the blocks on the PLC
s7commctl list blocks --ip 192.168.1.10 --format table
# Write an INT, which needs an explicit --dangerous
s7commctl write --ip 192.168.1.10 --area DB --db 1 --offset 0 --type int --value 123 --dangerousThe s7commctl guide walks through every command group, connection option and safety rule.
s7commctl is as easy to read for a pipeline as for a person. It follows the same conventions as every OT Fabric tool, so a script written for one protocol carries over to the next.
--format json, or S7COMMCTL_FORMAT=json for a whole job. One JSON document per command, JSON Lines for streams, and a single {"error": {"kind", "code", "message"}} object on failure. Field names are a documented contract: json-output.md.s7commctl version --json prints name, version,tag, commit, built, libraries (the OT Fabric stacks inside the binary), go andplatform, with the same keys in every tool.OTF_VERSION, and OTF_UNMANAGED_INSTALL for images that must not touch PATH or shell profiles.| Code | Meaning |
|---|---|
0 | Success |
1 | Findings: the command completed and its result reports problems, such as a file that does not validate or a diagnosis with a failing check |
2 | Usage: unknown command or flag, a missing argument |
3 | Invalid input: a flag value, a file or a combination that does not make sense. Nothing was sent |
4 | Transport: the connection could not be made, or was lost |
5 | Timeout: the device did not answer in time |
6 | Protocol: the device refused the request, or broke the protocol |
7 | Partial success: a valid result was written, and it holds failures |
8 | Unsupported: the device, or this platform, does not support what was asked |
9 | Permission: the device or the operating system refused, such as raw-socket access without the capability |
10 | Output or internal error |
130 | Interrupted by Ctrl-C or SIGTERM before a result |
Each tool uses the codes that apply to it; a code never changes meaning between tools.
In a Dockerfile
FROM debian:bookworm-slim
RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl \
&& curl -fsSL https://get.otfabric.io/s7commctl \
| env OTF_UNMANAGED_INSTALL=/usr/local/bin sh \
&& rm -rf /var/lib/apt/lists/*
ENTRYPOINT ["s7commctl"]Scripts, CI and containers has GitHub Actions and GitLab CI examples and shows how to use a simulator as a test fixture.
The README on GitHub has the full feature list, examples and changelog.
Siemens S7 client: read and write DBs, inputs, outputs and markers, discovery and SZL diagnostics.
go get github.com/otfabric/go-s7commCOTP TP0 transport service over RFC 1006, plus a full X.224 TPDU codec.
go get github.com/otfabric/go-cotpTPKT framing for RFC 1006 and RFC 2126 transport profiles.
go get github.com/otfabric/go-tpktFixture-driven Snap7 servers (native and pure Python) for testing S7 clients.