Add single-shot measurement mode matching vendor protocol

Stop command triggers a one-shot reading instead of start+poll+stop.
spectrometer.py now uses take_single_reading() for this flow.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-05 09:23:38 +07:00
parent 15d8444cac
commit 3bf4a7ad36
2 changed files with 25 additions and 1 deletions

View File

@@ -426,6 +426,30 @@ class HPCS6500:
return result
def take_single_reading(self):
"""Trigger a single measurement (no PSU control).
Sends stop to trigger a one-shot reading, waits for data, reads it,
then resets. This matches the vendor software's single-test flow."""
self.stop_measurement()
if not self.wait_for_data(timeout=30.0):
print("Timeout waiting for measurement data")
return None
meas = self.read_measurement_block()
elec = self.read_electrical_block()
if meas is None:
print("Failed to read measurement block")
return None
result = self._parse_measurement(meas)
if elec is not None:
result.update(self._parse_electrical(elec))
self.reset()
return result
def read_current(self):
"""Read current data without starting/stopping measurement.
Use this when the vendor software is controlling the instrument."""

View File

@@ -17,7 +17,7 @@ def measure():
try:
dev.identify()
dev.set_integration_time(0) # auto
reading = dev.take_reading(psu=False)
reading = dev.take_single_reading()
finally:
dev.close()