]> sigrok.org Git - libsigrok.git/log
libsigrok.git
17 months agokorad-kaxxxxp: add model entry for Tenma 72-2705
Gerhard Sittig [Fri, 25 Nov 2022 08:28:46 +0000 (09:28 +0100)]
korad-kaxxxxp: add model entry for Tenma 72-2705

Add the "Tenma 72-2705" model to the list of supported devices
(single channel, 30V, 3A).

Reported-By: Dries <redacted>
17 months agoconfigure: Accept glibmm-2.68 as an alternative to glibmm-2.4
Gerhard Sittig [Tue, 22 Nov 2022 10:11:50 +0000 (11:11 +0100)]
configure: Accept glibmm-2.68 as an alternative to glibmm-2.4

Check for both glibmm-2.4 as well as glibmm-2.68. Prefer the former
when either is available, to remain backwards compatible.

This unbreaks builds on OS X with homebrew where only glibmm-2.68
is available.

Implementor's note: It's yet to get determined whether glibmm-2.68
is to get preferred, being the first stable release of that external
dependency. https://gitlab.gnome.org/GNOME/glibmm/-/blob/2.68.2/NEWS
The commit is phrased to simplify future adjustment of this preference.

This commit is based on work that was
Submitted-By: Fabrice Fontaine <redacted>
17 months agobindings/cxx: Increase compatibility for glibmm-2.68
Fabrice Fontaine [Mon, 3 Jan 2022 07:32:27 +0000 (08:32 +0100)]
bindings/cxx: Increase compatibility for glibmm-2.68

Prefer the DateTime data type which has been available since glibmm-2.4
version 2.26, and also is available in glibmm-2.68. While glibmm-2.68
no longer provides the TimeVal data type.

[ gsi: split Fabrice's commit, rephrase commit message ]

17 months agoconfigure.ac: check for highest available C++17/C++14/C++11 standard
Gerhard Sittig [Mon, 21 Nov 2022 17:50:18 +0000 (18:50 +0100)]
configure.ac: check for highest available C++17/C++14/C++11 standard

There are external libraries (boost, glibmm) as well as platforms (Mac
OSX 12) which "require" C++ language standards above 11. Detect the
highest available standard which is supported by the compiler.

Use a "have modern C++" variable to improve robustness and readability
of the C++ language standard check.

17 months agom4: update ax_cxx_compile_stdcxx.m4 to also cover C++17
Gerhard Sittig [Mon, 21 Nov 2022 18:27:19 +0000 (19:27 +0100)]
m4: update ax_cxx_compile_stdcxx.m4 to also cover C++17

This file corresponds to the git://git.sv.gnu.org/autoconf-archive
repository's file m4/ax_cxx_compile_stdcxx.m4 as of 2022-07-25 (see
commit 2bfeecc1d509).

17 months agodmm/bm86x: fix broken URLs
François Revol [Tue, 27 Sep 2022 23:27:53 +0000 (01:27 +0200)]
dmm/bm86x: fix broken URLs

17 months agodmm/bm85x: fix broken URLs
François Revol [Tue, 27 Sep 2022 23:26:14 +0000 (01:26 +0200)]
dmm/bm85x: fix broken URLs

17 months agodmm/bm52x: fix broken URLs
François Revol [Tue, 27 Sep 2022 22:58:06 +0000 (00:58 +0200)]
dmm/bm52x: fix broken URLs

18 months agokingst-la2016: adjust sample memory interpretation for LA5032
Gerhard Sittig [Sun, 16 Oct 2022 10:50:55 +0000 (12:50 +0200)]
kingst-la2016: adjust sample memory interpretation for LA5032

The 32-channel model in the Kingst LA series uses a different sample
memory layout than 16-channel models. The previously encoded assumption
of 3x (u32 + u8) to hold 32 channels within the same 15 bytes as other
models was incorrect. User feedback in bug #1805 suggests that the
transfer size and the sequence number size differs as well. Thus the
packet count per transfer differs, too. LA5032 holds 6 packets within
a transfer that spans 32 bytes.

Reported-By: Roman Shishkin <redacted>
18 months agokingst-la2016: update developer comments, motivated by LA5032 support
Gerhard Sittig [Sun, 16 Oct 2022 10:43:50 +0000 (12:43 +0200)]
kingst-la2016: update developer comments, motivated by LA5032 support

User feedback in bug #1805 provides information on the sample memory
layout for the 32-channel model in the Kingst LA series. Adjust comments
for improved readability/maintainability, and for awareness of variants
across different models.

Rework the send_chunk() comment. This routine deals with captures to the
device's internal RAM. Memory layout differs quite a lot between models
with 16 and with 32 channels.

Rephrase the stream_data() comment. This routine deals with continuous
streams of uncompressed data which bypasses the device's local memory.

Reported-By: Roman Shishkin <redacted>
18 months agokingst-la2016: unbreak streaming mode for LA5032
Gerhard Sittig [Sun, 16 Oct 2022 10:35:08 +0000 (12:35 +0200)]
kingst-la2016: unbreak streaming mode for LA5032

The Kingst LA series models share the same streaming mode memory layout.
All channels' chunks are 16 bits wide. The previous version worked for
16-channel devices, this change unbreaks the 32-channel device LA5032.

This fixes the streaming aspect of bug #1805.

Reported-By: Roman Shishkin <redacted>
19 months agokorad-kaxxxxp: factor out ID response lookup in the models table
Gerhard Sittig [Fri, 16 Sep 2022 08:14:01 +0000 (10:14 +0200)]
korad-kaxxxxp: factor out ID response lookup in the models table

Introduce a model_lookup() routine so that the table iteration need not
get duplicated across several call sites.

19 months agokorad-kaxxxxp: use ID text prefix with optional version for RND models
Gerhard Sittig [Fri, 16 Sep 2022 08:07:14 +0000 (10:07 +0200)]
korad-kaxxxxp: use ID text prefix with optional version for RND models

This allows to match the "320-KA3005P" response text, and present the
"KA3005P" model name to users without the "320-" prefix.

19 months agokorad-kaxxxxp: support optional version after fixed ID response text
Gerhard Sittig [Fri, 16 Sep 2022 08:03:30 +0000 (10:03 +0200)]
korad-kaxxxxp: support optional version after fixed ID response text

The combination of a literal expected ID response, and an optionally
trailing version information that need not be part of the driver's
strict expectation, would be useful to handle the RND devices' prefix.

Extend the "strict ID response text check", accept an optional version
text before checking for exhausted input. This commit only introduces
the support code, does not change the set of supported models.

19 months agokorad-kaxxxxp: trim down list of supported models (renames RND models)
Gerhard Sittig [Thu, 15 Sep 2022 20:44:53 +0000 (22:44 +0200)]
korad-kaxxxxp: trim down list of supported models (renames RND models)

Remove expected ID response literals from the list of supported models
when the generic "vendor and name" approach matches. Remove duplicate
entries (those which only differed in firmware version numbers or in
trailing garbage) which were obsoleted by the generic match approach.

This user perceivably "renames" previously and still currently supported
RND devices. Presents the RND vendor's "320-" prefix before the "KA3005"
stem. Should be acceptable given that this is the vendor's article name.
Exclusively affects display texts, the user provided driver name which
addresses the PSU remains as it was before.

