Repository navigation
Add pluggable auxiliary-sensor co-logging - #3
Merged
Merged
Conversation
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
force-pushed
the
stack/01-aux-sensors
branch
from
November 16, 2026 18:33
66a70f6 to
dd0b4aa
Compare
12 of 13 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 targetsmain; PR 2 targets this branch. Merge bottom-up with Rebase and merge so the commits and their messages survive. The stack isphase0/reviewable-baselinecut into reviewable pieces; the last PR's tree is that branch's tree.Type of change
Hardware testing
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/ -vpasses locally — 578 passed, 39 skipped at this PR's headHow to verify:
Checklist
README.md/ version history if user-visible — the changelog's Unreleased section covers the whole stack and lands in PR 21