Skip to content

Fix what two bench days found - #13

Merged
PEEKPerformer merged 13 commits into
stack/10-visa-backend-and-driverfrom
stack/11-bench-fixes
Nov 16, 2026
Merged

PEEKPerformer merged 13 commits into
stack/10-visa-backend-and-driverfrom
stack/11-bench-fixes

Conversation

@PEEKPerformer

@PEEKPerformer PEEKPerformer commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

The frozen Windows backend against a 2420 and the driver against a 2400 (2026-09-18) found: websockets was never a declared dependency, so the first CI build had no WebSocket at all; the read-reply tail length on a real adapter; a settle needed after interface clear; the instrument lock was keyed to the config directory and never excluded a second backend; string settings fields crashed the UI blank; compliance was never detected in resistance mode (the 2400 and 2420 do not set the status word's compliance bit in the ohms function); and five UI majors.

Commit-message style changes at the first commit here (capitalised imperative, no type prefix). Earlier commits keep their style; rewording them would rewrite the whole branch for no content reason.

Stack

Part 11 of 28. Targets stack/10-visa-backend-and-driver; PR 12 targets this branch. Merge bottom-up with Rebase and merge so the commits and their messages survive. The stack is phase0/reviewable-baseline cut into reviewable pieces; the last PR's tree is that branch's tree.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing behavior to change)
  • Documentation only
  • CI / build / packaging only

Hardware testing

  • Tested against real hardware
  • Tested against software-only path
  • Not applicable

Keithley 2420 over GPIB (frozen Windows backend) and Keithley 2400 via GPIB-USB-HS on macOS, both 2026-09-18.

Test suite

  • QT_QPA_PLATFORM=offscreen pytest tests/ -v passes locally — 1159 passed at this PR's head
  • Added new tests for new behavior, or explained why none are needed

How to verify:

QT_QPA_PLATFORM=offscreen pytest tests/ -v
cd desktop && npm ci && npm test && npx tsc --noEmit

Checklist

  • My changes follow the existing code style
  • I have updated README.md / version history if user-visible — the changelog's Unreleased section covers the whole stack and lands in PR 21
  • I have read the CONTRIBUTING guidelines

Identify, a resistance run, a stop during the settle, an immediate restart
and a shutdown mid-run, all through the frozen Windows backend over NI-VISA,
with the instrument's own OUTP? confirming the output off afterwards. Also
records that auto-ohms chooses its own test current when Auto-range is on,
which the shipping worker has always done too.
uvicorn speaks WebSocket only through a separately installed library and
answers every upgrade with 404 without one. websockets was never a declared
dependency; it was on the development machine by accident, so the local
frozen build worked and the CI-built Windows bundle did not. Found on the
lab PC: the desktop UI sat on 'Reconnecting' while HTTP worked.

Declared in requirements and both extras; the spec collects the whole
package and names both uvicorn implementations, since auto has moved
between them across releases. A sidecar test performs a real upgrade
against the spawned process (Starlette's test client never asks uvicorn
to), and the CI smoke test does the same against the frozen binary.
First run against a GPIB-USB-HS (serial 01CEE482) with a Keithley 2400 at
primary address 3. The control path, the attach sequence, addressing,
writes, command bytes and the presence probe all behaved as the
specification describes. Two things did not:

The reply to a read ends in a 16-byte tail, not the 28 bytes the
specification derived: status block, count, last-block byte count, pad,
termination. The embedded status block and second count word it described
are not sent. The parser follows the device and tolerates the longer form.
The count word is meaningful only after a data operation; other replies
carry stale or fixed values there.

A hung adapter answers every control request normally, accepts bulk writes
until its FIFO fills, and never replies; a USB reset does not clear it,
only a power cycle does. attach() now says so: 'the adapter is hung.
Unplug it and plug it back in.'

