Skip to content

Fix/console fw safety limits - #322

Merged
georgevigelette merged 2 commits into
nextfrom
fix/console-fw-safety-limits
Oct 15, 2026
Merged

georgevigelette merged 2 commits into
nextfrom
fix/console-fw-safety-limits

Conversation

@georgevigelette

Copy link
Copy Markdown
Contributor

Summary

Licensing layer

  • Apache-2.0 extension (3D Slicer, wellness/veterinary module, partner SDK, language binding)
  • AGPL-3.0 core (firmware, sensing/beamforming/reconstruction/signal-processing/calibration algorithms, hardware reference design)
  • Docs / data / tooling only
  • This PR moves a file between the AGPL core and the Apache layer — if checked, this is NOT an ordinary PR: it requires the license-manifest change process (and board approval for anything leaving the core). Link the approval.

Checklist

  • Commits are signed off (DCO): git commit -s
  • New files carry the correct SPDX-License-Identifier for their layer
  • Tests and docs updated
  • No incompatible third-party code introduced
  • CI is green and CODEOWNERS review requested

Notes for reviewers

Host side of the console firmware safety fixes (console-fw branches
fix/cmd-length-bounds, fix/tec-interlock-start and
fix/trigger-validation-replies: NEW-1, NEW-2, NEW-3, CFW-05, CFW-06).

- MotionUart.send_packet refuses a payload over CONSOLE_MAX_PAYLOAD
  (2036 bytes, firmware OW_MAX_PAYLOAD) with CommandError instead of
  sending a frame the console NAKs.
- set_trigger_json checks the configuration with the new
  config.validate_trigger_config (1..40 Hz, trigger pulse < period,
  laser gate 20..2200 us, delay + gate + skip delay < period) and
  raises ValueError naming the field. It sends compact JSON and
  refuses JSON over TRIGGER_JSON_MAX (511 bytes). A config the console
  rejects is logged and returns None, as before.
- start_trigger decodes the status byte of a refused START_TRIG
  (TRIG_INTERLOCK_HOST_LOSS / _LASER_SAFETY / _TEC,
  TRIG_START_TIMER_FAILED) into last_start_refusal and
  last_start_refusal_reason.
- ScanWorkflow no longer ignores the SET_TRIG and START_TRIG results:
  a rejected config or a refused start ends the scan at once through
  the normal teardown (stop_trigger, disable_camera, source close) and
  reports the console's reason through last_scan_error / on_error.
- tec_status and ConsoleTelemetry docs: tec_good returns True on the
  first clean poll, but the TEC trigger interlock clears only after 200
  clean polls (about 5 s), so a start can be refused while tec_good is
  True.

Tests: tests/test_trigger_limits.py (no hardware) and a ScanWorkflow
test for the three trigger failure paths. Bench, console running the
three firmware fixes combined (Release-BareMetal): payload limit, config
refusals, firmware-rejection path, SDK verdict equal to the firmware
verdict for 500 random configs, and the TEC refusal decoded as 0x04
with the start accepted 5.1 s after recovery; 18/18. The SDK console
hardware tests pass (35).

Older console firmware replies OW_RESP to a refused start, so
start_trigger still returns True there. The 40 Hz ceiling matches the
firmware fix; the unmerged 60 Hz mode (feature/129-60hz-rate-ll) needs
TRIGGER_FREQ_MAX_HZ raised here and in the firmware.

Signed-off-by: George Vigelette <george@openwater.cc>
The console firmware trigger frequency range now depends on its build type
(console-fw fix/trigger-freq-by-build): Release, including every clinical
image, accepts 40 Hz only; Debug and *-dev.* builds accept 1..100 Hz. The
SDK cannot tell which build it talks to, so TRIGGER_FREQ_MIN_HZ / _MAX_HZ
are the union, 1..100 Hz:
- set_trigger_json raises ValueError before sending for anything outside
  1..100 Hz (no console build accepts it);
- a Release console answers any rate other than 40 Hz with OW_ERROR, and
  set_trigger_json logs the rejection and returns None, as for any
  configuration the console rejects.
The docstrings and the unit tests use the new range, with frame-fit
boundaries at 1, 30, 60 and 100 Hz.

Bench, console on fix/trigger-freq-by-build Release-BareMetal, TA trigger
and sync out off, no START: 40 Hz -> config dict; 60, 1 and 100 Hz -> None
with the console config unchanged; 101 and 0.5 Hz -> ValueError, nothing
sent. Software suite: no new failures.

Signed-off-by: George Vigelette <george@openwater.cc>
@georgevigelette
georgevigelette merged commit bd512f8 into next Oct 15, 2026
2 checks passed
@georgevigelette
georgevigelette deleted the fix/console-fw-safety-limits branch October 15, 2026 03:01
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