Commit Graph

5477 Commits

Author SHA1 Message Date
Gerhard Sittig f8a8d4bb70 input: use common support to send samplerate meta packet 2020-07-24 20:15:40 +02:00
Gerhard Sittig 9084c39608 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.
2020-07-24 18:40:38 +02:00
Gerhard Sittig d891892dc0 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.
2020-07-24 17:21:13 +02:00
Gerhard Sittig daa895cba3 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.
2020-07-24 17:02:40 +02:00
Gerhard Sittig dd8bec71c2 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
2020-07-24 16:10:55 +02:00
Gerhard Sittig c03aaf342c 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.
2020-07-24 09:13:43 +02:00
Gerhard Sittig 8c5bd3d9c7 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.
2020-07-24 09:10:27 +02:00
Gerhard Sittig 0ab36d2f54 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.
2020-07-24 09:10:27 +02:00
Gerhard Sittig 47a102f9bb 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.
2020-07-24 09:10:27 +02:00
Gerhard Sittig cb0fedd942 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.
2020-07-23 21:59:29 +02:00
Uwe Hermann 339d12df97 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.
2020-07-18 17:37:17 +02:00
Soeren Apel 5f8cf332a6 fx2lafw: Use 1 as default for frame limit and reset num_frames 2020-07-13 23:07:56 +02:00
Valentin Ochs bfc34b9ab0 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.
2020-07-13 23:07:56 +02:00
motte f5083435cb Korad-kaxxxxp: Add model Tenma 72-2550 2020-07-13 15:46:06 +02:00
Valentin Ochs 34ce4d8258 Fix #1576 by handling DSO1000B's CHAN#:PROB? responses 2020-07-12 23:30:20 +02:00
Valentin Ochs e434f624ba serial-lcr: Allow retrieving frame limit 2020-07-12 20:38:36 +02:00
Valentin Ochs 1b8a37c688 rigol-ds: Allow retrieving frame limit 2020-06-27 22:57:10 +02:00
Valentin Ochs 50bc52f3a6 hantek-dso: Allow retrieving frame limit 2020-06-27 22:56:57 +02:00
Valentin Ochs 98c7ef378c hameg-hmo: Allow retrieving frame limit 2020-06-27 22:56:39 +02:00
Valentin Ochs 7c48d434f0 gwinstek-gds-800: Allow retrieving frame limit 2020-06-27 22:56:10 +02:00
Andy Lutomirski 025bd56f10 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.
2020-06-25 00:03:24 +02:00
Andy Lutomirski e2283318c1 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.
2020-06-25 00:03:24 +02:00
Andy Lutomirski 6999029585 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.
2020-06-25 00:03:24 +02:00
Valentin Ochs 16e96ca3af 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)
2020-06-24 23:58:17 +02:00
Valentin Ochs 06ed999aa4 rigol-ds: Experimental support for segmented data with PROTOCOL_V3 models 2020-06-24 23:56:01 +02:00
Valentin Ochs 19f31c8ace rigol-ds: Experimental support for V5 frame reading 2020-06-24 23:56:01 +02:00
Valentin Ochs 8cbe5339b1 rigol-ds: Add support for reading segmented data for protocol v4 2020-06-24 23:56:01 +02:00
Valentin Ochs 704910e32c 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.
2020-06-24 23:56:01 +02:00
Valentin Ochs 1cbb3b1cfb 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.
2020-06-24 23:56:01 +02:00
Valentin Ochs 418c99248c rigol-ds: Do not stop reading after the first frame 2020-06-24 23:56:01 +02:00
Wolfram Sang 9b09360654 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 <wsa@kernel.org>
2020-06-24 23:20:41 +02:00
Walter Goossens 8b58a519e4 korad-kaxxxxp: Add KA3005P v5.5
Signed-off-by: Walter Goossens <waltergoossens@creative-embedded.com>
2020-06-20 21:54:07 +02:00
Uwe Hermann 856433b26e Revert "bindings/ruby: Disable Ruby bindings until we have a fix for #1526."
This reverts commit 49d130200d.

The Ruby bindings build has been fixed now.
2020-06-20 18:09:51 +02:00
Anatol Pomozov 2e199405e5 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 <anatol.pomozov@gmail.com>
2020-06-20 18:09:27 +02:00
Wolfram Sang 35be304ba6 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 <wsa@kernel.org>
2020-06-13 23:55:34 +02:00
Florian Schmidt 3f48ab0282 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]
2020-06-08 23:49:29 +02:00
Uwe Hermann 36962abf53 udev: Add Kingst LA2016 VID/PID. 2020-06-07 00:48:29 +02:00
Uwe Hermann b2b6dd55ec kingst-la2016: Use ARRAY_SIZE. 2020-06-07 00:48:29 +02:00
Florian Schmidt f2cd2debf9 kingst-la2016: tested with idVendor=77a1, idProduct=01a2 2020-06-07 00:48:24 +02:00
Andreas Sandberg cae33a5874 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 <andreas@sandberg.pp.se>
2020-06-05 00:25:26 +02:00
Uwe Hermann 219c63ea1b src/crc.c: Add missing file. 2020-06-05 00:25:26 +02:00
Andreas Sandberg 4ea012bdf5 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 <andreas@sandberg.pp.se>
2020-06-05 00:25:26 +02:00
Andreas Sandberg 8b607a24e7 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 <andreas@sandberg.pp.se>
2020-06-05 00:25:26 +02:00
Uwe Hermann ef2196712c binary_helpers: Drop unnecessary malloc check.
(as per HACKING)
2020-06-05 00:25:26 +02:00
Andreas Sandberg 18698b40d1 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 <andreas@sandberg.pp.se>
2020-06-05 00:07:30 +02:00
Andreas Sandberg 0cc3d090b7 libsigrok.h: Add SR_MQ_ENERGY 2020-06-04 23:13:43 +02:00
Gerhard Sittig cbfaf5e073 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.
2020-06-01 18:35:05 +02:00
Gerhard Sittig ebc5110989 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.
2020-06-01 18:35:05 +02:00
Gerhard Sittig 3094e9d8ca uni-t-ut181a: Initial driver skeleton. 2020-06-01 18:35:05 +02:00
Gerhard Sittig 5cc292b34a 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.
2020-05-31 23:56:40 +02:00