6b3da93151
A browse-committed AB CIP / TwinCAT / FOCAS tag bound with its model's DEFAULT
data type, not the one the device reported. A browsed REAL committed as
`{"tagPath":"Pump_1_Speed","dataType":"DInt"}` — and those three drivers decode
the wire bytes by that field, not by the raw row's OPC UA DataType — so the tag
read four bytes of a float through an integer decoder and published a plausible
wrong number with no error raised anywhere. FOCAS was missed when #536 was filed.
The type is CARRIED, not derived. Reverse-mapping the leaf's driver-agnostic
DriverDataType looks like the smaller fix and is wrong: SInt/Int/DInt/USInt/UInt
all collapse into Int32 on the way out of the driver, so that version would bind
a 16-bit INT as a 32-bit DINT while appearing to fix the REAL. Drivers now state
their own type name on DriverAttributeInfo.NativeDataType, which reaches the
picker as AttributeInfo.AddressFields["dataType"] and the commit mapper from
there. A leaf that states nothing keeps the model default — the pre-#536
behaviour, kept deliberately as the fallback rather than a guess.
Numeric strings are refused before parsing: Enum.TryParse accepts "9" for any
enum and Enum.IsDefined then confirms it, so an unguarded parse would bind a tag
to a type nobody named. A test caught this in the first version of the guard.
--- and the other half, which the fixture was hiding ---
Test Connect on a device with NO authored tags — every AB CIP device at the
moment an operator first presses the button — reported "CIP handshake failed"
against a healthy controller. That was written down as a fixture limitation
("ab_server doesn't implement @raw_cpu_type"). Both halves of that were wrong:
* @raw_cpu_type is not a libplctag special tag at all (only @raw, @tags and
@udt/ are), so it goes out as an ordinary symbolic name that no controller
defines, and the controller's "tag does not exist" IS the successful answer.
* ab_server answered an unresolvable tag path with CIP 0x03 where a Logix
controller answers 0x04 — ErrorBadParam vs ErrorNotFound, which the probe
classifies oppositely. Fixed in vendored patch 0002.
* With the fixture then telling the truth, the real defect surfaced:
AbCipDriverProbe.IsReachableException matched the native C status spellings
("STATUS_NOT_FOUND"), but libplctag.NET throws with the MANAGED enum name
("ErrorNotFound"). Those substrings can never match, so the reachable
classification could not fire on the exception path — which is the path every
no-authored-tags probe takes. This was failing on real hardware too, not just
against the sim. It now recovers the Status and defers to IsReachableStatus,
so there is one classification rather than two that can drift.
Rejected: switching the fallback to @tags. libplctag builds a tag-listing tag
with NO network I/O, so it reports OK against any TCP listener — measured green
against a Mosquitto broker.
Verification: full solution suite green. Falsification runs confirm exactly the
intended tests go red — 9 for the type carry, 3 (the reachable statuses only) for
the probe classification. Live on docker-dev: browse-committed TestString/
Motor_Run/TestSINT now store String/Bool/SInt, alongside last session's
Pump_1_Speed still holding the wrong DInt. TestSINT is the falsifier — its row
DataType is Int32, identical to TestDINT's, so no reverse map could have produced
"SInt".
Known consequence: pre-existing browse-committed tags keep their wrong dataType;
the fix applies to new commits only.
Claude-Session: https://claude.ai/code/session_015p7wGqy3YpZNCpDzTpGMKo
90 lines
3.1 KiB
Markdown
90 lines
3.1 KiB
Markdown
# `otopcua-abcip-cli` — AB CIP test client
|
|
|
|
Ad-hoc probe / read / write / subscribe tool for ControlLogix / CompactLogix /
|
|
Micro800 / GuardLogix PLCs, talking to the **same** `AbCipDriver` the OtOpcUa
|
|
server uses (libplctag under the hood).
|
|
|
|
Second of six driver test-client CLIs (Modbus → AB CIP → AB Legacy → S7 →
|
|
TwinCAT → FOCAS). Shares `Driver.Cli.Common` with the others; see
|
|
[DriverClis.md](DriverClis.md) for the authoritative roster.
|
|
|
|
## Build + run
|
|
|
|
```powershell
|
|
dotnet run --project src/Drivers/Cli/ZB.MOM.WW.OtOpcUa.Driver.AbCip.Cli -- --help
|
|
```
|
|
|
|
## Common flags
|
|
|
|
| Flag | Default | Purpose |
|
|
|---|---|---|
|
|
| `-g` / `--gateway` | **required** | Canonical `ab://host[:port]/cip-path` |
|
|
| `-f` / `--family` | `ControlLogix` | ControlLogix / CompactLogix / Micro800 / GuardLogix |
|
|
| `--timeout-ms` | `5000` | Per-operation timeout |
|
|
| `--verbose` | off | Serilog debug output |
|
|
|
|
Family ↔ CIP-path cheat sheet:
|
|
- **ControlLogix / CompactLogix / GuardLogix** — `1,0` (slot 0 of chassis)
|
|
- **Micro800** — empty path, just `ab://host/`
|
|
- **Sub-slot Logix** (rare) — `1,3` for slot 3
|
|
|
|
## Commands
|
|
|
|
### `probe` — is the PLC up?
|
|
|
|
```powershell
|
|
# ControlLogix — read a real tag
|
|
otopcua-abcip-cli probe -g ab://10.0.0.5/1,0 -t TestDINT --type DInt
|
|
|
|
# …or any name at all: `@raw_cpu_type` is NOT a libplctag special tag (only `@raw`, `@tags`
|
|
# and `@udt/` are), so it goes out as an ordinary symbolic name that no controller defines.
|
|
# The "tag does not exist" answer is itself proof the CIP session came up.
|
|
otopcua-abcip-cli probe -g ab://10.0.0.5/1,0 -t @raw_cpu_type --type DInt
|
|
|
|
# Micro800 — point at a user-supplied global
|
|
otopcua-abcip-cli probe -g ab://10.0.0.6/ -f Micro800 -t _SYSVA_CLOCK_HOUR --type DInt
|
|
```
|
|
|
|
### `read` — single Logix tag
|
|
|
|
```powershell
|
|
# Controller scope
|
|
otopcua-abcip-cli read -g ab://10.0.0.5/1,0 -t Motor01_Speed --type Real
|
|
|
|
# Program scope
|
|
otopcua-abcip-cli read -g ab://10.0.0.5/1,0 -t "Program:Main.Counter" --type DInt
|
|
|
|
# Array element
|
|
otopcua-abcip-cli read -g ab://10.0.0.5/1,0 -t "Recipe[3]" --type Real
|
|
|
|
# UDT member (dotted path)
|
|
otopcua-abcip-cli read -g ab://10.0.0.5/1,0 -t "Motor01.Speed" --type Real
|
|
```
|
|
|
|
### `write` — single Logix tag
|
|
|
|
Same shape as `read` plus `-v`. Values parse per `--type` using invariant
|
|
culture. Booleans accept `true`/`false`/`1`/`0`/`yes`/`no`/`on`/`off`.
|
|
Structure (UDT) writes need the member layout declared in a real driver config
|
|
and are refused by the CLI.
|
|
|
|
```powershell
|
|
otopcua-abcip-cli write -g ab://10.0.0.5/1,0 -t Motor01_Speed --type Real -v 3.14
|
|
otopcua-abcip-cli write -g ab://10.0.0.5/1,0 -t StartCommand --type Bool -v true
|
|
```
|
|
|
|
### `subscribe` — watch a tag until Ctrl+C
|
|
|
|
```powershell
|
|
otopcua-abcip-cli subscribe -g ab://10.0.0.5/1,0 -t Motor01_Speed --type Real -i 500
|
|
```
|
|
|
|
## Typical workflows
|
|
|
|
- **"Is the PLC reachable?"** → `probe`.
|
|
- **"Did my recipe write land?"** → `write` + `read` back.
|
|
- **"Why is tag X flipping?"** → `subscribe`.
|
|
- **"Is this GuardLogix safety tag writable from non-safety?"** → `write` and
|
|
read the status code — safety tags surface `BadNotWritable` / CIP errors,
|
|
non-safety tags surface `Good`.
|