Skip to content

Add pluggable auxiliary-sensor co-logging - #3

Merged
PEEKPerformer merged 6 commits into
stack/00-main-prepfrom
stack/01-aux-sensors
Nov 16, 2026
Merged

PEEKPerformer merged 6 commits into
stack/00-main-prepfrom
stack/01-aux-sensors

Conversation

@PEEKPerformer

@PEEKPerformer PEEKPerformer commented Sep 22, 2026 •

Copy link
Copy Markdown
Owner

Summary

Any measurement mode can co-log readings from auxiliary sensors (a serial thermocouple, a multi-channel stream sensor) beside the Keithley's rows, with a live readout for equilibration and fault provenance in the file.

Work from June that never merged. The lab's runs need the sample temperature in the same file as the resistance, and until now that was a second instrument and a spreadsheet. Reads are non-blocking so a slow or unplugged sensor cannot stall the SCPI loop, and the aux preview survives the Arduino's USB-reset window.

Stack

Part 1 of 28. Targets stack/00-main-prep (#31), which targets main; PR 2 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

A stream sensor and a serial sensor are exercised against fakes and the simulator's auxiliary thermocouple. Not re-run on the lab's Arduino for this PR.

Test suite

  • QT_QPA_PLATFORM=offscreen pytest tests/ -v passes locally — 578 passed, 39 skipped 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

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

Add a generic auxiliary-sensor layer so any streaming sensor (thermocouple,
flow, strain, humidity, ...) can be co-logged with each four-point-probe
point. A sensor declares its own channels(); the worker, exporter, and CSV
schema follow that declaration, so a new sensor needs no downstream changes.

- sensors.py: AuxiliarySensor protocol, SerialLineSensor base (flush-then-read
  freshness + resync), Arduino K-type thermocouple driver, name->class registry
- 4pp: optional fpp_log_temp opens a sensor and stamps aux_* columns per point;
  off by default and byte-identical to existing 4PP CSVs
- simulator: FakeSerialSensor + --sim-temp / --sim-aux-address for hardware-free
  end-to-end runs
- declare pyserial (pyvisa-py needs it to open ASRL serial resources)
Show a 2 Hz aux-sensor reading on the 4PP tab while idle so the sample can be
watched to equilibrium before a run. Hand the serial port off to the worker on
Start (only one handle per port), feed the readout from data_point during the
run, then resume the idle preview once the run ends. A failed read stops the
preview rather than re-blocking the GUI thread each tick.
Bench testing on the rig showed the MAX31856 board emits a banner + READY
line and takes ~2 s to start streaming after the port opens. The idle preview
now tolerates several consecutive read misses (the reset window) before giving
up, instead of stopping on the first one. Correct the driver comment to
MAX31856 and document the startup banner that read_latest resyncs past.
Co-logging now works on any continuous Keithley mode (resistance, source-V,
source-I, 4PP), anchored to the measurement run, configured once via a global
aux-source section in Settings (enable / driver / address) instead of a 4PP-only
checkbox. Aux columns splice into each supported mode's CSV only when enabled;
the schema is byte-identical when off. Sweep (atomic) and vdP (manual geometry)
are intentionally excluded.

Add StreamSensor: a generic multi-channel driver whose channels are
self-described by the device at connect (HDR,key:unit,... then positional DATA
rows), then discovered dynamically — proving the "Keithley + arbitrary data
sources" model with one serial link carrying many declared channels. A
FakeStreamSensor and --sim-stream-address exercise it end-to-end, no hardware.
- SerialLineSensor runs a background reader thread that caches the newest
  parsed line; read_latest() is a non-blocking cache read with staleness
  detection, so the acquisition loop and GUI never wait on the serial
  stream — a 10 Hz run stays 10 Hz with aux logging on, and a silent or
  unplugged sensor can no longer stall points or freeze the preview.
  StreamSensor captures its header in the reader thread; wait_ready() /
  wait_for_reading() serve callers that can afford to block (the worker).
- Replace NaN-on-fault with an aux_fault provenance column: channel values
  are recorded and marked, never silently dropped; the worker consumes
  reading_to_columns() so the glue and the CSV schema cannot drift; a
  nonzero status flag marks rows instead of wiping a run's aux data.
- VisaInstrument.close() closes only its own device session — pyvisa's
  ResourceManager is a process-wide singleton and closing it severed every
  other live session (first observable with two concurrent instruments).
  Test Connection likewise no longer closes the shared manager.
- Prefix aux connect failures ("Auxiliary sensor: ...") and exclude them
  from the GPIB address remediation, so an unplugged thermocouple can no
  longer lead to rewriting the machine-local SMU address.
- Preview lifecycle: reconcile instead of restart — no port close/reopen
  on tab switches or unchanged settings (no repeated USB auto-resets),
  preview follows user switching, stale channel cache cleared on stop,
  and the in-run readout updates for every co-logging mode, not just 4PP.
- parse_stream_header rejects duplicate channel keys (HDF5 compound dtype
  rejects them mid-run; CSV silently collapsed a channel).
- Cleanup: public AUX_LOG_MODES shared by worker and exporter, one
  splice_before_tail helper for the delta and aux row splices, explicit
  aux_columns/aux_units parameters replacing settings-dict smuggling, aux
  timing constants in constants.py, e2e harness deduplicated into
  conftest.py/e2e_utils.py.
@PEEKPerformer
PEEKPerformer changed the base branch from main to stack/00-main-prep November 16, 2026 18:33
@PEEKPerformer
PEEKPerformer merged commit 78be508 into stack/00-main-prep Nov 16, 2026
5 of 8 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