]> sigrok.org Git - libsigrok.git/log
libsigrok.git
3 years agools: Use symbolic name for "success" error code.
v1ne [Wed, 1 Apr 2020 14:45:17 +0000 (16:45 +0200)]
ols: Use symbolic name for "success" error code.

Reviewed-By: Wolfram Sang <redacted>
3 years agools: Make constant names more precise, clarify comment
v1ne [Tue, 31 Mar 2020 18:20:25 +0000 (20:20 +0200)]
ols: Make constant names more precise, clarify comment

Reviewed-By: Wolfram Sang <redacted>
3 years agools: Rename "flags" to "capture flags".
v1ne [Tue, 31 Mar 2020 17:32:23 +0000 (19:32 +0200)]
ols: Rename "flags" to "capture flags".

In the current implementation the "flags" are exclusively used for
captures. Prepare the introduction of device flags by renaming the
capture related flags which are specific to an operation.

Reviewed-By: Wolfram Sang <redacted>
3 years agools: Symbolic name for magic value, reflect units in variable names
v1ne [Tue, 31 Mar 2020 16:48:30 +0000 (18:48 +0200)]
ols: Symbolic name for magic value, reflect units in variable names

Reviewed-By: Wolfram Sang <redacted>
3 years agools: Remove stray command
v1ne [Tue, 31 Mar 2020 19:38:38 +0000 (21:38 +0200)]
ols: Remove stray command

It's nowhere documented and nowhere used.

Reviewed-By: Wolfram Sang <redacted>
3 years agools: Make use of zero-initialization.
v1ne [Tue, 31 Mar 2020 16:48:05 +0000 (18:48 +0200)]
ols: Make use of zero-initialization.

No need to assign zero after gmalloc0(). Move comments to declaration.

Reviewed-By: Wolfram Sang <redacted>
3 years agolibsigrok.h: Fix comment for unit Joule.
Frank Stettner [Sun, 23 Aug 2020 11:10:00 +0000 (13:10 +0200)]
libsigrok.h: Fix comment for unit Joule.

3 years agolibsigrok.h: Add Joule, Coulomb, and Ah units.
Frank Stettner [Mon, 27 Jul 2020 17:54:06 +0000 (19:54 +0200)]
libsigrok.h: Add Joule, Coulomb, and Ah units.

Also extend a comment on energy in comparison to power.

3 years agolibsigrok.h: Add MQ for electric charge.
Frank Stettner [Mon, 27 Jul 2020 17:54:06 +0000 (19:54 +0200)]
libsigrok.h: Add MQ for electric charge.

3 years agoteleinfo: Fix measured quantity (energy, not power).
Frank Stettner [Mon, 27 Jul 2020 17:55:27 +0000 (19:55 +0200)]
teleinfo: Fix measured quantity (energy, not power).

3 years agooutput/csv: always generate text for analog/logic data packets
Gerhard Sittig [Sat, 22 Aug 2020 16:24:12 +0000 (18:24 +0200)]
output/csv: always generate text for analog/logic data packets

Unconditionally generate output text when a session packet is received
which carries analog or logic sample data. Even if the data gets queued
and is not shown immediately, in that case the output text remains empty
but needs to be present. Otherwise applications may assume that the CSV
output module had not handled the data at all, which would result in
unexpected "screen output" with fallback data being interleaved with the
CSV output.

This resolves bug #1026 in its strictest sense (the unexpected presence
of fallback data). But leaves all other issues mentioned in comment 1.

3 years agooutput/csv: check unsupported/untested input signal conditions
Gerhard Sittig [Sat, 22 Aug 2020 15:57:55 +0000 (17:57 +0200)]
output/csv: check unsupported/untested input signal conditions

The current implementation of the CSV output module makes assumptions
which don't hold. Which results in incorrect or incomplete output for
some combinations of logic and analog signals.

Check for some of the known problematic conditions, and warn the user
about potentially unexpected results. This is a workaround until the
issues properly get addressed in the implementation.

This is motivated by but does not resolve bug #1026.

3 years agoREADME.devices: Document enabling GW Instek GDM-397 serial output mode.
Timo Kokkonen [Sat, 22 Aug 2020 06:59:25 +0000 (23:59 -0700)]
README.devices: Document enabling GW Instek GDM-397 serial output mode.

3 years agoserial-dmm: Add GW Instek GDM-397 meter support.
Timo Kokkonen [Sat, 22 Aug 2020 06:14:47 +0000 (23:14 -0700)]
serial-dmm: Add GW Instek GDM-397 meter support.

This meter appears to be rebranded UNI-T UT61B, but with
improved input protection.

3 years agokorad-kaxxxxp: add support for forced "detection" of a given model
Gerhard Sittig [Sat, 1 Aug 2020 15:22:28 +0000 (17:22 +0200)]
korad-kaxxxxp: add support for forced "detection" of a given model

Korad PSU models are rather popular. But the successful operation of
currently unsupported model names or firmware versions is hard to verify
by users, because building the library from locally modified sources is
involved.

Introduce support for the "force_detect=" scan option. Warning messages
contain how the device identifies itself. Optional user specs can force
the assignment of the driver to the unsupported model. Which results in
reports that include the identification details as well as the successful
use of the device.

  $ sigrok-cli -d korad-kaxxxxp:conn=...:force_detect=KORADKA3005PV2.0 --show

3 years agohwdriver: introduce SR_CONF_FORCE_DETECT config key (scan option)
Gerhard Sittig [Sat, 1 Aug 2020 15:12:50 +0000 (17:12 +0200)]
hwdriver: introduce SR_CONF_FORCE_DETECT config key (scan option)

Often previously unsupported models might be covered by existing code,
but would not match against a builtin list of known devices.

Introduce a config key which provides a scan option for users to force
the use of a driver with an unsupported device. This increases the
probability of requests for support of an additional model which are
associated with a successful use of that very device, and eliminates
the necessity to build from source for the trivial cases.

It's up to individual drivers whether they support forced detection,
and how they interpret the value of the scan option.

3 years agokorad-kaxxxxp: add config_get() support for SR_CONF_CONN
Gerhard Sittig [Sun, 2 Aug 2020 10:01:45 +0000 (12:01 +0200)]
korad-kaxxxxp: add config_get() support for SR_CONF_CONN

