Helios: don't let an unlabelled reply pass for a register's value

_value_in()'s last resort was to accept any line it could not attribute as
the answer to whatever had just been asked.  That fallback exists for the
serial numbers, which come back bare — but it applied to every query, so a
stray "32" could be read as a diode current of 32 mA.  32 is also what a
status register reads with bit 5 set (LER "Over voltage laser diode", LCE
"Door switch open", CCE "Q-switch under/over temperature"), which is
exactly the value the panel is stuck on.

Only CSR and HSR now accept an unlabelled reply; every other read has to
see its own mnemonic in the line.  A read that cannot be attributed returns
None, and the panel shows "laser: ? mA" instead of leaving the last good
value on screen looking live — a stale reading and a setpoint that refuses
to move are indistinguishable otherwise.

tools/helios_lds_probe.py is the diagnostic for the underlying question:
it talks to the controller with no reply parsing at all and prints every
byte, so the transcript says whether LDS answers for itself, whether the
write is taken, and which flags the registers hold before and after.  The
status-register tables move to hardware/helios_registers.py so the probe
can decode them without importing the Qt app.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Thomas Ales
2026-09-08 07:48:06 -05:00
parent c7eb33891c
commit eff589d901
6 changed files with 389 additions and 111 deletions
+16 -1
View File
@@ -337,6 +337,7 @@ class HeliosWorker(PollingQueueWorker):
"""
enabled_updated = pyqtSignal(bool)
current_updated = pyqtSignal(int)
current_unknown = pyqtSignal()
diode_temp_updated = pyqtSignal(float)
pstage_temp_updated = pyqtSignal(float)
qswitch_temp_updated = pyqtSignal(float)
@@ -426,8 +427,19 @@ class HeliosWorker(PollingQueueWorker):
self.enabled_updated.emit(self._laser.is_laser_enabled())
except Exception:
pass
# A failed LDS read must not leave the last good value on screen
# looking live: that is indistinguishable from a setpoint that
# refuses to move, which is the failure this panel exists to show.
try:
current = self._laser.get_current_ma()
except Exception:
current = None
if current is None:
self.current_unknown.emit()
else:
self.current_updated.emit(current)
for getter, signal in (
(self._laser.get_current_ma, self.current_updated),
(self._laser.get_diode_temp_c, self.diode_temp_updated),
(self._laser.get_power_stage_temp_c, self.pstage_temp_updated),
(self._laser.get_qswitch_temp_c, self.qswitch_temp_updated),
@@ -1015,6 +1027,9 @@ class HeliosWindow(QWidget):
self.helios_set_current_btn.clicked.connect(self._on_set_current)
self._worker.current_updated.connect(self._on_current_updated)
self._worker.current_unknown.connect(
lambda: self.helios_current_readback_label.setText("laser: ? mA")
)
self._worker.diode_temp_updated.connect(
lambda t: self.helios_temp_diode_label.setText(f"{t:.1f} °C")
)