Commit Graph

5403 Commits

Author SHA1 Message Date
Gerhard Sittig 72cd558d4a 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 47e7a6395e.
2020-08-17 19:07:37 +02:00
Gerhard Sittig 6dc0007c71 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 a0ade2f933.
2020-08-17 18:48:50 +02:00
Timo Kokkonen 4e5ff004d8 scpi_serial: Add GW-Instek GPD-9061 (USBCDC mode) VID/PID. 2020-08-17 18:35:17 +02:00
Timo Kokkonen 7eba792f0d udev: Add GW-Instek GDM-9061 VID/PID. 2020-08-17 18:35:17 +02:00
Timo Kokkonen 868fc65ec3 scpi-dmm: Add support for GW-Instek 906X series bench multimeters.
- Add support for GDM-9060 and GDM-9061 DMMs.
2020-08-17 18:35:17 +02:00
Timo Kokkonen d0b602f00f scpi-dmm: Add support for GW-Instek 8200A series bench multimeters.
- Add support for GDM-8251A and GDM-8255A DMMs.
2020-08-17 18:35:17 +02:00
Timo Kokkonen 47e7a6395e scpi: Support devices that omit serial number in *IDN? command responses. 2020-08-17 18:35:17 +02:00
Timo Kokkonen a0ade2f933 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.
2020-08-17 18:35:17 +02:00
Gerhard Sittig d7df9dc738 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.
2020-08-09 16:09:04 +02:00
Gerhard Sittig 4feb6ec9a2 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.
2020-08-05 21:03:11 +02:00
Earle F. Philhower, III 01ac3eedfa 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 <earlephilhower@yahoo.com>
[ gsi: rephrased commit message, how to reprodue ]
2020-08-05 20:53:57 +02:00
Timo Kokkonen b81cfbc349 gwinstek-gpd: Add missing SW limits API calls. 2020-08-03 18:54:33 +02:00
Gerhard Sittig d579755a66 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.
2020-08-03 17:53:11 +02:00
Gerhard Sittig 0dc27cd1db serial: make failed flush() in open() non-fatal, CP2110 flush() return
Commit cb828f1b3e 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.
2020-08-01 14:55:20 +02:00
Timo Kokkonen 13726d30b2 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.
2020-08-01 07:19:49 +02:00
Timo Kokkonen 3b316fdca0 gwinstek-gpd: Add support for GPD-3303S. 2020-07-31 14:28:38 +02:00
Gerhard Sittig dc172c38d2 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.
2020-07-31 11:25:29 +02:00
Gerhard Sittig 31907b76de 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
2020-07-31 10:39:50 +02:00
v1ne cc835205cd 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 ]
2020-07-31 10:30:22 +02:00
v1ne 3b93d3c24b 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 ]
2020-07-31 10:24:43 +02:00
v1ne f64f51b404 output/ascii: Remove unused variable 2020-07-31 10:24:26 +02:00
milan hauth 588295b8b9 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.
2020-07-28 17:07:22 +02:00
Gerhard Sittig 9dde746023 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.
2020-07-27 19:45:46 +02:00
Mike Walters 85cff5cfba scpi-dmm: Add Agilent 34410A. 2020-07-27 01:10:57 +01:00
Wolfram Sang cb828f1b3e 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 <wsa@kernel.org>
2020-07-26 16:06:42 +02:00
Gerhard Sittig 3b13990f7d 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.
2020-07-26 10:47:59 +02:00
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