Let applications query the device instance's conn= key. This lets users
recognize individual devices if multiple of them are connected.

  $ sigrok-cli -d korad-kaxxxxp:conn=/dev/ttyACM0 --show
  ...
  korad-kaxxxxp:conn=/dev/ttyACM0 - Korad KA3005P with 2 channels: V I
  ...

3 years agoscpi-dmm: Remove SYST:LOC hack for GWInstek meters.
Timo Kokkonen [Wed, 19 Aug 2020 06:52:19 +0000 (23:52 -0700)]
scpi-dmm: Remove SYST:LOC hack for GWInstek meters.

No need for this hack anymymore as there is now DMM_CMD_SETUP_LOCAL
command that can be used to return unit back to "local" mode properly.

3 years agoscpi-dmm: Add new command DMM_CMD_SETUP_LOCAL.
Timo Kokkonen [Wed, 19 Aug 2020 06:29:18 +0000 (23:29 -0700)]
scpi-dmm: Add new command DMM_CMD_SETUP_LOCAL.

Add new command DMM_CMD_SETUP_LOCAL for setting device back
to "local" mode. If device implmements this command, it is
sent when driver is closed and after device "scan".

Define DMM_CMD_SETUP_LOCAL for GWInstek meters, so they get
returned to local mode automatically after use.

3 years agoscpi-dmm: alpha-sort the list of supported devices (vendor/model list)
Gerhard Sittig [Mon, 17 Aug 2020 18:32:08 +0000 (20:32 +0200)]
scpi-dmm: alpha-sort the list of supported devices (vendor/model list)

Any order is as arbitrary as any other. The alphabetical order of vendor
and model names might be the most robust during maintenance: easiest to
remember, easiest to use when checking for presence, and easiest to add
to or resolve conflicts during merges. Vendor renames (HP to Agilent to
Keysight, et al) are ugly but can't be helped easily.

3 years agoscpi-dmm: minor style adjustment (gdm906x, analog init, comments, diag)
Gerhard Sittig [Mon, 17 Aug 2020 18:01:02 +0000 (20:01 +0200)]
scpi-dmm: minor style adjustment (gdm906x, analog init, comments, diag)

Address minor style issues: Need not assign NULL after g_malloc0(), need
not check for NULL before g_free(). Rephrase diagnostics messages which
are user visible by default, remove internal development details. Reword
a few comments, and adjust their grammar for consistency across the code
base. The sr_analog_init() routine executed immediately before getting
measurements, need not (re-)assign endianess or floating point details,
except those which do change after initialization (double vs float).
Rephrase model dependent checks for easier adjustment during maintenance.
Unobfuscate string comparisons.

3 years agoscpi: Raise severity when IDN response lacks the serial number field.
Gerhard Sittig [Mon, 17 Aug 2020 17:07:37 +0000 (19:07 +0200)]
scpi: Raise severity when IDN response lacks the serial number field.

Raise the diagnostics message's severity from debug to warn when the
'*IDN?' response lacks the serial number field. Although it has only
been seen for some GWInstek DMMs, it violates the SCPI spec, and more
or other activity is required in a future implementation. This change
amends commit 47e7a6395e21.

3 years agoscpi_serial: Rephrase NL and NL+CR line termination check.
Gerhard Sittig [Mon, 17 Aug 2020 16:48:50 +0000 (18:48 +0200)]
scpi_serial: Rephrase NL and NL+CR line termination check.

Rearrange the check for line termination in SCPI receive data, and add a
comment in that spot. Keep related conditions together, avoid line breaks
for complex terms. This shall simplify review, and raise awareness during
maintenance. This change amends commit a0ade2f933d6.

3 years agoscpi_serial: Add GW-Instek GPD-9061 (USBCDC mode) VID/PID.
Timo Kokkonen [Sun, 16 Aug 2020 00:03:34 +0000 (17:03 -0700)]
scpi_serial: Add GW-Instek GPD-9061 (USBCDC mode) VID/PID.

3 years agoudev: Add GW-Instek GDM-9061 VID/PID.
Timo Kokkonen [Sat, 15 Aug 2020 23:59:55 +0000 (16:59 -0700)]
udev: Add GW-Instek GDM-9061 VID/PID.

3 years agoscpi-dmm: Add support for GW-Instek 906X series bench multimeters.
Timo Kokkonen [Sat, 15 Aug 2020 22:40:23 +0000 (15:40 -0700)]
scpi-dmm: Add support for GW-Instek 906X series bench multimeters.

- Add support for GDM-9060 and GDM-9061 DMMs.

3 years agoscpi-dmm: Add support for GW-Instek 8200A series bench multimeters.
Timo Kokkonen [Tue, 2 Jun 2020 06:29:47 +0000 (23:29 -0700)]
scpi-dmm: Add support for GW-Instek 8200A series bench multimeters.

- Add support for GDM-8251A and GDM-8255A DMMs.

3 years agoscpi: Support devices that omit serial number in *IDN? command responses.
Timo Kokkonen [Tue, 2 Jun 2020 07:42:54 +0000 (00:42 -0700)]
scpi: Support devices that omit serial number in *IDN? command responses.

3 years agoscpi_serial: Add support for (broken) devices sending NL+CR terminator.
Timo Kokkonen [Tue, 2 Jun 2020 06:56:03 +0000 (23:56 -0700)]
scpi_serial: Add support for (broken) devices sending NL+CR terminator.

This allows SCPI code to work with devices that terminate their responses
with NL+CR (instead of usual NL) like some GW-Instek DMMs.

3 years agoserial_hid: add iokit= prefix for the Mac IOKit special case
Gerhard Sittig [Thu, 30 Jul 2020 16:54:44 +0000 (18:54 +0200)]
serial_hid: add iokit= prefix for the Mac IOKit special case

Rephrase the logic which turns HIDAPI paths returned from enumerations
into something that can be used with conn= device options. Rearrange
code paths and rename variables to hopefully increase readability, and
to prepare support for more conditions in future implementations.