The table of supported models now contains no entry with a fixed wanted
response text. But the match logic keeps support for this condition, so
that future entries can use it when required. RND entries could use it
when the "320-" prefix is undesirable, but version numbers are not
stripped transparently by the match logic's implementation.

19 months agokorad-kaxxxxp: implement more generic ID response text checks
Gerhard Sittig [Thu, 15 Sep 2022 20:42:55 +0000 (22:42 +0200)]
korad-kaxxxxp: implement more generic ID response text checks

Either compare the device's response text for IDN queries against a
specific string literal (strict match, compatible with earlier driver
implementations). Or apply a more generic approach which expects to
find the vendor and model names, accepts optional version details,
and transparently deals with several quirks in the process.

Adjust user visible as well as developer centric diagnostics. The
fixed ID response literal became optional. Tell exact literal matches
from the matches of the generic vendor/device approach.

This commit only adds the support code, but does not modify the table
of supported models. Which results in the check logic to always use the
path which strictly matches the device's response against a literal.
The generic approach will only be taken when the supported models table
gets adjusted in future commits.

19 months agokorad-kaxxxxp: prepare more versatile ID response text checks
Gerhard Sittig [Thu, 15 Sep 2022 20:34:02 +0000 (22:34 +0200)]
korad-kaxxxxp: prepare more versatile ID response text checks

Add more quirks for IDN responses: Some devices would not report the
vendor in their response. Some devices suffer from trailing garbage.
Move IDN response text checks to a new model_matches() routine, stick
with the strcmp() implementation in this commit for compatibility.

This commit does not change the set of supported models, but prepares
the addition of more versatile IDN response checks in a future version.

19 months agokorad-kaxxxxp: unclutter table layout of supported models
Gerhard Sittig [Thu, 15 Sep 2022 20:28:32 +0000 (22:28 +0200)]
korad-kaxxxxp: unclutter table layout of supported models

Reduce the number of lines per item in the table of supported models
where appropriate. Only occupy two text lines for the rather lengthy
Velleman items. This shall simlify navigation in the models table.

19 months agokorad-kaxxxxp: eliminate numeric model ID in supported models table
Gerhard Sittig [Thu, 15 Sep 2022 20:24:11 +0000 (22:24 +0200)]
korad-kaxxxxp: eliminate numeric model ID in supported models table

Drop the first column in the table of supported models. Voltage/current
capabilities as well as quirks are immediately detected at scan time, no
other code paths outside of scan need to access that "model enum/index".

[ see a word-diff for the essence, a table column gets removed ]

19 months agokorad-kaxxxxp: eliminate numeric model ID (table index) in scan
Gerhard Sittig [Thu, 15 Sep 2022 20:18:42 +0000 (22:18 +0200)]
korad-kaxxxxp: eliminate numeric model ID (table index) in scan

Rephrase the successful lookup of a supported model by means of a
pointer to a models[] entry. Which eliminates the numeric index,
including the "sentinel" value which points outside of the table.

Use a signed integer for iteration over table items. Don't break
text lines between vendor and model fields, these fields form a
logical group from the user's perspective.

19 months agokorad-kaxxxxp: eliminate model check in OVP enabled quirk handling
Gerhard Sittig [Thu, 15 Sep 2022 20:12:28 +0000 (22:12 +0200)]
korad-kaxxxxp: eliminate model check in OVP enabled quirk handling

Rephrase the check for the Velleman LABPS3005D quirk. Eliminate the
check for individual supported models in the main loop. The condition
gets detected at scan time already. Handling other affected models
becomes transparent.

19 months agokorad-kaxxxxp: add quirks flags to table of supported models
Gerhard Sittig [Thu, 15 Sep 2022 20:07:25 +0000 (22:07 +0200)]
korad-kaxxxxp: add quirks flags to table of supported models

Out of the current set of supported models, the Velleman LABPS3005D is
the only device which requires special OVP enable handling. In future
implementations, more quirks could get identified or other models could
be affected. Add a quirks flags field to the models[] table, so that
other driver code paths need not care about individual models.

This commit only provides the flag. Calling code is not adjusted in this
commit, to reduce the diff size and simplify review. There are a lot of
"no quirks" additions in this commit already.

19 months agokorad-kaxxxxp: factor voltage/current capability out of models[] table
Gerhard Sittig [Thu, 15 Sep 2022 20:02:20 +0000 (22:02 +0200)]
korad-kaxxxxp: factor voltage/current capability out of models[] table

Move the number literals for supported voltage and current ranges and
their granularity out of the models[] table. Reference the ranges from
the models[] table by symbolic names, such that entries will read as
"a model which supports up to 30V and 5A", which is considered easier
to maintain. It's assumed that only few of these "templates" will be
required, the current set of supported devices gets away with 30V/60V,
and 3A/5A, and is able to express all of their combinations. See the
Korad KD6005, Tenma 72-2535, and Tenma 72-2550 models, which are the
only exceptions from the typical 30V/5A configuration.

19 months agokorad-kaxxxxp: reflow models[] table for capabilities comparison
Gerhard Sittig [Thu, 15 Sep 2022 19:54:12 +0000 (21:54 +0200)]
korad-kaxxxxp: reflow models[] table for capabilities comparison

The entries in the models[] table are wide, and occupy several text
lines each. Re-flow these lines such that channel count, voltage and
current capabilities will vertically align, to simplify the review of
which degrees of freedom the driver needs to actually support. As a
byproduct these phrases keep the IDN response text and the displayed
vendor and model names together on a text line. Which is useful for
grepping the source for user feedback.

It's assumed that listing every firmware version as a separate model
is both tedious, and rather fragile at the same time. It is to be seen
which of these models genuinely differ from all others, and whether
their IDN response is unique enough even if an incomplete match is
done on the response text.

