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:
@@ -235,3 +235,22 @@ def test_a_set_frequency_is_read_back(laser):
|
||||
def test_an_out_of_range_current_is_not_sent(laser):
|
||||
assert laser.set_current_ma(9000) is False
|
||||
assert laser.serial.written == []
|
||||
|
||||
|
||||
def test_an_unlabelled_number_is_not_taken_as_a_register_value(laser):
|
||||
"""A bare number answers nothing in particular.
|
||||
|
||||
The controller's status registers read 32 when bit 5 is set (LER "Over
|
||||
voltage laser diode", LCE "Door switch open"), and a diode current of
|
||||
32 mA is a perfectly ordinary-looking value — so a stray "32" must not
|
||||
be allowed to pass for the answer to LDS.
|
||||
"""
|
||||
laser.serial.replies = {"LDS": ["32"]}
|
||||
assert laser.get_current_ma() is None
|
||||
|
||||
|
||||
def test_a_serial_number_still_comes_back_bare(laser):
|
||||
"""The one reply that legitimately names nothing."""
|
||||
laser.serial.replies = {"CSR": ["A1B2C3D4"], "HSR": ["7654321"]}
|
||||
assert laser.get_controller_serial() == "A1B2C3D4"
|
||||
assert laser.get_head_serial() == "7654321"
|
||||
|
||||
Reference in New Issue
Block a user