Replace the "IOService:" prefix on recent Mac versions with the "iokit="
literal, to eliminate the previously unhandled colon in path names. This
resolves bug #1586.

Move the allocation of a writable buffer from the callers to the callee,
to simplify multiple call sites, and most of all because the caller need
not be aware of the buffer's required size (input and output size can
differ in either direction).

Update the conn=hid/ section in README.devices, add the iokit= prefix.

3 years agooutput/csv: complete and improve timestamp construction support
Gerhard Sittig [Wed, 5 Aug 2020 17:52:17 +0000 (19:52 +0200)]
output/csv: complete and improve timestamp construction support

Unbreak the timestamp calculation when session data is received in
multiple packets. Avoid a division by zero when the samplerate is not
known yet the time column is requested. Only calculate timestamps when
the time column is requested. Use floating point during the scaling,
only convert to integer immediately before printing. Change line breaks
to not split a complex sub-expression across several lines.

3 years agooutput/csv: Avoid accumulated timestamp error for odd samplerates
Earle F. Philhower, III [Sat, 2 May 2020 17:45:22 +0000 (10:45 -0700)]
output/csv: Avoid accumulated timestamp error for odd samplerates

The conversion of sample rates to sample periods and the repeated
addition of truncated values (integer variables) resulted in the
accumulation of errors in the timestamp column for odd samplerate
values. How to reproduce:

  $ sigrok-cli -d demo:analog_channels=0 \
      -c samplerate=6000000 --samples 1200001 \
      -O csv:time=true | tail

Accept the additional cost to reduce the error. Always get the timestamp
in a new calculation based on the sample number and the sample rate.

This addresses bug #1027.

Signed-off-by: Earle F. Philhower, III <redacted>
[ gsi: rephrased commit message, how to reprodue ]

3 years agogwinstek-gpd: Add missing SW limits API calls.
Timo Kokkonen [Tue, 14 Jul 2020 04:54:25 +0000 (21:54 -0700)]
gwinstek-gpd: Add missing SW limits API calls.

3 years agosw_limits: add const for limits param for config_get
Gerhard Sittig [Mon, 3 Aug 2020 15:48:38 +0000 (17:48 +0200)]
sw_limits: add const for limits param for config_get

The sr_sw_limits_config_get() routine exclusively reads the 'limits'
parameter, need not write to it. Add the 'const' attribute.

3 years agoserial: make failed flush() in open() non-fatal, CP2110 flush() return
Gerhard Sittig [Sat, 1 Aug 2020 12:55:20 +0000 (14:55 +0200)]
serial: make failed flush() in open() non-fatal, CP2110 flush() return

Commit cb828f1b3e00 introduced an unconditional flush() call in the
open() routine's body, and passed its return value in verbatim form to
open() callers. Some of the transports/cables for serial communication
yield the SR_ERR_NA return value. Consider this a non-fatal condition.

Unbreak the CP2110 HID chip's flush() implementation. Don't expect a
return value of 0 from HID write calls, instead expect to see the number
of written bytes for successful calls.

This was tested with ch9325 (UT-D04), cp2110 (UT-D09) and bu86x.

3 years agogwinstek-gpd: Add support to old (hardware) revision units.
Timo Kokkonen [Tue, 14 Jul 2020 04:32:17 +0000 (21:32 -0700)]
gwinstek-gpd: Add support to old (hardware) revision units.

Manufacturer revised hardware design without changing model numbers at some point.
Old units have firmware that behaves differently. Responses are terminated with \r
instead of \n. And STATUS? command response format is different.

3 years agogwinstek-gpd: Add support for GPD-3303S.
Timo Kokkonen [Tue, 14 Jul 2020 04:44:25 +0000 (21:44 -0700)]
gwinstek-gpd: Add support for GPD-3303S.

3 years agooutput/ascii: data type nits, rephrase sample bit access
Gerhard Sittig [Fri, 31 Jul 2020 09:09:46 +0000 (11:09 +0200)]
output/ascii: data type nits, rephrase sample bit access

Use size types for counters, unsigned for bit manipulation. Trigger
position needs to remain a signed int (must be possible to go negative
for "not here", and strictly remains within the output text line length,
so should be good).

Rephrase the nested loop during bit extraction from logic packets, and
how a channel's value at a given sample number gets accessed. Eliminate
redundancy in that spot, to improve readability and simplify maintenance.

3 years agooutput/ascii: style nits in name alignment and trigger flush
Gerhard Sittig [Fri, 31 Jul 2020 08:15:44 +0000 (10:15 +0200)]
output/ascii: style nits in name alignment and trigger flush

Unobfuscate the implementation of the recent channel name alignment and
trigger position flush, address other style nits of earlier versions:

Don't need a GString for runtime constant channel names (which also
suffered from a mismatch of declaration and allocation). Don't need to
"construct space" when printf(3) can align the value. Pre-allocate text
buffers with more appropriate length when known in advance. Drop another
unused variable. Eliminate data type redundancy in malloc(3) calls. Make
sure to get zeroed memory, disabled channels can result in assignment
gaps. Use consistent brace style and separate variable declaration from
use (no RAII here).

Excess text line length remains, there has been a lot of it in the
previous implementation. It is left for another commit.

Tested with:

  $ sigrok-cli -d demo:analog_channels=0:logic_channels=4 --samples 40 -O ascii -t D3=r -w

3 years agooutput/ascii: Also print trigger marker for "short" data lines
v1ne [Wed, 1 Apr 2020 20:14:39 +0000 (22:14 +0200)]
output/ascii: Also print trigger marker for "short" data lines

The trigger position would be missing in the output text when the number of
available samples is less than the configured text line length. Do flush the
trigger marker for the last chunk of accumulated samples, too.

How to reproduce:

  $ sigrok-cli -d ... --samples 32 -O ascii:width=128

[ gsi: rephrased commit message ]

3 years agooutput/ascii: Vertically align logic channel names
v1ne [Wed, 1 Apr 2020 19:34:01 +0000 (21:34 +0200)]
output/ascii: Vertically align logic channel names

This results in vertical alignment of sample data and trigger positions.
The implementation assumes that the channel names' byte count corresponds
to the space which they occupy on screen. Channel names with umlauts still
may suffer from misalignment.

