Repository navigation
Conversation
nullifyr
added a commit
to LANScapes/logic-analyze
that referenced
this pull request
Oct 1, 2026
The same code as DreamSourceLab/DSView#920 and #918: - dslcap: strict argument validation, every configuration call checked (threshold voltage only where the device has one), failed captures exit 3 and publish nothing, mutex-guarded callback state, monotonic deadline, 64-bit file offsets, checked stdout, install rule, built on non-Windows only, with its own link list. - macOS: a window that starts maximized is shown at its saved normal region and then zoomed, so un-maximizing returns it there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S6AB69CNtvrecQVn1nyvL1
dslcap drives a DSLogic through libsigrok4DSL without the GUI, for
scripted and automated captures:
dslcap --list
dslcap --channels 0,1 --samplerate 10000000 --samples 1000000 \
[--vth 1.6] [--mode buffer|stream] [--trigger CH[:R|F|C|1|0]] \
[--trigpos PERCENT] [--timeout SEC] [--res DIR] --out /path/base
It writes <base>.bin (each enabled channel's samples packed LSB-first)
and prints one JSON object describing the capture on stdout. Every
failure prints a JSON object with an "error" key and exits non-zero
(1 runtime/I/O error, 2 invalid argument or unavailable setting,
3 failed capture).
- Validates all options before the library is initialised: whole-string
numeric parses with range checks, finite --vth (0-5 V) and --timeout,
positive rate and sample count, channel lists of plain indexes without
duplicates, --mode exactly buffer or stream, --trigpos 0-100 (and
small enough that its share of the sample limit fits the driver's
32-bit trigger position), and a trigger type of exactly one of
R F C 1 0.
- Accepts only the samplerates the device reports, and picks a channel
mode that supports the requested rate and channel count; triggers must
be on an enabled channel.
- Checks every configuration call (operation mode, threshold voltage,
samplerate, sample limit, trigger) and reads back the samplerate,
sample limit and threshold, reporting the values the device holds.
The threshold voltage is set only on devices that list SR_CONF_VTH;
on older models with only the 3.3 V / 5 V threshold setting, "vth" is
reported as null and an explicit --vth is rejected.
- A failure to list devices is reported as an error, not as an empty
device list.
- Library callbacks update shared state under a mutex. The capture
waits, against a monotonic deadline, for the collect task's final
end event rather than SR_DF_END or the device-stopped event.
- A capture that timed out, ended by error or detach, reported a packet
or logic data error, overflowed, or returned fewer samples than
requested is reported as failed and no <base>.bin is created.
- Spools the logic data to disk while capturing, so long or streaming
captures do not have to fit in memory, then de-interleaves it in
bounded chunks; the target is built with 64-bit file offsets and
output offsets are range-checked.
- Checks every write, including the JSON on stdout, and publishes the
output file atomically without replacing an existing one; the output
name is allocated to full length.
- Finds the firmware next to the executable (build tree, app bundle or
installed ../share/DSView/res), in the configured install prefix, or
in --res / $DSLCAP_RES.
- Built and installed (to the configured bindir) on non-Windows
platforms, with its own link list including libm; Windows builds are
unchanged.
tools/dslcap/test_spool.c is a standalone check, needing no hardware,
of argument validation, packet/event status handling, the de-interleave
path and large-file offsets; its header gives macOS and Linux build
commands.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01S6AB69CNtvrecQVn1nyvL1
nullifyr
added a commit
to LANScapes/logic-analyze
that referenced
this pull request
Oct 1, 2026
Same change as DreamSourceLab/DSView#920: reject a --trigpos whose share of the sample limit would overflow the driver's 32-bit trigger position. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S6AB69CNtvrecQVn1nyvL1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dslcapis a small command-line tool that runs a DSLogic capture through libsigrok4DSL without the GUI, for scripts, test benches and automation:It writes
<base>.bin(each enabled channel's samples packed LSB-first) and prints one JSON object describing the capture. Every failure prints a JSON object with an"error"key and exits non-zero (1 runtime/I/O, 2 invalid argument or unavailable setting, 3 failed capture).Design points:
SR_CONF_VTH.tools/dslcap/test_spool.cchecks argument validation, packet/event status handling, the de-interleave path and large-file offsets without hardware; its header has macOS and Linux build commands.Tested on a DSLogic Plus (macOS, Apple silicon):
--list; buffer capture of 2 channels at 1 MHz and stream capture of 4 channels at 10 MHz (files of exactly the expected size); explicit--vth 1.2applied and read back; a rising-edge trigger that never fired timed out with exit 3 and no file.Also: builds on macOS (Apple Clang, Qt 6) and Ubuntu 24.04 on aarch64 and x86_64 (GCC 13, Qt 5); the standalone test passes on both; a mocked-library harness covering normal, failed, timed-out, legacy-threshold and malformed-argument captures passes, including under ThreadSanitizer. I have not run it on Windows (excluded) or on a 32-bit platform.
🤖 Generated with Claude Code
https://claude.ai/code/session_01S6AB69CNtvrecQVn1nyvL1