Skip to content

docs(adr): decide how ivi-cli reads SCPI text - #192

Open
ShortArrow wants to merge 1 commit into
mainfrom
docs/adr-scpi-text-interpretation
Open

docs(adr): decide how ivi-cli reads SCPI text#192
ShortArrow wants to merge 1 commit into
mainfrom
docs/adr-scpi-text-interpretation

Conversation

@ShortArrow

Copy link
Copy Markdown
Owner

Three places in this repository read SCPI text, and each had grown its own rule without reference to the others:

Surface Language
Mock rule matching literal equality — NormalizeForMatch strips a leading : and nothing else
Script assert regular expression, partial match
visa lint, completion mnemonic vocabulary, standard roots only

The trigger was a request to assert numerically on a reading (25.3,72.1 from a temperature/humidity probe). That could not be answered on its own — whether ; separates anything, whether MEAS and MEASure are the same command, and which surface speaks which language turned out to be one decision.

What the standard actually requires

Verified against the specification rather than from habit, because two of the decisions rest on it: headers are case-insensitive; a mnemonic has exactly two spellings and nothing between them is valid (":FREQuen is not an acceptable form"); ; leaves the command path where it was, so returning to the root needs ;:; optional keywords in brackets apply implicitly.

Two of those cannot be honoured generically — optional keywords and default suffixes are properties of one instrument's command tree, and ADR 0032 already declined to carry vendor dictionaries. A third is one-directional: a long-form rule yields its short form mechanically, a short-form rule does not yield its long form.

Decisions

  1. Canonicalization: case folding and the leading colon, nothing more. Every match in every scenario here is short form and upper case, so this changes no existing behaviour while making the mock accept requests it refused and an instrument would have answered. Short/long equivalence is refused rather than deferred, with the reason recorded: ScpiVocabulary has root-node pairs, so a partial version is available and tempting — it would accept MEASure:VOLT? and refuse MEAS:VOLTage?, which looks like conformance and is full of holes.
  2. Requests: ; is not expanded. A compound request matches only as the whole string.
  3. Responses: ; then ,; block data stays opaque. The asymmetry with (2) is deliberate — a response carries no path.
  4. One grammar per directive, with a table of which surface speaks which.
  5. !values: slots of literal / * / {predicate}, ranges rather than float equality, optional slot names because the failure message is what heterogeneity actually breaks.

6. The script format break

Investigating where to put the new directive turned up two defects in the existing format, neither documented:

  • Every directive permanently removes a SCPI command. A line is a directive when it starts with sleep /assert /echo , otherwise it is SCPI, and there is no escape — an instrument with a vendor extension spelled ECHO ON cannot be driven from a script at all.
  • # cannot mark a comment inside a SCPI line. IEEE 488.2 gives # four meanings: #8<len> and #0 for block data, and #H/#Q/#B for hex/octal/binary. SOUR:VOLT #HFF sets 255. The parser strips from the first # unconditionally, so that line and every block transfer are silently truncated — and the code comment above the strip describes a conditional behaviour the implementation does not have.

So the format becomes one rule: a line starting with ! is ivi-cli's; everything else goes to the instrument verbatim. Comments are !#. ! is available precisely because a SCPI message begins with a letter, * or :. Trailing comments are dropped rather than rescued — any rule that finds a comment inside a SCPI line must enumerate the meanings of #, and the next edition is free to add a fifth.

Migration follows the shape this repository already used twice (diagnosedoctor, nested mock scenario scene): 0.3.x accepts both and warns, 0.4.0 removes the unprefixed form, landing alongside the mock-spelling removal users are already told to expect. No .scpi file exists here, so the warning is for scripts written elsewhere.

Documentation only; no code changes. Implementation follows in separate PRs.

Three surfaces had grown three unrelated rules for reading SCPI, and a
request to assert numerically on a reading could not be answered without
settling all of them; recording the script format's reserved-word and
comment defects here is what makes the 0.4.0 break worth taking.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant