Repository navigation
feat: support DSLogic hardware trigger in capture - #13
TreeNewbeer wants to merge 4 commits into
Conversation
seasonyuu
left a comment
There was a problem hiding this comment.
Review findings
-
[P1] Stream captures can succeed even when the trigger never fires
In
crates/dsview-core/src/lib.rs:2795-2805,StoppedByDurationandStoppedByInterruptare returned as successful captures without checking the trigger observation. The CLI remapping incrates/dsview-cli/src/main.rs:2319-2324only handlesTimeoutandIncompleteerrors. As a result,--duration-ms/--until-interruptcan stop before a requested trigger is hit, export a partial VCD, and exit successfully instead of returning the documentedcapture_trigger_not_firederror. Please checktrigger.observation.fired()before treating these stopped completions as success, and discard the temporary streaming artifact on the error path. -
[P2] Trigger packet payload is read without validating its size or type
crates/dsview-sys/bridge_runtime.c:3897-3919casts everySR_DF_TRIGGERpayload tostruct ds_trigger_pos *and immediately reads all fields. A truncated or malformed packet from the runtime can therefore cause an out-of-bounds read and crash the process. Please validate the payload pointer, length, and packet format before dereferencing it.
Validation
I attempted cargo test --workspace, but the build stopped in crates/dsview-sys/build.rs:484 because this Windows environment does not have pkg-config / glib-2.0 available.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
63d7b17 to
fa2ea44
Compare
Summary
This PR lets
capturearm the DSLogic Plus hardware trigger. It supports DSView's simple, stage, and serial trigger modes, and reports where the trigger fired. It implements the deferredTRIG-01requirement from the v1.1 milestone. TheDSView/submodule is unchanged.captureflags, shown under a Trigger help heading:--trigger CH=COND[,CH=COND...]: a simple trigger. Conditions arelow,high,rising,falling, andedge; DSView letters0,1,R,F,Calso work.--trigger-config PATH: a version-1 JSON config insimple,stage, orserialmode.--trigger-position PERCENT: the pre-trigger share. It can be 1-90 in buffer mode (default 1); stream mode allows only a simple trigger and fixes the position at 1, as the DSView GUI does.start,stop,clock) needs an edge conditionds_trigger_*setters and replays a fixed-size program that mirrorsTriggerDock::commit_triggerandLogicSignal::commit_trig.asserts, and resets the native state if a setter fails part-way.SR_DF_TRIGGERpackets are recorded, so the CLI knows whether and where the trigger fired.triggerblock withrequestedandobserved(fired,sample_index, raw status). Without a trigger the output is unchanged, and the metadataschema_versionstays 2.capture_trigger_not_fired, for a timeout or a stopped stream capture that never saw a trigger hittrigger_config_invalidandtrigger_config_unreadabletrigger_channel_not_enabledandtrigger_channel_unsupportedtrigger_mode_unsupportedandtrigger_position_out_of_rangedevices optionslists the trigger capabilities in both JSON and text output.*.vcd.streaming.tmpfile. Before this change the file was left behind, and stream captures whose trigger never fires now hit this path routinely.dsview_runtime.defexports the trigger setters andtrigger DATA, which the state read-back uses.Behaviour worth knowing
observed.sample_indexis the exact trigger sample in the exported VCD.sample_indexis below the requested share. This is common with periodic signals. The README documents it.data_bitsbits clocked after the start flag; there is no sliding windowdata_valueTest plan
cargo test --workspace: 315 passed, 0 failed. New tests:dsview-sys/tests/trigger.rs: applies programs to the source-built runtime and reads the nativestruct ds_triggerbackdsview-cli/tests/trigger_cli.rs: flags, output shape, and error codes, using the debug fixture--duration-ms, and--until-interrupt).defchange.Known limitations
enabled_channelsapply step withSR_ERR_ARG, with or without a trigger. v1.2.4 has the same failure:set_enabled_channelswalks all 16 channels, but these modes expose only 8 or 4. This PR does not fix it, so the halved and quartered trigger-mask paths are covered by validation only and were not tested on hardware.invert,contiguous, andorwere checked on the internal-test counter only.🤖 Generated with [Claude Code](https://claude.com/claude-code