[ gsi: rephrased commit message ]

3 years agooutput/ascii: Remove unused variable
v1ne [Wed, 1 Apr 2020 20:13:26 +0000 (22:13 +0200)]
output/ascii: Remove unused variable

3 years agoanalog: avoid double free in '-O analog' shutdown path
milan hauth [Tue, 28 Jul 2020 15:01:03 +0000 (17:01 +0200)]
analog: avoid double free in '-O analog' shutdown path

Do void the 'def' and 'values' references for '-O analog' module options
in the shutdown path, to avoid double free calls.

3 years agooutput/srzip: improve robustness (analog-only acquisition)
Gerhard Sittig [Mon, 27 Jul 2020 16:51:22 +0000 (18:51 +0200)]
output/srzip: improve robustness (analog-only acquisition)

For pure analog acquisition without logic data the ZIP creation code
path resulted in a division by zero. Skip the bytes to samples math in
that case. How to reproduce:

  $ sigrok-cli -d demo:logic_channels=0:analog_channels=1 --samples 20 -o file.sr

Avoid a dependency on malloc(0) behaviour while we are here. Add a
warning on data feed submitter implementation issues, to not silently
drop the data, which could surprise users. This ShouldNotHappen(TM) for
correct implementations where channel counts and unit size agree, but
was observed with incomplete out-of-tree implementations. Eliminate
a data type redundancy in another malloc() call.

3 years agoscpi-dmm: Add Agilent 34410A.
Mike Walters [Mon, 27 Jul 2020 00:10:57 +0000 (01:10 +0100)]
scpi-dmm: Add Agilent 34410A.

3 years agoserial: flush() after open() in the serial core.
Wolfram Sang [Sun, 3 May 2020 20:57:50 +0000 (22:57 +0200)]
serial: flush() after open() in the serial core.

Quite some drivers flush the serial port after opening it. And quite
some don't although they should. Factor this out, so serial_open() will
always flush the port. The removal in the drivers was done with this
small coccinelle script:

@@
struct sr_serial_dev_inst *serial;
@@

        serial_open(serial, ...)
        ... when != serial
-       serial_flush(serial);

and then the results and the unmatched findings of serial_flush() were
audited.

Signed-off-by: Wolfram Sang <redacted>
3 years agobt: drop bt_put_le16() dependency (not universally available)
Gerhard Sittig [Fri, 6 Sep 2019 15:43:05 +0000 (17:43 +0200)]
bt: drop bt_put_le16() dependency (not universally available)

Eliminate the dependency on the non-portable bt_put_le16() routine. It
isn't available in all supported BlueZ versions, and won't be available
in other platform backends. Prefer write_u16le() which is available on
all sigrok supported platforms.

3 years agoinput: use common support to send samplerate meta packet
Gerhard Sittig [Thu, 11 Jun 2020 15:19:01 +0000 (17:19 +0200)]
input: use common support to send samplerate meta packet

3 years agoinput/saleae: reduce the format match routine's greed
Gerhard Sittig [Sun, 14 Jun 2020 12:26:57 +0000 (14:26 +0200)]
input/saleae: reduce the format match routine's greed

Only return OK from the format match routine when either of the tested
conditions reliably matched. Return an error in all other cases. This
avoids that the Saleae module is "winning a contest" due to even the
weakest condition, and then is not able to handle the input file.

3 years agoinput/saleae: introduce input module for Saleae Logic exported files
Gerhard Sittig [Thu, 11 Jun 2020 15:25:20 +0000 (17:25 +0200)]
input/saleae: introduce input module for Saleae Logic exported files

Start the implementation of an input module which covers Saleae Logic's
export files. CSV and VCD are handled by other modules, this one accepts
binary exports for Logic1 digital data (every sample, and when changed),
Logic1 analog data, Logic2 digital data, and Logic2 analog data.

The newer file format versions contain header information and can get
auto-detected, the older formats require a user spec. Some of the file
formats lack essential information in the file content, thus require
another user spec (samplerate for digital data is an example).

The .logicdata file format is unknown, and is not supported. The .sal
format could get added later, but requires local file I/O in the input
module, which current common infrastructure does not provide.

3 years agolibsigrok-internal: add endianess helpers for floating point types
Gerhard Sittig [Thu, 11 Jun 2020 15:19:50 +0000 (17:19 +0200)]
libsigrok-internal: add endianess helpers for floating point types

Extend the common set of endianess conversion helpers. Cover readers and
writers for little endian single and double precision and 64bit integer
values, including support to advance the read/write position.

3 years agoinput/vcd: unbreak the logic which skips a user specified period
Gerhard Sittig [Fri, 24 Jul 2020 14:10:55 +0000 (16:10 +0200)]
input/vcd: unbreak the logic which skips a user specified period

Rephrase the default value for the 'skip' option and the detection of a
user specified value. This is tricky because: Sample numbers are kept in
64bit values. Skip and downsample are fed to formulae so we want them
both to be unsigned. Yet absence of a user spec as well as possible user
values 0 and positive must be told apart. Use all-ones for the default
of "-1" which translates to "first timestamp", users need not be able to
specify that negative value.

Make sure to only downsample 'skip' values when the user specified some.
Which avoids the undesired insertion of huge idle gaps at the start of
the capture. An earlier implementation had to check for -1, this recent
version uses an unsigned number in combination with a boolean flag to
achieve this.

Reword some diagnostics messages, and print the samples count between
timestamps while we are here. Add a check for successful text to number
conversion of timestamp values.

How to reproduce:

  $ pulseview -i file.vcd
  $ pulseview -i file.vcd -I vcd:downsample=5
  $ pulseview -i file.vcd -I vcd:skip=111381600

Example file:

  $timescale 1 ns $end
  $scope module top $end
  $var wire 1 ! d1 $end
  $upscope $end
  $enddefinitions $end
  #111381815
  0!
  #111381905
  1!
  #111381990
  0!
  #111382075

3 years agooutput/srzip: queue samples before ZIP operation
Gerhard Sittig [Sun, 28 Jun 2020 01:30:58 +0000 (03:30 +0200)]
output/srzip: queue samples before ZIP operation

