Files
lmxopcua/docs/Driver.AbLegacy.Cli.md
Joseph Doherty f46e126208 fix(driver-ablegacy-cli): resolve Low code-review findings (Driver.AbLegacy.Cli-002,003,004,005,006,007)
- Driver.AbLegacy.Cli-002: WriteCommand.Value description lists the full
  true/false, 1/0, on/off, yes/no alias set.
- Driver.AbLegacy.Cli-003: SubscribeCommand serialises every WriteLine
  via a per-execution consoleGate lock so the poll-thread OnDataChange
  handler can't interleave with the banner.
- Driver.AbLegacy.Cli-004: dropped 'await using var driver' in favour of
  a plain 'var driver' + explicit await ShutdownAsync in finally; the
  driver is no longer shut down twice.
- Driver.AbLegacy.Cli-005: SubscribeCommand.IntervalMs description
  carries the PollGroupEngine 250ms-floor caveat; docs/Driver.AbLegacy.Cli.md
  spells out the same.
- Driver.AbLegacy.Cli-006: ProbeCommand --type now carries the short
  alias 't' to match the other commands.
- Driver.AbLegacy.Cli-007: BuildOptionsTests cover the probe-disabled,
  device-shape, tag-passthrough, timeout-propagation, and empty-tag-list
  paths.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-23 08:34:32 -04:00

3.6 KiB

otopcua-ablegacy-cli — AB Legacy (PCCC) test client

Ad-hoc probe / read / write / subscribe tool for SLC 500 / MicroLogix 1100 / MicroLogix 1400 / PLC-5 devices, talking to the same AbLegacyDriver the OtOpcUa server uses (libplctag PCCC back-end).

Third of four driver test-client CLIs. Shares Driver.Cli.Common with the others.

Build + run

dotnet run --project src/Drivers/Cli/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Cli -- --help

Common flags

Flag Default Purpose
-g / --gateway required Canonical ab://host[:port]/cip-path
-P / --plc-type Slc500 Slc500 / MicroLogix / Plc5 / LogixPccc
--timeout-ms 5000 Per-operation timeout
--verbose off Serilog debug output

Family ↔ CIP-path cheat sheet:

  • SLC 5/05 / PLC-51,0
  • MicroLogix 1100 / 1400 — empty path (ab://host/) — they use direct EIP with no backplane
  • LogixPccc1,0 (Logix controller accessed via the PCCC compatibility layer; rare)

PCCC address primer

File letters imply data type; type flag still required so the CLI knows how to parse your --value.

File Type CLI --type
N signed int16 Int
F float32 Float
B bit-packed (B3:0/3 addresses bit 3 of word 0) Bit
L long int32 (SLC 5/05+ only) Long
A analog int (semantically like N) AnalogInt
ST ASCII string (82-byte + length header) String
T timer sub-element (T4:0.ACC / .PRE / .EN / .DN) TimerElement
C counter sub-element (C5:0.ACC / .PRE / .CU / .CD / .DN) CounterElement
R control sub-element (R6:0.LEN / .POS / .EN / .DN / .ER) ControlElement

Commands

probe

# SLC 5/05 — default probe address N7:0
otopcua-ablegacy-cli probe -g ab://192.168.1.20/1,0

# MicroLogix 1100 — status file first word
otopcua-ablegacy-cli probe -g ab://192.168.1.30/ -P MicroLogix -a S:0

read

# Integer
otopcua-ablegacy-cli read -g ab://192.168.1.20/1,0 -a N7:10 -t Int

# Float
otopcua-ablegacy-cli read -g ab://192.168.1.20/1,0 -a F8:0 -t Float

# Bit-within-word
otopcua-ablegacy-cli read -g ab://192.168.1.20/1,0 -a B3:0/3 -t Bit

# Long (SLC 5/05+)
otopcua-ablegacy-cli read -g ab://192.168.1.20/1,0 -a L19:0 -t Long

# Timer ACC
otopcua-ablegacy-cli read -g ab://192.168.1.20/1,0 -a T4:0.ACC -t TimerElement

write

otopcua-ablegacy-cli write -g ab://192.168.1.20/1,0 -a N7:10 -t Int -v 42
otopcua-ablegacy-cli write -g ab://192.168.1.20/1,0 -a F8:0 -t Float -v 3.14
otopcua-ablegacy-cli write -g ab://192.168.1.20/1,0 -a B3:0/3 -t Bit -v on

Writes to timer / counter / control sub-elements land at the wire level but the PLC's runtime semantics (EN/DN edge-triggering, preset reload) are PLC-managed — use with caution.

subscribe

otopcua-ablegacy-cli subscribe -g ab://192.168.1.20/1,0 -a N7:10 -t Int -i 500

-i / --interval-ms is the publishing interval in milliseconds — default 1000. PollGroupEngine floors sub-250 ms values, so -i 100 runs at 250 ms.

Known caveat — ab_server upstream gap

The integration-fixture ab_server Docker container accepts TCP but its PCCC dispatcher doesn't actually respond — see tests/...AbLegacy.IntegrationTests/Docker/README.md. Point --gateway at real hardware or an RSEmulate 500 box for end-to-end wire-level validation. The CLI itself is correct regardless of which endpoint you target.