Tests encode the observed replies as goldens; the specification records
each correction as observed on this unit and date.
Reproduced on the bench: attach, presence probe, close, attach again, then
address the instrument within a millisecond of take control. The Keithley
2400 is still switching between local and remote from the reset and the
renewed REN, its interface handshakes the addressing bytes in hardware and
drops them; the mild form loses a query (-420), the severe form stalls the
handshake and wedges the adapter until it is power-cycled. This is the
sequence connect() produces, since it lists resources and then opens.

100 ms after take control and after an IFC pulse, five times the measured
threshold. Injectable sleep, so tests do not wait. Ten attach-probe-close-
attach-query cycles back to back and three consecutive ResistaMet runs on
the 2400 now pass with no hang.
The instrument lock lived beside the config, which meant beside whichever
config each process was pointed at: the desktop app in its app-data folder,
a second backend in its own. They never looked at the same file. On the
bench the second backend was told 'started', connected a moment later, and
its SCPI landed in the middle of a live run, which died with read errors.

Locks now live in ~/.resistamet/locks for every ResistaMet process on the
machine. The session takes the lock before it answers start, so another
process holding the bus is a 409 the caller sees, not a run that fails
later; the run releases it in cleanup as before. The PySide6 worker path,
which takes the lock inside the run, is unchanged.
Settings > Aux sensor and Settings > Files & output emptied the page: their
string fields (driver, address, data directory) fell through FieldRow to the
numeric input, whose formatter called toPrecision on a string during render,
and nothing caught it. With an instrument running that left the operator
without a Stop button.

FieldRow now has a string branch (full-width text). Two error boundaries
back it up: one around the settings dialog body, which offers Close so a
broken section goes away with the dialog, and one around the application,
which says the measurement is unaffected in the backend and offers a reload.
The Keithley ohms function does not set the compliance bit in the status
word, on a 2400 and a 2420 (bench, 2026-09-18), and in manual range it
reports the programmed current rather than the measured one. A run into
compliance therefore archived V_limit / I_programmed as a resistance, every
row flagged OK, and Stop on compliance never fired: 100 ohms at 10 mA under
a 0.5 V limit was recorded as 49.98 ohms.

Resistance mode now does what the source modes do: a measured voltage at
99 % of the limit is compliance. The limit compared against is the one the
instrument reports after configuration, because auto-ohms overrides the
requested value (2.1 V for a 0.5 V request); that effective limit is also
recorded in the file header beside the request, so a reader sees what the
instrument overrode. The simulator no longer raises the bit the hardware
leaves clear, so its runs reproduce the fault.

Verified on the 2400: pinned readings flagged, Stop on compliance ends the
run after one sample, a run within the limit stays OK.
With Auto range on, the 2400's auto-ohms picks the test current per range
and sets its own voltage limit; the two fields kept showing the numbers
that were not in force. A field spec can now name the field that overrides
it, and the row renders disabled with a one-line reason.
Ten ticks of a resistance trace all read '10.07 Ω': four significant
figures cannot show a scale that lives in the fourth decimal, and the shared
prefix factor was itself computed from a rounded mantissa. One helper now
picks the prefix from the largest tick and the decimals from the tick
spacing, and both plots use it.
An aborted van der Pauw run showed the previous run's complete result
badged Done, and a new run showed the old readings until its first one
arrived. Events replayed after a reconnect carry the previous run's id and
were applied on top of the run in progress; and between Start and the
run_started event the store still describes the old run. The vdP and sweep
stores now ignore events from another run, and the vdP view shows the store
only when its run id matches the session's.
Start, stop, step and compliance are volts or amps depending on the source.
Changing the source kept the numbers and changed their meaning: a 2 V
compliance became 2 A with no warning. They now reset to a conservative
sweep for the new source, and the view says what they were set to until the
next edit. The schema bounds sweep_compliance at 3 in either unit, so the
current-source default limit is 2 V.
@PEEKPerformer
PEEKPerformer force-pushed the stack/10-visa-backend-and-driver branch from 3676cb4 to efce3d2 Compare November 16, 2026 18:33
@PEEKPerformer
PEEKPerformer merged commit cb5cfee into stack/10-visa-backend-and-driver Nov 16, 2026
2 checks passed
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