Accumulate samples from multiple session feed packets before sending
them off to ZIP archive operations. This improves throughput for those
setups where acquisition devices or input modules provide only few
samples per session feed send call.

This version also splits large packets from applications into smaller
ZIP members (if the application's packet size is larger than the output
module's local buffer size). If that is not desired, the implementation
needs adjustment to immediately pass larger blocks to ZIP operations
(after potentially flushing previously queued data) instead of looping.

This fixes bug #974.

3 years agooutput/vcd: support analog data, more channels, minor cleanup
Gerhard Sittig [Sat, 15 Apr 2017 11:06:20 +0000 (13:06 +0200)]
output/vcd: support analog data, more channels, minor cleanup

Extend and rephrase the VCD output module, to support mixed signal data,
support higher channel counts, and address other minor issues.

Increase the number of VCD identifiers which can get generated. Bump the
limit from 94 to 18346 channels. Prefer single letter names for backwards
compatibility for the first channels. Use two or three letter identifiers
as needed for higher channel counts.

Add support for analog channels, and carefully organize a queue such
that timestamps and their data only get written after input data for
_all_ channels was received from the session feed. Provide IEEE754
double precision values for maximum compatibility with other VCD aware
software, although sigrok internally passes analog data with single
precision. This makes potential later adjustment transparent to external
software.

Factor out and rephrase code while we are here. This implementation
avoids glib calls where they'd hurt performance. A local pool reduces
malloc() pressure to increase throughput. String manipulation is tuned
for simplicity and reduced cost. Special code paths were added to tune
the use cases where mixed signals are not involved (immediate write to
the output text, bypassing the output module's local queue).

An srzip input implementation detail still makes the VCD output consume
lots of memory during merge sort of channels' data. See bug #1566.

Other nits got addressed in bypassing: Adjust data types. Separate the
gathering of detail information and the construction of the VCD header
text to simplify review and future maintenance. Skip VCD identifiers for
disabled channels. Emit a final timestamp to flush the last sample, and
communicate the total capture length.

Update comments. Update the copyright for recent non-trivial changes.

3 years agoinput/vcd: rework VCD file import logic (vector, integer, real)
Gerhard Sittig [Mon, 13 Mar 2017 12:33:59 +0000 (13:33 +0100)]
input/vcd: rework VCD file import logic (vector, integer, real)

Extend and rework the VCD input module: accept more data types, improve
usability, fix known issues.

Add support for bit vectors (arbitrary width), multi-bit integer values
(absolute 64bit width limit, internal limitation to single precision),
and floating point numbers ('real' in VCD, single precision in sigrok).
Unfortunately sigrok neither has concepts of multi-bit logic channels
nor IEEE-1364 stdlogic values, the input module maps input data to
strict boolean and multiple logic channels. A vector's channels are
named and grouped to reflect their relation. VCD 'integer' types are
mapped to sigrok analog channels. Add support for scoped signal names,
and the re-use of one VCD signal name for multiple variables.

Rework file and text handling. Only skip pointless UTF-8 BOMs before
file content (not between sections). Handle lack of line termination at
the end of the input file. Process individual lines of input chunks,
avoid glib calls when they'd result in malloc pressure, and severely
degrade performance. Avoid expensive string operations in hot loops.

Rearrange the order of parse steps, to simplify maintenance and review:
end of section, new section, timestamp, data values, unsupported. Flush
previously queued values in the absence of a final timestamp. Unbreak
$comment sections in the data part. Apply stricter checks to input data,
and propagate errors. Avoid silent operation (weak warnings can go
unnoticed) which yields results that are unexpected to users. Unbreak
the combination of 'downsample' with 'skip' and 'compress'. Reduce noise
when users limit the number of channels while the input file contains
more data (keep a list of consciously ignored channels). Do warn or
error out for serious and unexpected conditions.

Address minor issues. Use common support for datafeed submission. Keep
user specified options across file re-load. Fixup data type nits, move
complex code blocks into separate routines. Sort the groups of routines,
put helpers first and concentrate public routines at the bottom. Extend
the builtin help text. Update comments, update the copyright for the
non-trivial changes.

Fixes bug #776 by adding support for bit vectors.
Fixes bug #1476 by flushing most recently received sample data.

3 years agoinput: introduce helper for buffered submission of sample data
Gerhard Sittig [Tue, 30 Jun 2020 18:14:18 +0000 (20:14 +0200)]
input: introduce helper for buffered submission of sample data

Input modules often find themselves in the situation where sample data
was received and could be sent to the session bus, but submission should
get deferred to reduce the number of send calls and provide larger data
chunks in these calls. Introduce common support code for buffered sample
data submission (both logic and analog), provide a simple alloc, submit,
flush, and free API.

3 years agoinput/binary: align sr_session_send() chunks to unit size
Gerhard Sittig [Thu, 23 Jul 2020 19:55:30 +0000 (21:55 +0200)]
input/binary: align sr_session_send() chunks to unit size

The input/binary module chops raw input data into chunks and sends these
to the session feed. The total size of input chunks got aligned to the
unit size, the session feed output didn't. Make sure to align session
packets with the input data's unit size, too.

This fixes bug #1582.

3 years agobindings/ruby: Bump minimum requirement to Ruby 2.5.0.
Uwe Hermann [Sat, 18 Jul 2020 15:31:38 +0000 (17:31 +0200)]
bindings/ruby: Bump minimum requirement to Ruby 2.5.0.

This version is known to work with the current code-base and recent
SWIG versions, whereas e.g. Ruby 2.3.x is known to not work (anymore).

This "fixes" the remaining parts of bug #1526.

3 years agofx2lafw: Use 1 as default for frame limit and reset num_frames
Soeren Apel [Mon, 13 Jul 2020 17:29:38 +0000 (19:29 +0200)]
fx2lafw: Use 1 as default for frame limit and reset num_frames

3 years agofx2lafw: Add support for frames
Valentin Ochs [Sat, 20 Jun 2020 00:04:00 +0000 (02:04 +0200)]
fx2lafw: Add support for frames

When using a number of frames that is not 1, the driver will read
samples up to its limit and then wait for another trigger. This will be
repeated until the configured number of frames has been finished.

3 years agoKorad-kaxxxxp: Add model Tenma 72-2550
motte [Mon, 13 Jul 2020 13:46:06 +0000 (15:46 +0200)]
Korad-kaxxxxp: Add model Tenma 72-2550

3 years agoFix #1576 by handling DSO1000B's CHAN#:PROB? responses
Valentin Ochs [Sun, 12 Jul 2020 21:15:29 +0000 (23:15 +0200)]
Fix #1576 by handling DSO1000B's CHAN#:PROB? responses

3 years agoserial-lcr: Allow retrieving frame limit
Valentin Ochs [Sat, 27 Jun 2020 20:45:06 +0000 (22:45 +0200)]
serial-lcr: Allow retrieving frame limit

3 years agorigol-ds: Allow retrieving frame limit
Valentin Ochs [Sat, 27 Jun 2020 20:44:53 +0000 (22:44 +0200)]
rigol-ds: Allow retrieving frame limit

3 years agohantek-dso: Allow retrieving frame limit
Valentin Ochs [Sat, 27 Jun 2020 20:44:39 +0000 (22:44 +0200)]
hantek-dso: Allow retrieving frame limit

3 years agohameg-hmo: Allow retrieving frame limit
Valentin Ochs [Sat, 27 Jun 2020 20:44:21 +0000 (22:44 +0200)]
hameg-hmo: Allow retrieving frame limit

3 years agogwinstek-gds-800: Allow retrieving frame limit
Valentin Ochs [Sat, 27 Jun 2020 20:44:04 +0000 (22:44 +0200)]
gwinstek-gds-800: Allow retrieving frame limit

3 years agoscpi_usbtmc_libusb: Retry if a Bulk-IN request starts with an empty packet
Andy Lutomirski [Sat, 13 Jun 2020 22:39:17 +0000 (15:39 -0700)]
scpi_usbtmc_libusb: Retry if a Bulk-IN request starts with an empty packet

This seems to make the Rigol DS1054Z work.  It's still a bit janky --
on a live capture, sample 688 (zero-based) out of the 1200-sample
frame seems to consistently contain garbage.  I'm not sure what's
going on.

3 years agoscpi_usbtmc_libusb: Check that bulk in requests read the entire header
Andy Lutomirski [Sat, 13 Jun 2020 22:32:36 +0000 (15:32 -0700)]
scpi_usbtmc_libusb: Check that bulk in requests read the entire header

The Rigol DS1054Z sometimes returns zero bytes in response to a bulk in
request.  sigrok ends up reading out of bounds and failing ungracefully
when this happens.  Check that libusb returned a full USBTMC header and
fail gracefully if it did not.

3 years agorigol-ds: Improve short block handling
Andy Lutomirski [Sat, 13 Jun 2020 19:03:38 +0000 (12:03 -0700)]
rigol-ds: Improve short block handling

When a short block is received, clean up the header state so that the
next block can be read.

Based on a patch for #1011 by Aleksander Alsekseev.

3 years agorigol-ds: Send some commands on 1st frame only
Valentin Ochs [Sun, 14 Jun 2020 01:23:36 +0000 (03:23 +0200)]
rigol-ds: Send some commands on 1st frame only

This can speed up reading of multiple segments by a factor 2 (9s vs 18s
when reading 5 frames with 2 channels and 7 kSa)

3 years agorigol-ds: Experimental support for segmented data with PROTOCOL_V3 models
Valentin Ochs [Sat, 13 Jun 2020 20:24:09 +0000 (22:24 +0200)]
rigol-ds: Experimental support for segmented data with PROTOCOL_V3 models

3 years agorigol-ds: Experimental support for V5 frame reading
Valentin Ochs [Thu, 11 Jun 2020 12:24:49 +0000 (14:24 +0200)]
rigol-ds: Experimental support for V5 frame reading

3 years agorigol-ds: Add support for reading segmented data for protocol v4
Valentin Ochs [Thu, 11 Jun 2020 11:54:10 +0000 (13:54 +0200)]
rigol-ds: Add support for reading segmented data for protocol v4

3 years agorigol-ds: Fix reading data from internal memory
Valentin Ochs [Thu, 11 Jun 2020 14:12:25 +0000 (16:12 +0200)]
rigol-ds: Fix reading data from internal memory

According to the programming manual, one should issue

    :WAV:RES
    :WAV:BEG

before reading data from internal memory. Without this, the wrong data
will be returned.

3 years agorigol-ds: Get correct samplerate for Memory and Segmented sources
Valentin Ochs [Thu, 11 Jun 2020 16:14:17 +0000 (18:14 +0200)]
rigol-ds: Get correct samplerate for Memory and Segmented sources

Read it at the start of acquisition. This prevents requests for
the SR from interfering with ongoing transfers.

This fixes bug #1217.

3 years agorigol-ds: Do not stop reading after the first frame
Valentin Ochs [Thu, 11 Jun 2020 11:53:12 +0000 (13:53 +0200)]
rigol-ds: Do not stop reading after the first frame

3 years agostd: avoid doube close
Wolfram Sang [Sat, 11 Apr 2020 20:45:00 +0000 (22:45 +0200)]
std: avoid doube close

I want to fix this double-close issue I see with my OLS:

First close at the end of a 'scan':

sr: [00:00.045171] openbench-logic-sniffer: Got metadata key 0x00, metadata ends.
sr: [00:00.045178] openbench-logic-sniffer: Disabling demux mode.
sr: [00:00.045186] serial: Closing serial port /dev/ttyACM0.

Second one as part of hwdriver cleanup:

sr: [00:00.046088] hwdriver: Cleaning up all drivers.
sr: [00:00.046108] serial: Closing serial port /dev/ttyACM0.
sr: [00:00.046116] serial-libsp: Cannot close unopened serial port /dev/ttyACM0.

So, before closing a second time, check if the device is not idle.

I am optimistic this could fix bugs #1151 and #1275, too.

Signed-off-by: Wolfram Sang <redacted>
3 years agokorad-kaxxxxp: Add KA3005P v5.5
Walter Goossens [Sat, 20 Jun 2020 19:54:07 +0000 (21:54 +0200)]
korad-kaxxxxp: Add KA3005P v5.5

Signed-off-by: Walter Goossens <redacted>
3 years agoRevert "bindings/ruby: Disable Ruby bindings until we have a fix for #1526."
Uwe Hermann [Sat, 20 Jun 2020 16:06:00 +0000 (18:06 +0200)]
Revert "bindings/ruby: Disable Ruby bindings until we have a fix for #1526."

This reverts commit 49d130200dc3217f99f3f7750fbc20d6c046bcf7.

The Ruby bindings build has been fixed now.

3 years agobindings/ruby: Fix ruby SWIG bindings generation
Anatol Pomozov [Tue, 9 Jun 2020 03:46:44 +0000 (20:46 -0700)]
bindings/ruby: Fix ruby SWIG bindings generation

bindings/swig/doc.py generates a swig interface file for ruby bindings
that includes docstrings with comments braces ( /* and */ ) like this:

  %feature("docstring") sigrok::Channel::type "/* Type of this channel. */\n";
  %feature("docstring") sigrok::Channel::enabled "/* Enabled status of this channel. */\n";

SWIG generates *.cxx and adds its own braces to the docstring:

/*/* Document-class: Sigrok::Error
Exception thrown when an error code is returned by any libsigrok call. */
*/

this causes compilation error for Ruby bindings.

To fix the error we should not add extra braces to the docstring.
With this patch libsigrok compiles fine with with ruby 2.7 and swig 4.0.2.

Fixes bug #1526

Signed-off-by: Anatol Pomozov <redacted>
3 years agoopenbench-logic-sniffer: improve error messages when scanning ID
Wolfram Sang [Mon, 4 May 2020 21:33:20 +0000 (23:33 +0200)]
openbench-logic-sniffer: improve error messages when scanning ID

- always say 'ID' when the ID command failed
- print hexdump of a faulty ID because on a stalled device we may get
  0x00 bytes which would terminate the string early.

Signed-off-by: Wolfram Sang <redacted>
3 years agokingst-la2016: improved bitstream upload and fix for v3.4.2
Florian Schmidt [Sun, 7 Jun 2020 16:43:39 +0000 (18:43 +0200)]
kingst-la2016: improved bitstream upload and fix for v3.4.2

of vendor's bitstream.
is now tested to work with version 3.4.0 and 3.4.2.

[fixes #1559]

3 years agoudev: Add Kingst LA2016 VID/PID.
Uwe Hermann [Sat, 6 Jun 2020 22:28:34 +0000 (00:28 +0200)]
udev: Add Kingst LA2016 VID/PID.

3 years agokingst-la2016: Use ARRAY_SIZE.
Uwe Hermann [Sat, 6 Jun 2020 22:47:46 +0000 (00:47 +0200)]
kingst-la2016: Use ARRAY_SIZE.

3 years agokingst-la2016: tested with idVendor=77a1, idProduct=01a2
Florian Schmidt [Sat, 21 Mar 2020 11:08:10 +0000 (12:08 +0100)]
kingst-la2016: tested with idVendor=77a1, idProduct=01a2

3 years agordtech-tc: Add initial support for the RDTech TC66C
Andreas Sandberg [Fri, 6 Mar 2020 14:44:41 +0000 (14:44 +0000)]
rdtech-tc: Add initial support for the RDTech TC66C

This changeset adds support for the RDTech TC66C USB power meter.

Currently, the driver reports the following channels:
  * V: VBus voltage
  * I: VBus current
  * D+: D+ voltage
  * D-: D- voltage
  * E: Energy consumed in threshold-based recording mode.

The number of significant digits shown for each channel has been set
to match the number of digits shown on the device.

Usage example:

sigrok-cli -d rdtech-tc:conn=/dev/ttyACM0 --scan

Known issues:

  * BLE support is currently unimplemented. This uses a different
    command set, but the same poll data format.

Kudos to Ben V. Brown for reverse engineering some of the protocol and
documenting the encryption key used for poll data.

Signed-off-by: Andreas Sandberg <redacted>
3 years agosrc/crc.c: Add missing file.
Uwe Hermann [Thu, 4 Jun 2020 22:05:04 +0000 (00:05 +0200)]
src/crc.c: Add missing file.

3 years agocrc: Factor out CRC16 implementation from Modbus
Andreas Sandberg [Fri, 6 Mar 2020 14:38:19 +0000 (14:38 +0000)]
crc: Factor out CRC16 implementation from Modbus

Being able to calculate a CRC16 is useful in multiple places, factor
this into a new module with CRC implementation. This module currently
only supports ANSI/Modbus/USB flavor of CRC16.

Signed-off-by: Andreas Sandberg <redacted>
3 years agordtech-um: Add initial support for the RDTech UMxx series
Andreas Sandberg [Sun, 28 Oct 2018 22:45:57 +0000 (22:45 +0000)]
rdtech-um: Add initial support for the RDTech UMxx series

This changeset adds support for the RDTech UMxx series of USB power
meters. The driver has been tested with the RDTech UM24C, but should
support the UM24C, UM25C, and the UM34C.

Currently, the driver reports the following channels:
  * V: VBus voltage
  * I: VBus current
  * D+: D+ voltage
  * D-: D- voltage
  * T: Device temperature
  * E: Energy consumed in threshold-based recording mode.

The number of significant digits shown for each channel has been set
to match the number of digits shown on a UM24C.

Missing features:

  * There is currently no support for configuring threshold-based
    recording from sigrok, but this can be done on the device itself.

  * Fast charging mode currently not logged.

Usage example:

sigrok-cli -d rdtech-um:conn=bt/rfcomm/MAC --scan
sigrok-cli -d rdtech-um:conn=/dev/rfcomm0 --scan

Known issues:

  * When using sigrok's Bluetooth transport implementation, the device
    is disconnected between probing and sampling. Some devices (e.g.,
    the UM24C), dislikes this and can't be reconnected reliably for
    sampling. This is not an issue when setting up a rfcomm device
    manually and using it as a serial port.

Kudos to Sven Slootweg for documenting most of the protocol.

Signed-off-by: Andreas Sandberg <redacted>
3 years agobinary_helpers: Drop unnecessary malloc check.
Uwe Hermann [Thu, 4 Jun 2020 22:09:11 +0000 (00:09 +0200)]
binary_helpers: Drop unnecessary malloc check.

(as per HACKING)

3 years agobinary_helpers: Add helper for devices with binary data
Andreas Sandberg [Fri, 6 Mar 2020 14:41:19 +0000 (14:41 +0000)]
binary_helpers: Add helper for devices with binary data

Many devices receive a struct with binary values when polled. Many of
these values will correspond channels in sigrok. This
change introduces helper functions for automatically reading and
scaling such values and sending them down a sigrok analog channel.

Signed-off-by: Andreas Sandberg <redacted>
3 years agolibsigrok.h: Add SR_MQ_ENERGY
Andreas Sandberg [Sat, 15 Feb 2020 12:53:16 +0000 (12:53 +0000)]
libsigrok.h: Add SR_MQ_ENERGY

3 years agouni-t-ut181a: comment on how to start a recording
Gerhard Sittig [Mon, 1 Jun 2020 08:23:38 +0000 (10:23 +0200)]
uni-t-ut181a: comment on how to start a recording

The meter allows remote controlled start of recordings, but requires a
few parameters where it's uncertain how to most appropriately get these
by means of SR_CONF_* keys.

Introduce SR_CONF_SET support for SR_CONF_DATALOG to raise awareness,
but leave the implementation empty for now. Leave a TODO comment which
discusses the meter's commands that one might want to use from here.

3 years agouni-t-ut181a: implement device driver for the UNI-T UT181A multimeter
Gerhard Sittig [Sat, 14 Dec 2019 14:14:46 +0000 (15:14 +0100)]
uni-t-ut181a: implement device driver for the UNI-T UT181A multimeter

Extend the previously introduced skeleton driver for UNI-T UT181A. Introduce
support for the full multimeter's protocol as it was documented by the ut181a
project. Which covers the retrieval of live readings, saved measurements, and
recordings, in all of the meter's modes and including relative, min/max, and
peak submodes. This implementation also parses compare mode (limits check)
responses, although it cannot express the result in terms of the session feed.

Announce the device as a multimeter as well as a thermometer, it supports
up to two probes including difference mode. When in doubt, prefer usability
over feature coverage (the driver side reflects all properties of the meter,
but not all features can get controlled by the driver). The probe routine
requires that users specify the serial port, and enable serial communication
on the meter.

Several TODO items remain. Comments in the driver code discuss limitations
of the current implementation, as well as cases where the meter's features
don't map well to sigrok's internal presentation. This implementation also
contains (optional, off by default) diagnostics for research on the serial
protocol.

3 years agouni-t-ut181a: Initial driver skeleton.
Gerhard Sittig [Fri, 13 Dec 2019 20:41:50 +0000 (21:41 +0100)]
uni-t-ut181a: Initial driver skeleton.

3 years agoasix-sigma: discuss usability of data pattern trigger specs
Gerhard Sittig [Sun, 31 May 2020 10:38:21 +0000 (12:38 +0200)]
asix-sigma: discuss usability of data pattern trigger specs

When data patterns for trigger specs span multiple bits, users may not
want to specify long lists of "<ch>=<lvl>" conditions for sigrok-cli's
--trigger option, and count channels by hand. Or click a dozen dialogs
to specify one data pattern, or modify a previous specification. Setups
with few traces may accept that, "data heavy" setups like parallel data
or address bus inspection may not.

Add comments which discuss the potential use of SR_CONF_TRIGGER_PATTERN.
Outline a syntax which may be flexible enough _and_ acceptable to users,
support data patterns and edge triggers alike, in several presentations
that serve different use cases.  This commit exclusively adds comments,
does not change behaviour.

Update a comment in the user spec to internal format trigger spec parser
to expand on hardware constraints and implementation limitations. Rename
an identifier which checks the number of edge conditions, not the number
of accepted trigger spec details.

3 years agoasix-sigma: unconditionally re-enable trigger support code
Gerhard Sittig [Sun, 31 May 2020 10:36:11 +0000 (12:36 +0200)]
asix-sigma: unconditionally re-enable trigger support code

Trigger support became operational again. Drop the compile time switch
which disabled the previously incomplete implementation.

This resolves bug #359.

3 years agoasix-sigma: complete and extend capture mode supervision
Gerhard Sittig [Sun, 31 May 2020 16:38:14 +0000 (18:38 +0200)]
asix-sigma: complete and extend capture mode supervision

Parse trigger specs early when acquisition starts, timeout calculation
needs to reflect on it. Either immediately start an acquisition timeout
for trigger-less configurations. Or prepare a timeout which spans the
post-trigger period, but only start its active period when the trigger
match was detected by the device's hardware.

Extend mode tracking during acquisition to handle other special cases.
Terminate acquisition when the user specified sample count limit exceeds
the hardware capacity, or when no limits were specified and the device's
memory is exhausted.

There is a slight inaccuracy in this approach, but the implementation
fails on the safe side. When both user specified limits and triggers are
involved, then at least the user specified time or sample count span is
provided. Usually more data is sent to the session feed, and all of the
requested period is covered. This is because of the software poll period
and the potential to start the timeout slightly late. As well as having
added some slack for hardware pipelines in the timeout calculation.

3 years agoasix-sigma: download sample memory in multiple receive calls
Gerhard Sittig [Sun, 31 May 2020 16:38:39 +0000 (18:38 +0200)]
asix-sigma: download sample memory in multiple receive calls

The previous implementation ran the complete sample memory retrieval
in a single call to the receive callback. Which in combination with
slow USB communication and deep memory could block application logic
for rather long periods of time.

Rephrase the download_capture() routine such that it can spread its
workload across multiple invocations. Run the acquisition stop and
resource allocation for the download, the interpretation of a set of
DRAM lines, and the resource cleanup, as needed. And keep calling the
download routine until completion of the interpretation of the sample
memory region of interest. The workload size per invocation may need
more adjustment.

The previous implementation could stall UI progress for some 20-30s.
This change lets users perceive UI progress while sample memory gets
retrieved and interpreted.

This resolves bug #1005.