[ see a word-diff, it's all whitespace, no behaviour has changed ]

19 months agokorad-kaxxxxp: alpha-sort list of supported models
Gerhard Sittig [Thu, 15 Sep 2022 19:52:08 +0000 (21:52 +0200)]
korad-kaxxxxp: alpha-sort list of supported models

Sort the models[] table by vendor name and model name. Use the enum
identifier as a sort key (haven't checked the ID response text).

19 months agokorad-kaxxxxp: add Korad KD3005P V6.8 to list of known models
Gerhard Sittig [Thu, 15 Sep 2022 19:49:04 +0000 (21:49 +0200)]
korad-kaxxxxp: add Korad KD3005P V6.8 to list of known models

User Imre Liessens reported this model in bug #1800.

19 months agokingst-la2016: add another supported LA5016 model (bytes 0x0c 0x10)
Gerhard Sittig [Wed, 14 Sep 2022 17:52:48 +0000 (19:52 +0200)]
kingst-la2016: add another supported LA5016 model (bytes 0x0c 0x10)

User Daniel reports in bug #1799 that an LA5016 as of 2022-08 uses
magic byte values which were not listed in earlier implementations.
Add the very 12 (16) combination (in hex: 0x0c 0x10) which the user
reported. As well as 12 (0) for good measure -- most other models
have this "wildcard" entry, too.

19 months agokingst-la2016: rephrase magic bytes in table of known models
Gerhard Sittig [Wed, 14 Sep 2022 17:50:01 +0000 (19:50 +0200)]
kingst-la2016: rephrase magic bytes in table of known models

Prefer the hex presentation for magic bytes retrieved from EEPROM to
identify Kingst LA models. Adjust the models[] array and diagnostics.
As a byproduct this keeps the table layout stable in future versions.

[ See a word-diff for the essence of the change. ]

19 months agokorad-kaxxxxp: All received values are zero
Georg Hofmann [Tue, 13 Sep 2022 08:12:04 +0000 (10:12 +0200)]
korad-kaxxxxp: All received values are zero

Commit 5dfa77b5 introduced a regression in korad_kaxxxxp_get_value().
Positive non-zero return values from command transmission made the
routine fail for every invocation. Fixup the error check and advance
to response reception, do provide the values retrieved from the PSU.

[ gsi: rephrase check, reword commit message ]

19 months agoasix-sigma: check sdi before dereferencing a NULL pointer
Gerhard Sittig [Wed, 31 Aug 2022 15:37:05 +0000 (09:37 -0600)]
asix-sigma: check sdi before dereferencing a NULL pointer

The asix-sigma config_list() routine unconditionally dereferenced the
'sdi' pointer, which could be NULL. Properly check before dereferencing.
This issue was introduced in commit eabf9ca630f4. How to reproduce:

  $ sigrok-cli -d asix-sigma --show

Reported-By: Paul Kasemir <redacted>
20 months agoinput/vcd: do propagate parse error in file header
Gerhard Sittig [Sun, 21 Aug 2022 07:57:24 +0000 (09:57 +0200)]
input/vcd: do propagate parse error in file header

The vcd input module's parse_header() routine used the 'status' variable
in inappropriate ways. It was preset to false, then raised when the end
of the header was seen, and lowered when parse errors occurred. This made
parse errors go unnoticed because the flag always was raised at the end
of the header. The issue was introduced in commit 0ab36d2f5448.

Separate the "header seen" from "header valid" aspects. The "header seen"
is needed for loop control including resource management. The "valid" is
needed to propagate errors should they have happened at any time during
parsing.

Also adjust the process_buffer() and end() routines to cease processing
the input file's content after header parsing failed earlier. Which
addresses bug #1758 for VCD.

20 months agoscpi-dmm: prefer double over float data types more often
Gerhard Sittig [Thu, 3 Oct 2019 16:50:21 +0000 (18:50 +0200)]
scpi-dmm: prefer double over float data types more often

The 'float' data type uses 23 bits for the mantissa, which can express
some 6.9 decimal places. Some meters claim "6 digits" when in fact they
are 6.5 or so. Averaging over higher numbers of power line cycles (NPLC)
could additionally raise a meter's precision. Prefer double over float
for 6-digit devices already, just to err on the safe side.

The previous implementation only started using the double data type for
devices with 7 and more digits, and left a theoretical gap that's fully
closed now.

20 months agools: add support for "probe names" scan option
Gerhard Sittig [Sun, 14 Aug 2022 19:17:29 +0000 (21:17 +0200)]
ols: add support for "probe names" scan option

Add support for the SR_CONF_PROBE_NAMES scan option. Optionally assign
user specified channel names instead of the driver's builtin names.

20 months agools: move sigrok channel creation from protocol.c to api.c
Gerhard Sittig [Sun, 14 Aug 2022 19:07:07 +0000 (21:07 +0200)]
ols: move sigrok channel creation from protocol.c to api.c

It's unexpected that several code paths redundantly create sigrok
channels, and that most of them reside in the protocol.c source file.
Concentrate channel creation in api.c instead in the scan() routine,
to remain aware during maintenance.

Fallback to the maximum channel count for SUMP compatibles, prefer
metadata gathered from the device when available, including quirks for
models which are known to deviate. Just setup the number during probe,
and create the channels at the end of scan() in common code.

Change the channel count struct member to unsigned while we are here.
Shorten a long comment line to not have to break it.

20 months agools: move device context creation from protocol.c to api.c
Gerhard Sittig [Sun, 14 Aug 2022 18:47:43 +0000 (20:47 +0200)]
ols: move device context creation from protocol.c to api.c

The get_metadata() routine was unfortunately named, and surprisingly did
more than its name suggested. Rename the routine to contain the ols_
prefix. Run communication to the device in protocol.c, but keep sdi and
devc creation in api.c where they are expected during maintenance. This
"unhides" where stuff is happening, and eliminates redundancy between
the models which support meta data to announce their features, and other
"compatibles" which are covered by generic fallback data.

20 months agokingst-la2016: add support for "probe names" scan option
Gerhard Sittig [Sun, 14 Aug 2022 18:33:18 +0000 (20:33 +0200)]
kingst-la2016: add support for "probe names" scan option

Add support for the SR_CONF_PROBE_NAMES scan option. Optionally assign
user specified channel names instead of the driver's builtin names.

20 months agofx2lafw: add support for "probe names" scan option
Gerhard Sittig [Sun, 14 Aug 2022 18:27:25 +0000 (20:27 +0200)]
fx2lafw: add support for "probe names" scan option

Add support for the SR_CONF_PROBE_NAMES scan option. Optionally assign
user specified channel names instead of the driver's builtin names.

It's essential to create sdi and devc before scanning the probe names
spec. The previous logic which printed channel names to a local buffer
got replaced by a const table of channel names. This commit is a little
longer because checks are added, to make sure that future models with
more channels won't exceed the static const tables.

This implementation exclusively allows to specify logic channel names.
Analog channels keep the open coded naming pattern. Because the driver
supports different models with differing numbers of channels of several
types, covering analog channels in the "probe names" feature requires
more runtime effort to create the table of default channel names for the
specific device that was found. This remains as an option for a later
commit.

20 months agoasix-sigma: add support for "probe names" scan option
Gerhard Sittig [Sun, 14 Aug 2022 18:22:42 +0000 (20:22 +0200)]
asix-sigma: add support for "probe names" scan option

Add support for the SR_CONF_PROBE_NAMES scan option. Optionally assign
user specified channel names instead of the driver's builtin names.

This commit is a little more involved because channel names are also
referenced as external clock source. The lack of 'const' decoration in
the glib API and the presence of 'const' in the std_*() routines require
some intermediate storage and casts and duplicate length determination.
This is considered more desirable than a redundant length field in devc.

20 months agoasix-omega-rtm-cli: add support for "probe names" scan option
Gerhard Sittig [Sun, 14 Aug 2022 18:19:01 +0000 (20:19 +0200)]
asix-omega-rtm-cli: add support for "probe names" scan option

Add support for the SR_CONF_PROBE_NAMES scan option. Optionally assign
user specified channel names instead of the driver's builtin names.

20 months agostrutil: add common parse logic for SR_CONF_PROBE_NAMES input specs
Gerhard Sittig [Sun, 14 Aug 2022 18:06:58 +0000 (20:06 +0200)]
strutil: add common parse logic for SR_CONF_PROBE_NAMES input specs

Add the public sr_parse_probe_names() and sr_free_probe_names() routines
so that device drivers can share a maximum amount of support code. The
input spec can either carry a list of names for individual signals, or
aliases can expand to a set of multiple signals which e.g. correspond
to a protocol or other popular/typical sets of signals. Which increases
usability. Order of items is arbitrary, recursion is not supported (yet
this internal implementation detail may change in a future version).

In the absence of an SR_CONF_PROBE_NAMES value the driver's list of
channel names is returned. Which yields completely backwards compatible
behaviour -- drivers can unconditionally call the parse routine. In the
presence of a configuration value the user spec is taken, aliases get
expanded (alias lookup is case insensitive).

Calling drivers can either have the list capped to a maximum size (pin
count is a natural limit), or get the result of whatever the user has
specified (dynamic size, grows as specs require). The user's probe names
by default get padded with the device's builtin probe names, unless the
spec starts with a '-' (dash), then exclusively the specified signal
names are used.

Calling code which resides in individual device drivers remains minimal.
Behaviour of individual drivers should be identical or very similar from
the user's perspective. The implementation is not tuned for performance,
the logic only executes once during device scan and is not sensitive.

This implementation supports the following aliases for maximum user's
convenience, covering the libsigrokdecode supported protocols with many
signals or with complicated names: ac97 i2c ieee488 jtag jtag-opt lpc
lpc-opt mcs48 microwire sdcard_sd seven_segment spi swd uart usb z80.
The "-opt" variants carry more optional signals which users may want to
inspect sometimes, while often the low logic channel count of typical
devices severely constraints how many signals can get assigned. Let
users pick what they prefer. A mix of a non-opt alias plus a few hand
listed extras is another option.

Adding more aliases is straight forward, and transparently benefts all
participating device drivers.

Outside of isolated inspection of a single protocol (special purpose
traffic recorders), combinations are useful as well to quickly assign
many signals in complex MCU setups which then require fewer adjustment
than full manual configuration:

  $ sigrok-cli -d ...:probe_names=jtag,rtck
  $ sigrok-cli -d ...:probe_names=spi,i2c,uart,r,g,b,clock,data,usb
  $ sigrok-cli -d ...:probe_names=ieee488,uart,led
  $ pulseview -d ...:probe_names=ieee488,uart,led

20 months agohwdriver: introduce SR_CONF_PROBE_NAMES config key (scan option)
Gerhard Sittig [Sun, 14 Aug 2022 11:33:51 +0000 (13:33 +0200)]
hwdriver: introduce SR_CONF_PROBE_NAMES config key (scan option)

Device drivers assign a fixed set of probe names during scan. Users can
rename previously created channels in the GUI as well as in the CLI,
though this is tedious, and depends on the application, as well as
depends on the names which the driver initially used to assign. Manual
assignment of protocol decoder inputs to device channel names is as
tedious.

Introduce the SR_CONF_PROBE_NAMES scan option, which assigns the user
provided names to the device's probes during scan already (for those
drivers which support the option). This commit declares the config key
but does not affect any driver yet.

20 months agoserial_hid: improve and tighten "find USB" for the HID transport
Gerhard Sittig [Tue, 18 Jun 2019 17:06:49 +0000 (19:06 +0200)]
serial_hid: improve and tighten "find USB" for the HID transport

The .find_usb() method of the HID transport previously returned
connections which lacked the "hid/" prefix and chip type, thus could
later not be used with open() and data communication calls. Add the
missing decoration.

As a minor optimization, lookup the chip type and name from the caller's
VID:PID pair already if it's specific enough, still lookup the chip for
every enumerated device if the caller's VID:PID pair is unspecific.

Tighten the result set of the HID transport's USB search. Only return
connections which involve one of the supported chips. The other devices
very probably cannot be used to connect to measurement equipment anyway,
listing mice and keyboards and other unrelated stuff was found to be not
so useful.

20 months agoserial_hid: restrict .list() result set, supported chips only
Gerhard Sittig [Tue, 18 Jun 2019 17:26:04 +0000 (19:26 +0200)]
serial_hid: restrict .list() result set, supported chips only

The --list-serial output was excessively large for the HID transport,
listing mice and keyboards and other stuff that could never by used
for serial communication. Especially when one device provided multiple
interfaces, and on Windows where paths are rather long by default.

Limit the result set of the HID transport's .list() operation. Only
consider connections that we know how to communicate to (supported
chip type). The others are not usable anyway, so there is no point in
presenting them to the user.

20 months agomicrochip-pickit2: silence compiler warnings (NULL dereference)
Gerhard Sittig [Sun, 16 Jun 2019 09:17:51 +0000 (11:17 +0200)]
microchip-pickit2: silence compiler warnings (NULL dereference)

Check pointers for validity before dereferencing them. This silences the
following compiler warnings:

../src/hardware/microchip-pickit2/api.c:275:8: warning: Access to field 'conn' results in a dereference of a null pointer (loaded from variable 'sdi')
                if (!sdi->conn)
../src/hardware/microchip-pickit2/api.c:281:10: warning: Access to field 'samplerates' results in a dereference of a null pointer (loaded from variable 'devc')
                rate = devc->samplerates[devc->curr_samplerate_idx];
../src/hardware/microchip-pickit2/api.c:287:11: warning: Access to field 'captureratios' results in a dereference of a null pointer (loaded from variable 'devc')
                ratio = devc->captureratios[devc->curr_captureratio_idx];

20 months agokorad-kaxxxxp: silence compiler warning (unused value)
Gerhard Sittig [Sun, 16 Jun 2019 09:13:15 +0000 (11:13 +0200)]
korad-kaxxxxp: silence compiler warning (unused value)

Do inspect the return value of the routine which sends the command
before retrieving the response. This silences the following warnings:

../src/hardware/korad-kaxxxxp/protocol.c:179:3: warning: Value stored to 'ret' is never read
                ret = korad_kaxxxxp_send_cmd(serial, "IOUT1?");
../src/hardware/korad-kaxxxxp/protocol.c:184:3: warning: Value stored to 'ret' is never read
                ret = korad_kaxxxxp_send_cmd(serial, "ISET1?");
../src/hardware/korad-kaxxxxp/protocol.c:189:3: warning: Value stored to 'ret' is never read
                ret = korad_kaxxxxp_send_cmd(serial, "VOUT1?");
../src/hardware/korad-kaxxxxp/protocol.c:194:3: warning: Value stored to 'ret' is never read
                ret = korad_kaxxxxp_send_cmd(serial, "VSET1?");
../src/hardware/korad-kaxxxxp/protocol.c:202:3: warning: Value stored to 'ret' is never read
                ret = korad_kaxxxxp_send_cmd(serial, "STATUS?");

20 months agodmm/eev121gw: silence compiler warning (unused value)
Gerhard Sittig [Sun, 16 Jun 2019 08:42:36 +0000 (10:42 +0200)]
dmm/eev121gw: silence compiler warning (unused value)

Silence a compiler warning about not using an assigned value in later
instructions. This is about the EEVBlog 121GW meter's date and device
number in received serial packets, which are worth keeping around for
future versions of the driver.

../src/dmm/eev121gw.c:728:2: warning: Value stored to 'raw_serial' is never read
        raw_serial = RB32(&buf[OFF_SERIAL_3]);

20 months agodmm/bm86x: improve robustness of secondary display parsing
Gerhard Sittig [Sun, 16 Jun 2019 08:37:50 +0000 (10:37 +0200)]
dmm/bm86x: improve robustness of secondary display parsing

Return with unset MQ when parsing the number value for the secondary
display of BM86x fails. So that no invalid measurement result gets sent
to the session bus.

Reported-By: a helpful compiler warning
../src/dmm/bm86x.c:290:3: warning: Value stored to 'ret' is never read
                ret = brymen_bm86x_parse_digits(&buf[9], 4, txtbuf,

20 months agoserial_hid: silence compiler warning (unused value)
Gerhard Sittig [Sun, 16 Jun 2019 08:30:50 +0000 (10:30 +0200)]
serial_hid: silence compiler warning (unused value)

Silence a compiler warning about assigning a value to a variable that's
not used in subsequent instructions. This 'have_chip' condition is worth
keeping around, in case the HID chip search code receives updates later.
Removing the assignment may complicate maintenance, or result in
incomplete diagnostics during research.

../src/serial_hid.c:1066:3: warning: Value stored to 'have_chip' is never read
                have_chip = 1;

20 months agoserial_bt: silence compiler warning (unused value)
Gerhard Sittig [Sun, 16 Jun 2019 08:14:58 +0000 (10:14 +0200)]
serial_bt: silence compiler warning (unused value)

Drop assignments of values to variables which never took effect. Drop
assignments which strictly speaking were not required, but were added in
the past to silence warnings in different compiler versions.

../src/serial_bt.c:168:2: warning: Value stored to 'type' is never read
        type = SER_BT_CONN_UNKNOWN;

../src/serial_bt.c:507:2: warning: Value stored to 'now_us' is never read
        now_us = 0;     /* Silence a (false) compiler warning. */

Shuffle variable declarations into the rough order in which they are
used in the function's body.

20 months agouni-t-dmm: sort supported devices, sort in the ut71x group
Gerhard Sittig [Sat, 15 Jun 2019 21:58:56 +0000 (23:58 +0200)]
uni-t-dmm: sort supported devices, sort in the ut71x group

20 months agouni-t-dmm: sort supported devices, sort in the fs9721 group
Gerhard Sittig [Sat, 15 Jun 2019 21:57:26 +0000 (23:57 +0200)]
uni-t-dmm: sort supported devices, sort in the fs9721 group

20 months agouni-t-dmm: sort supported devices, sort in the es519xx group
Gerhard Sittig [Sat, 15 Jun 2019 21:55:39 +0000 (23:55 +0200)]
uni-t-dmm: sort supported devices, sort in the es519xx group

Sort the items in the uni-t-dmm driver's es519xx group.

20 months agouni-t-dmm: sort supported devices, collect the vc870 group
Gerhard Sittig [Sat, 15 Jun 2019 21:54:38 +0000 (23:54 +0200)]
uni-t-dmm: sort supported devices, collect the vc870 group

20 months agouni-t-dmm: sort supported devices, collect the fs9922 group
Gerhard Sittig [Sat, 15 Jun 2019 21:53:38 +0000 (23:53 +0200)]
uni-t-dmm: sort supported devices, collect the fs9922 group

20 months agouni-t-dmm: sort supported devices, collect the es519xx group
Gerhard Sittig [Sat, 15 Jun 2019 21:52:03 +0000 (23:52 +0200)]
uni-t-dmm: sort supported devices, collect the es519xx group

20 months agouni-t-dmm: sort supported devices, collect the ut71x group
Gerhard Sittig [Sat, 15 Jun 2019 21:50:07 +0000 (23:50 +0200)]
uni-t-dmm: sort supported devices, collect the ut71x group

20 months agouni-t-dmm: sort supported devices, collect the fs9721 group
Gerhard Sittig [Sat, 15 Jun 2019 21:45:12 +0000 (23:45 +0200)]
uni-t-dmm: sort supported devices, collect the fs9721 group

Sort the list of supported devices in the uni-t-dmm driver, for easier
synchronization to the serial-dmm list of devices. This commit takes
care of fs9721 items (collects them in a group, still unsorted for now).

20 months agohameg-hmo: re-add 20V/div and 50V/div vertical scales (RTB2K)
Gerhard Sittig [Sat, 12 Oct 2019 17:08:12 +0000 (19:08 +0200)]
hameg-hmo: re-add 20V/div and 50V/div vertical scales (RTB2K)

The absence of the 20V and 50V choices in the driver resulted in failed
probe/scan when the device happened to be configured to these values
(which is more probable with disabled channels). Re-introduce vdivs[]
items which unconditionally were removed in commit 4f3cb1eaf727. Use
them for RTB2K models, stick with at most 10V/div for all other models
to remain compatible with the previous implementation.

[ use 'git diff -U25' to see the models and verify the change ]

20 months agoscpi: comment on indefinite length block data (unsupported here)
Gerhard Sittig [Sat, 5 Oct 2019 11:26:29 +0000 (13:26 +0200)]
scpi: comment on indefinite length block data (unsupported here)

It's fine that the current SCPI implementation in libsigrok exclusively
supports definite length block response data. It is what most supported
devices or all of them are speaking. But the implementation of the
indefinite length case assumed that the block is empty when the response
starts with #0, and returned successful although receive data was not
taken at all.

Rephrase the test condition for successful reception. Return an error
code in the unsupported case. Emit an error message to remain aware. Let
users report when that communication pattern is seen in the field. Add
comments with references to the specs, in case the feature will receive
support later.

20 months agools: also reflect successful identify response in diagnostics
Gerhard Sittig [Fri, 13 Jan 2017 18:44:26 +0000 (19:44 +0100)]
ols: also reflect successful identify response in diagnostics

The ols driver's scan() routine used to present the identification
response to users when the scan failed, but would not when the scan
succeeded.

Since multiple response literals are supported, it's considered useful
to see these, too, in case of successful device detection. Emit debug
messages for developers' awareness.

20 months agools: make connection ID available
Gerhard Sittig [Thu, 20 Jun 2019 09:12:30 +0000 (11:12 +0200)]
ols: make connection ID available

Implement a getter for the SR_CONF_CONN config key in the ols driver.

20 months agoresource: add support for SIGROK_FIRMWARE_PATH env variable
Gerhard Sittig [Sun, 21 Aug 2022 11:36:29 +0000 (13:36 +0200)]
resource: add support for SIGROK_FIRMWARE_PATH env variable

The optional SIGROK_FIRMWARE_DIR environment variable accepts a single
directory specification. The SIGROK_FIRMWARE_PATH variable accepts a
list of directories to search firmware images. The list separator is
platform dependent (colon or semicolon). Empty items are explicitly
ignored. Both variables get evaluated. Behaviour remains backwards
compatible, just gets extended for increased usability.

20 months agousb: move connection string parsing out of USB enumeration/search
Gerhard Sittig [Tue, 18 Jun 2019 16:36:29 +0000 (18:36 +0200)]
usb: move connection string parsing out of USB enumeration/search

The sr_usb_find() routine inspects an input specification in textual
format, as well as scans for USB devices that match the caller specified
address. Factor out the text parsing including range checks for address
numbers. This part of the source code also does not depend on the libusb
library's availability.

Adjust the sr_usb_find() routine's data types for result variables. This
commit changes user visible diagnostics messages, since text parsing and
USB device lookup happen in distinct locations and don't share knowledge.

20 months agoinput/wav: undo "create channels once" workaround
Gerhard Sittig [Sun, 28 Oct 2018 09:45:42 +0000 (10:45 +0100)]
input/wav: undo "create channels once" workaround

Undo the essence of commit 9e850040db5c which added a workaround to
create sigrok channels only once, and keep reusing them across every
file import (without checking details). Which was obsoleted by the
recent channel list check on file re-load, including proper response
when essential file properties have changed.

Indentation changes. See a whitespace ignoring diff for the essence.

20 months agoinput/wav: add channel list checks for file re-read
Gerhard Sittig [Sun, 28 Oct 2018 09:45:42 +0000 (10:45 +0100)]
input/wav: add channel list checks for file re-read

Do for the WAV input module what commit 08f8421a9e82 did for VCD. Check
the channel list for consistency across re-imports of the same file.
This addresses the WAV part of bug #1241.

This commit also changes the WAV module's reset() method's behaviour.
The previous implementation only created channels once, and re-used that
channel list when the file got re-read. Which could cause issues when
the file's properties changed between re-runs. This implementation
always creates the channel list upon every file import, and ensures a
consistent channel list across re-imports. This follows the approach
that was taken in all other input modules before.

20 months agodrivers: update comment on "driver list" linker section
Gerhard Sittig [Tue, 17 Dec 2019 11:57:52 +0000 (12:57 +0100)]
drivers: update comment on "driver list" linker section

Update and slightly extend the comment on the "__sr_driver_list"
linker section which holds a list of all drivers which were built
into the libsigrok library.

20 months agoserial-dmm: fix typo in comment
Gerhard Sittig [Mon, 17 May 2021 20:14:25 +0000 (22:14 +0200)]
serial-dmm: fix typo in comment

20 months agodmm/bm86x: check more bytes in DMM packet (undocumented by vendor)
Gerhard Sittig [Mon, 17 May 2021 20:14:50 +0000 (22:14 +0200)]
dmm/bm86x: check more bytes in DMM packet (undocumented by vendor)

User johnch reported via IRC that bm86x meters can lose sync to the
packet stream which goes unnoticed and tries to process invalid data.

Tighten the packet validity check, compare four bytes of the third chunk
in the DMM packet. This improves reliability, but isn't backed by vendor
documentation. It's yet to get determined whether other existing devices
don't provide the four-byte magic pattern.

20 months agoscpi-dmm: add "switch to local" support for Agilent protocol
Gerhard Sittig [Thu, 20 May 2021 21:46:17 +0000 (23:46 +0200)]
scpi-dmm: add "switch to local" support for Agilent protocol

Send "SYST:LOC" to Agilent protocol speaking scpi-dmm devices at the end
of the probe (--scan) as well as in close (--show, --samples, etc). This
ends "remote" and re-enters "local" mode after programmatic use. Should
increase usability, eliminates the need for manual intervention before
subsequent DMM use. Was tested with a Keysight DMM. Does not affect the
HP protocol speaking devices.

20 months agokorad-kaxxxxp: add an entry for Korad KD3005P V4.1
JD Steffen [Mon, 21 Feb 2022 21:01:59 +0000 (15:01 -0600)]
korad-kaxxxxp: add an entry for Korad KD3005P V4.1

Renames the previous entry to _V20, and adds _V41 to the list.

[ gsi: squash commits, fixup whitespace, sort order, reword message ]

20 months agostrutil: avoid glib/platform conversion calls for empty input
Gerhard Sittig [Thu, 19 Jul 2018 19:17:16 +0000 (21:17 +0200)]
strutil: avoid glib/platform conversion calls for empty input

It appears that either glib or some underlying platform library code for
text to number conversion yields unexpected values for return codes,
errno, and "end pointer" when _none_ of the input could get converted.
This was reported for MacOS, did not reproduce on Linux. The reported
issue was addressed in commit 51bf39a1633c, this implementation is just
much more conservative and hopefully easier to verify since it's more
explicit.

Rephrase the rational text to number conversion to avoid the problematic
input cases. Address style nits while we are here in the hope to improve
readability: Move initial assignment and subsequent updates of variables
closer together for easier verification.

Accept optional leading whitespace. Accept numbers like "123." in
addition to the previously supported ".123" formats. But insist that one
of the integral or fractional parts must be present. Try harder to setup
non-zero errno values for other failed conversion attempts beyond failed
library calls (the strtol(3) manpage suggests so in the ERRORS section).

This implementation passes on Linux, but has not been tested with MacOS
which appears to have a pickier library implementation.

20 months agohp-3478a: Handle NULL dereference in read, write and list.
Frank Stettner [Wed, 30 Jun 2021 12:46:31 +0000 (14:46 +0200)]
hp-3478a: Handle NULL dereference in read, write and list.

20 months agohp-3478a: revert the recent NULL dereference check in config API routines
Gerhard Sittig [Wed, 30 Jun 2021 18:13:21 +0000 (20:13 +0200)]
hp-3478a: revert the recent NULL dereference check in config API routines

Undo commit 020df861e0eb before replacing it with something better.

20 months agodevice: don't accept empty names for sigrok channels
Gerhard Sittig [Tue, 16 Aug 2022 20:17:45 +0000 (22:17 +0200)]
device: don't accept empty names for sigrok channels

It's unexpected when sigrok channels "have no name". Previous versions
would not strictly enforce non-empty names and could let empty names
slip in, but application code was reported to be confused when it
happened. The benefit of having channels "with no names" is questioned.

Adjust the public API routines. Accept missing name specs in the
sr_channel_new() routine for maximum backwards compatibility. Reject
missing names in sr_dev_channel_name_set() so that empty or non-empty
names can only be replaced by non-empty names. Check the return code of
sr_channel_new() in sr_dev_inst_channel_add() so that failed channel
creation gets propagated to callers. The current implementation will
never fail sr_channel_new(), but future versions might.

None of libsigrok code (device drivers, input modules) assign empty
names to channels. Applications still need to get checked. A future
commit might make names in sr_channel_new() mandatory.

20 months agodmm/bm52x: silence compiler warning related to printf() buffer size
Gerhard Sittig [Tue, 9 Aug 2022 16:05:49 +0000 (18:05 +0200)]
dmm/bm52x: silence compiler warning related to printf() buffer size

Increase another text buffer's size to cover the maximum length that an
integer could occupy in theory. Which amends commit 46a36bf0bb2e.

The previous implementation did not suffer from any issue, we know the
number of recordings in the BM52x DMM to remain small. This change only
silences a compiler warning, doesn't change the parser's behaviour.

22 months agoREADME.devices: mention that kingst-la2016 requires firmware files
Gerhard Sittig [Sat, 11 Jun 2022 14:29:16 +0000 (16:29 +0200)]
README.devices: mention that kingst-la2016 requires firmware files

22 months agoREADME.devices: explicitly discuss serial-over-HID in the UNI-T section
Gerhard Sittig [Sat, 11 Jun 2022 14:21:40 +0000 (16:21 +0200)]
README.devices: explicitly discuss serial-over-HID in the UNI-T section

This amends commit f736691d1323. Explictly mention that USB cables for
UNI-T devices and rebrands transparently work with libsigrok's serial
communication over HID cables. Mention that uni-t-dmm is redundant.

2 years agoinput: decorate sr_input_find() parameter as const
Gerhard Sittig [Sat, 23 Apr 2022 19:01:12 +0000 (21:01 +0200)]
input: decorate sr_input_find() parameter as const

The caller's input module name is only read for comparison. Decorate it
with the 'const' attribute to simplify calling application code.

2 years agoREADME.devices: add an UT-D04 on Windows section (libwdi and hidapi)
Gerhard Sittig [Sun, 3 Apr 2022 18:09:18 +0000 (20:09 +0200)]
README.devices: add an UT-D04 on Windows section (libwdi and hidapi)

A user reported that the Windows driver which is assigned to the CH9325
based UT-D04 cable neither provides a genuine serial port nor shows up
in the sigrok enumeration which additionally uses HIDAPI. Mention that
assigning a different Windows driver can help in that case.

2 years agoREADME.devices: add Windows and Zadig discussion near the udev section
Gerhard Sittig [Wed, 30 Mar 2022 06:06:22 +0000 (08:06 +0200)]
README.devices: add Windows and Zadig discussion near the udev section

Add a section on Windows and device driver assignments by means of Zadig
after the section on Linux udev rules and permissions. Reference the
wiki page for the Windows platform.

2 years agoREADME: Mention optional nettle dependency.
Gerhard Sittig [Thu, 24 Feb 2022 21:42:55 +0000 (22:42 +0100)]
README: Mention optional nettle dependency.

One of the USB load drivers depends on the nettle library. Add it to the
README file as another optional dependency.

2 years agoconfigure.ac: consider libusb_os_handle absence non-fatal on Windows
Gerhard Sittig [Mon, 14 Feb 2022 20:30:14 +0000 (21:30 +0100)]
configure.ac: consider libusb_os_handle absence non-fatal on Windows

Keep checking for the libusb_os_handle data type's presence, but don't
consider its absence on Windows fatal. Recent mainline libusb provides
something similar to the event abstraction branch under the common API.
Assume that it's the integrators' or packagers' responsibility to either
use a recent library or a patched older library for sigrok builds.

All other non-Windows platforms remain unaffected, the presence check
never was fatal there. The data type check itself needs to remain in
place because the usb.c source code adjusts to its presence.

2 years agohp-3478a: use symbolic name for status register bit field
Gerhard Sittig [Tue, 21 Dec 2021 15:25:26 +0000 (16:25 +0100)]
hp-3478a: use symbolic name for status register bit field

The hp_3478a_receive_data() routine uses SPOLL to only communicate
measurement data when they have become available. Use a symbolic name
for the tested bitfield for consistency with other driver locations
and for improved readability.

2 years agoudev: add Asix Omega USB identification to udev rules
Gerhard Sittig [Wed, 7 Oct 2020 18:07:01 +0000 (20:07 +0200)]
udev: add Asix Omega USB identification to udev rules

2 years agokingst-la2016: cope with 800MHz base clock for 500MHz models
Gerhard Sittig [Mon, 21 Feb 2022 20:45:18 +0000 (21:45 +0100)]
kingst-la2016: cope with 800MHz base clock for 500MHz models

The LA5016 uses an 800MHz base clock to derive the samplerate from. And
communicates divider 1 to configure the 500MHz rate. And does support
the 200MHz rate (divider 4). Which also makes the 10kHz lower boundary
unavailable on some models. Update the capture configuration logic, the
config API routines, and associated comments. Discuss how streaming may
make finer grained rates tables desirable (but stick with 1/2/5 for now).

2 years agokingst-la2016: zero pad FPGA bitstream to 4KiB boundaries
Gerhard Sittig [Mon, 21 Feb 2022 20:43:16 +0000 (21:43 +0100)]
kingst-la2016: zero pad FPGA bitstream to 4KiB boundaries

The 2KiB padding worked for LA2016 but kept looking susipcious. Pad the
FPGA bitstream to 4KiB boundaries, which unbreaks LA5016 and still works
with LA2016.

2 years agokingst-la2016: introduce base clock independent from max samplerate
Gerhard Sittig [Mon, 7 Feb 2022 18:42:19 +0000 (19:42 +0100)]
kingst-la2016: introduce base clock independent from max samplerate

The LA1010 devices are said to use an 800MHz base clock to derive the
samplerate of up to 100MHz from. Add this information to the list of
known devices, and adjust the samplerate dividier code path.

Keep value 0 in that column for all devices where the base clock and the
maximum samplerate are identical. For awareness during maintenance. Make
the untypical devices stand out.

2 years agokingst-la2016: add more device types and their EEPROM magic numbers
Gerhard Sittig [Mon, 7 Feb 2022 17:52:20 +0000 (18:52 +0100)]
kingst-la2016: add more device types and their EEPROM magic numbers

Extend the EEPROM content check which identifies device types. Inspect
the full set of four bytes before falling back to weaker checks of two
bytes per copy. Prefer the longest run of consistent data that is found
first. Some devices are said to require inspection of byte[2] in
addition to byte[0], to tell different models apart which share the
same byte[0] value.

This was exclusively tested on LA2016 hardware. The details were derived
from the https://github.com/AlexUg/sigrok implementation (which claims
support for LA1010, the LA50xx details may be untested there as well).
The model database also includes items which are not supported by this
driver implementation, to provide the maximum amount of information to
users which became available during scan.

2 years agotests: address printf format issues, spotted by clang on macos
Gerhard Sittig [Sat, 12 Feb 2022 14:00:44 +0000 (15:00 +0100)]
tests: address printf format issues, spotted by clang on macos

The sr_rational data type has int64_t and uint64_t members, but analog.c
and strutil.c source code used "%ld" and "%lu" formats. Use PRIu64 et al
instead.

  .../libsigrok/tests/strutil.c:125:14: warning: format specifies type 'long' but the argument has type 'int64_t' (aka 'long long') [-Wformat]
                      input, rational.p, rational.q);
                             ^~~~~~~~~~
  /usr/local/Cellar/check/0.15.2/include/check.h:472:77: note: expanded from macro 'fail_unless'
      _ck_assert_failed(__FILE__, __LINE__, "Assertion '"#expr"' failed" , ## __VA_ARGS__, NULL)
                                                                            ^~~~~~~~~~~

Also make test stimulus static. It's a constant vector of literals and
is exclusively used in the test routine, need not occupy stack space.

2 years agokingst-la2016: comment on FPGA register at offset 0x0004 (unused)
Gerhard Sittig [Sun, 20 Feb 2022 07:10:33 +0000 (08:10 +0100)]
kingst-la2016: comment on FPGA register at offset 0x0004 (unused)

The vendor firmware optionally keeps reading u32 values from the FPGA
register at offset 0x0004 outside of acquisition periods. To present
the input pin's current level and changes "in real time" in the GUI.
The sigrok driver does not use this information, but it's useful to
have the comment in the source code.

2 years agokingst-la2016: prefer boolean data type for bool information
Gerhard Sittig [Sun, 20 Feb 2022 09:02:15 +0000 (10:02 +0100)]
kingst-la2016: prefer boolean data type for bool information

The la2016_is_idle() routine provided boolean information in an
'int' data type. Prefer gboolean instead.

2 years agokingst-la2016: stop acquisition when USB device was lost
Gerhard Sittig [Sun, 20 Feb 2022 10:36:43 +0000 (11:36 +0100)]
kingst-la2016: stop acquisition when USB device was lost

Check for the condition when the USB device has gone away in the middle
of getting communicated to. Terminate acquisition in that case, instead
of trying to continue.

2 years agokingst-la2016: add support for streaming mode, works for 16 channels
Gerhard Sittig [Sun, 20 Feb 2022 09:06:09 +0000 (10:06 +0100)]
kingst-la2016: add support for streaming mode, works for 16 channels

Implement support for streaming mode and announce the SR_CONF_CONTINUOUS
config key. Automatically enable streaming mode for devices which don't
have local memory. Device identification, firmware download, and capture
setup are identical to "normal mode" as the vendor calls it. But the
sequence of submitting USB transfers by the host and starting capture
data transmission on the device differs. The phase of supervising the
hardware driven acquisition does not apply. Capture data is immediately
streamed to the host after initiating the acquisition.

The capture data memory layout dramatically differs. Samples are not
compressed, and samples taken at several points in time are kept in the
same memory cell. Processing is a little more expensive, bits need more
shuffling. Lack of compression makes the acquisition in stream mode
heavily depend on the reliability of USB bulk communication. The vendor
software assumes a 300Mbps boundary, and also enforces it by disabling
channels depending on the samplerate. The sigrok driver accepts any user
specified configuration, and merely warns for high amounts of traffic.
Local tests successfully communicated 320Mbps. Slow samplerates result
in slow arrival of more sample data, which periodically gets flushed to
improve usability. Thresholds when to start pushing may need tuning.

This implementation was tested with LA2016 and up to 16 channels. Other
devices are untested, especially LA1010 which lacks local memory and
thus exclusively supports streaming, and devices with 32 channels where
capture data memory layout may differ from devices with 16 channels (yet
to get verified).

2 years agokingst-la2016: experiment with USB bulk size and pool count
Gerhard Sittig [Sun, 20 Feb 2022 08:32:14 +0000 (09:32 +0100)]
kingst-la2016: experiment with USB bulk size and pool count

The previous implementation used a pool of 32 USB bulk transfers of up
to 256KiB size each. Using a pool did speedup capture data downloads,
using more transfers or larger buffers would not make a difference.
Slightly reduce the total memory consumption again, change the setup to
8 transfers of up to 512KiB each, which results in a total of 4MiB for
pending USB communication. These numbers are as arbitrary as any other.
No attempt was made to automatically derive the values from acquisition
parameters like samplerate and samples count.

2 years agokingst-la2016: use a pool of USB bulk transfers, speedup download
Gerhard Sittig [Sun, 20 Feb 2022 08:22:21 +0000 (09:22 +0100)]
kingst-la2016: use a pool of USB bulk transfers, speedup download

Use a pool of 32 USB bulk transfers of up to 256KiB size each. Which
doubles throughput and reduces the time to download the capture data
after acquisition has completed.

2 years agokingst-la2016: move USB bulk transfer handling to helper routines
Gerhard Sittig [Sun, 20 Feb 2022 07:48:08 +0000 (08:48 +0100)]
kingst-la2016: move USB bulk transfer handling to helper routines

Concentrate all support code which handles USB bulk transfers for the
capture data download in a set of helper routines: memory allocation
and release, submission and cancellation including re-submission after
a previous completion.

Submit host side transfers earlier, between the configuration and the
start of USB bulk transfers in the device. Allocate transfers and their
buffers at the first acquisition start. Keep allocated buffers across
several acquisition periods. Relase transfers and their buffers when the
device closes. Allocate buffers of fixed size (always 256KiB, no longer
depends on the remainder of the currently downloaded capture data).

Acquisition stop cancels all currently submitted transfers, and does
postprocess their (cancelled) completion without re-submitting. This
avoids "spilling" pending transfers into the next acquisition cycle.

Name the helper routines in preparation of using multiple transfers.
Stick with a single transfer in this commit to simplify review. Use a
longer USB receive timeout (500ms for capture data, in contrast to
200ms for control transfers).

2 years agokingst-la2016: move capture download details out of USB xfer handling
Gerhard Sittig [Sun, 20 Feb 2022 07:15:21 +0000 (08:15 +0100)]
kingst-la2016: move capture download details out of USB xfer handling

Ideally the USB transfer handling logic and the interpretation of the
downloaded capture data would not be as intertwined. The current
implementation assumes a rather specific capture model ("normal mode"
as it's called in the vendor software), and would not work in streaming
mode.

Move as many details out of the receive_transfer() routine and into the
send_chunk() data processing routine as we can. Which only leaves error
code paths and USB transfer re-submission, which get addressed in a
subsequent commit.

2 years agouse common channel group allocation/release code
Gerhard Sittig [Wed, 26 Jan 2022 22:23:27 +0000 (23:23 +0100)]
use common channel group allocation/release code

Eliminate individual open coded alloc and release code for channel
groups in hardware drivers and input modules. Use common code instead.

This commit affects: arachnid-labs-re-load-pro, atten-pps3xxx,
baylibre-acme, dcttech-usbrelay, demo, dreamsourcelab-dslogic, fx2lafw,
gwinstek-gds-800, gwinstek-gpd, hameg-hmo, hantek-4032l, hantek-6xxx,
hantek-dso, hp-3457a, hp-59306a, hung-chang-dso-2100, itech-it8500,
lecroy-xstream, maynuo-m97, microchip-pickit2, motech-lps-30x, rigol-dg,
rigol-ds, scpi-pps, siglent-sds, yokogawa-dlm, input/vcd.

2 years agokingst-la2016: add my copyright for recent improvements
Gerhard Sittig [Sat, 5 Feb 2022 13:40:59 +0000 (14:40 +0100)]
kingst-la2016: add my copyright for recent improvements

The usability improvements, firmware speedups, portability and robustness
improvements, and style cleanup were non-trivial. Add my copyright to the
Kingst LA2016 driver source code.

2 years agokingst-la2016: spew pretty FPGA register dump for development support
Gerhard Sittig [Sat, 5 Feb 2022 13:30:47 +0000 (14:30 +0100)]
kingst-la2016: spew pretty FPGA register dump for development support

Implement a pretty registers dump, and call it when the FPGA bitstream
content gets checked and when hardware controlled acquisition completes.
Generate this FPGA registers dump at spew log level, accept a caller
provided address range to further reduce verbosity as needed.

This is mostly motivated by developer's curiousity. To suport research
when previously unknown models are seen. Or to see which other details
are available as an acquisition executes. Or to check whether some of
the previously written configuration could be read back.