Commit Graph

5564 Commits

Author SHA1 Message Date
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
Gerhard Sittig e092671365 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.
2020-05-31 23:56:16 +02:00
Gerhard Sittig f14e6f7e1a 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.
2020-05-31 23:53:42 +02:00
Gerhard Sittig debe1ff66d 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.
2020-05-31 23:52:24 +02:00
Gerhard Sittig 914f8160e7 asix-sigma: drop obsolete "trigger countdown" in sample interpretation
Recent commits added "position tracking" for interesting spots in the
sample stream and the current iteration pointer. Which obsoletes the
counters for remaining items until trigger, the "triggered here" flags,
as well as the unfortunate "rewind a little" workaround which lacked a
comment on its motivation or implementation details.
2020-05-31 23:51:23 +02:00
Gerhard Sittig 8a72362505 asix-sigma: re-enable software check for exact trigger position
The hardware provided trigger match location is inaccurate. Do check
sample values against the initial trigger condition spec for a short
range of the retrieved sample data, to refine the trigger marker's
position which is sent to the session feed.

Temporarily ignore the optional sample count limit for trigger-using
acquisitions, to reduce the diff size and simplify review. Since the
hardware transparently compresses sample data, we cannot reliably
determine where to start the download and interpretation of sample data,
and the submission to the session feed. Starting early in the sample
memory content, and sticking with the strict sample count limit, could
clip submission before the actual trigger position.

This implementation provides _at least_ the requested amount of data,
and does cover the spot of interest (the trigger position). This, and
the trigger support's having become operational again, is considered an
important improvement. The inaccuracy is considered acceptable for now.
Trigger-less acquisition does enforce the exact sample count limit.
2020-05-31 23:49:35 +02:00
Gerhard Sittig 66d1790cc0 asix-sigma: rephrase sample memory iteration position and trigger check
Rephrase how the sample memory iteration position gets tracked, increment
after every event slot already. Update the "last seen sample" status more
often (an event slot can hold several sample items). Arrange for a period
of time where software will check sample data for trigger matches. This
improves the precision of the hardware provided trigger match location.

Do send hardware provided trigger locations to the session feed even if
the software check found no match on the data content. This covers user
initiated button presses (which can unblock the acquisition when the
application provided trigger condition never matches).

Note that this implementation does manage the window of supervision, but
does not yet check the sample values against the trigger condition. This
gets added later.
2020-05-31 23:46:21 +02:00
Gerhard Sittig 16a5d5ac7d asix-sigma: rework outer sample download loop (DRAM lines iteration)
Factor USB data transfer out of the code path which interprets sample
memory content. Keep internal state of sample memory download in the
device context. This eliminates local variables, and ideally allows a
future implementation to spread chunked downloads across several read
callbacks, which would improve UI responsiveness.

Update comments while we are here. Address minor portability nits (ull
suffix vs UINT64_C macro). The inner loops (iterating clusters and their
events which contain individual samples) are not affected by this commit.
2020-05-31 23:45:29 +02:00
Gerhard Sittig 1385f791b0 asix-sigma: more trigger LUT download rephrase, think 16bit entities
Further rephrase the sigma_write_trigger_lut() routine. It's helpful to
"think" in BE16 quantities to improve readability of LUT address and
parameter downloads. Better matches the vendor's documentation. Also use
a better name for the "trigger select 2" register content.
2020-05-31 23:44:56 +02:00
Gerhard Sittig ee5cef7103 asix-sigma: concentrate more sample memory interpretation params
Start moving parameters into the device context which are related to the
interpretation of sample memory content. This can simplify error paths,
allow to release resources late. And ideally sample memory download and
interpretation could spread across several receive callbacks, improving
UI responsiveness. Also makes total and current dimensions available to
deeper nesting levels in the interpretation, which currently don't have
access to these details.
2020-05-31 23:44:29 +02:00
Gerhard Sittig de4c29fa91 asix-sigma: concentrate parameters for sample memory interpretation
Create a sub struct in the device context which keeps those parameters
which are related to sample memory interpretation. Which also obsoletes
the 'state' struct and only leaves the 'state' enum as a remainder.

Use the "samples per event" condition instead of the samplerate when
extracting a number of samples from an event's storage. Rename the
de-interleaving routines to better reflect their purpose.
2020-05-31 23:44:09 +02:00
Gerhard Sittig ea57157d0d asix-sigma: force strict boolen arith in LUT item manipulation
Mechanically adjust the add_trigger_function() routine to address nits,
attempt to improve maintainability.

Raise awareness of the fact that strict binary arithmetics is done (bit
operators are used), the strict 0..1 set of values needs to be enforced,
and mere "logical truthness" is not good enough in this spot. Explicitly
check for bit positions instead of "shifting out" the bit of interest
and have the 0/1 value result nearly by coincidence.

Extend comments. Group related instructions and separate them from other
groups. Reduce the scope of the rather generic i, j, tmp named variables
which are just too easy to get wrong.
2020-05-31 23:43:17 +02:00
Gerhard Sittig 3f5f548410 asix-sigma: use more helpers for bit mask creation
Rename macros to better reflect which of them check a bit position, and
which span a bit field of given width. Adjust more call sites to use the
macros. This takes tedium out of maintenance as well as review. Has the
minor benefit of somewhat shortening text lines, and eliminating nested
parentheses (or getting perceived as if it would).
2020-05-31 23:42:53 +02:00
Gerhard Sittig 156b6879e9 asix-sigma: rephrase limits management, use sub structure
Move the acquisition limits related variables into a sub struct within
the device context. Over time they became numerous, and might grow more
in the future.
2020-05-31 23:42:32 +02:00