Commit Graph

5596 Commits

Author SHA1 Message Date
Gerhard Sittig 400bc4ffab dmm/bm52x: introduce support for Brymen BM525s
Introduce a bm52x DMM packet parser which is modelled after the bm86x
implementation, and hook it up to the serial-dmm driver. This supports
the live readings (real-time download) of the Brymen BM525s logging DMM.
The timing follows the vendor documentation (0.5s between requests, and
4.0s absolute timeout after request transmission). Reading previously
recorded data (memory data sets) unfortunately does not fit well into
the serial-dmm approach, and needs to get addressed differently later.
2020-09-19 12:52:41 +02:00
Gerhard Sittig abcb13855f serial-dmm: only do bytes to text conversion at higher log levels
Check the current log level before starting the potentially expensive
bytes to text conversion for a debug message (dump DMM packets).
2020-09-19 12:32:35 +02:00
Gerhard Sittig ce3fe37969 input/csv: provide double precision values to session feed
Common conversion support code accepts double precision input data for
analog packets. Use the 'double' data type in the CSV input module to
feed sample data to the session bus.
2020-09-18 16:42:37 +02:00
Gerhard Sittig e62b284c1c analog.c: rephrase analog feed to float conversion routine
Rephrase the sr_analog_to_float() routine to further reduce redundancy.

Check early for a match of the input data and result format, to grab the
raw data without conversion in that case. Handle optional scale/offset
calculation in that fast code path, too.

Unify the instructions which convert input data from either integer or
floating point presentations to the result format. Use common stream
readers to retrieve input data in several formats, which eliminates
local conversion buffers. Move common sub-expressions (scale/offset) out
of loops. Run more calculations on double precision data before results
get trimmed to single precision.

Add and extend comments to improve future maintenance. Include (terse)
details of unsupported input data presentations in error messages.

This implementation was neither tuned nor measured for performance.
There still is a lot of redundancy among the branches which handle a
specific input data type. Rephrasing that approach interacts with the
yet to be done performance tuning, thus needs to get addressed later.
The current phrases' verbosity is believed to improve readability.
2020-09-18 16:42:37 +02:00
Gerhard Sittig e4bcc63de6 libsigrok-internal.h: add more endianess aware stream reader routines
Add endianess aware readers including address incrementing variants for
those intrinsic data types which were missing in the previous version
yet are needed for sr_analog_to_float() adjustment.

Also move the 24bit reader to its position in the sort order.
2020-09-18 16:42:37 +02:00
Gerhard Sittig 6205515cc8 tests/analog: add more tests for analog feed to float array conversion
Extend test coverage for the sr_analog_to_float() conversion routine.
Pass data which is encoded in native, little and big endian format to
the routine. Pass single and double precision floating point data, and
integer data in different unit sizes and signedness. Cover scale/offset
calculations as well.

Also cover expected failed conversion for unsupported combinations of
input data format details (half/quad precision float, u64 integer).

Adjust the grouping of test cases in the sequence while we are here.
Move SI prefix, unit, and rational number related tests out of the
analog-to-float conversion group.
2020-09-18 16:42:37 +02:00
Timo Kokkonen f37f11ec6b analog.c: sr_analog_to_float(): Support for receiving double values.
Unbreak the conversion of input data in the floating point format when
the input data's format does not match the host's internal presentation,
thus grabbing raw data cannot be done.

Also accept the input data in double precision format which was not
supported before. Check for unsupported unit size values and emit an
error message similar to the integer code path.

This is motivated by bug #779 but does not resolve it. Adjusts common
conversion support, but sticks with single precision return data type
for API compatibility.
2020-09-18 16:42:37 +02:00
Jiri Slaby 505a55f789 tests: strutil, use ck_assert
We pass no message, so use ck_assert instead of ck_assert_msg. This
results in an error with check 0.15:
tests/strutil.c:157:2: error: too few arguments to function '_ck_assert_failed'
  157 |  ck_assert_msg(saved_locale != NULL);
2020-09-15 08:56:21 +02:00
Gerhard Sittig 5208214739 input/saleae: improve L2D undersampling, do provide sample data
The Saleae Logic exported files (Logic2 digital format) don't contain a
samplerate, so users need to specify the value. For values smaller than
the samplerate that was used during the capture undersampling will take
place. An implementation detail of the input module could result in
incorrect timing of sample values in the session feed. In extreme cases
none of the periods between signal edges qualified for submission. In
that case no sample data was sent to the sigrok session at all.

  $ sigrok-cli -i digital_1.bin -I saleae:samplerate=1000

Keep the very timestamp at hand when the last sample data was submitted.
Only advance that timestamp when more sample data was sent. This avoids
the accumulation of timing errors for undersampling scenarios, and does
forward undersampled input data when the user provided sample period has
passed.

This fixes bug #1600.
2020-09-02 19:52:44 +02:00
Gerhard Sittig 565c8c3545 korad-kaxxxxp: remove obsolete code (clear before read, timeout literal)
The korad response read routine clears the receive buffers, so callers
don't have to. This amends commit d2cc60bd45.

The acquisition timeout is handled by common sw_limits support. Remove
the no longer referenced literal. This amends commit 3f9b48ae5f.
2020-09-01 17:15:54 +02:00
Gerhard Sittig d2cc60bd45 korad-kaxxxxp: speed up scan process, rephrase response read routine
The Korad protocol relies on unterminated request and response strings,
which works well enough for fixed length acquisition and status queries.
But the variable length replies to identification requests suffered from
an implementation detail in the receive routine. A large timeout must be
used because supported devices reportedly are slow to respond. There is
no simple yet robust condition to detect the response's completion. The
scan code must prepare for the maximum response length across the set of
supported devices. Unfortunately the maximum amount of time was spent
waiting for the response to occupy the provided response buffer, before
a long total timeout expired.

Rework the korad driver's helper routine which gets a variable length
non-terminated text string. Keep the long initial timeout, and keep
iterating in that initial phase to quickly detect when response data
became available. But terminate the read sequence after a shorter period
without receive data after some initial receive data was seen. Assume
that identification responses get transferred at wire speed and without
additional delays beyond bitrate expectations. Acquisition and status
responses shall not be affected by this change.

This speeds up the scan for devices from roughly 5s to some 0.1s on
newer devices (KA3005P v5.5) and 0.5s on older devices (KA3005P V2.0).

This commit also addresses an issue in the response text termination,
where partial responses contained undefined data. The previous version's
return value was unspecific: Negative for fatal errors, but either zero
or non-zero for successful reads, with no way for callers to learn about
the received amount of data. The rephrased version always returns the
amount of received data, and adds internal documentation which discusses
the implementation's constraints and the motivation for the approach.

This is a modified version of the initial implementation which was
Submitted-By: Karl Palsson <karlp@tweak.net.au>
2020-09-01 17:11:36 +02:00
Gerhard Sittig fcacf532f5 korad-kaxxxxp: style cleanup in device scan, keep serno at hand
Cleanup style in the korad driver's scan() routine. Keep declarations
out of code blocks. Reduce redundancy and improve robustness in the
response buffer length calculation. Reduce clutter and group related
instructions together. Unobfuscate result checks, and keep the result
at hand (for diagnostics, or error propagation). Unobfuscate string
comparisons in the model ID lookups, terminate the search upon match.
Use a not so terse name for data that gets referenced at rather distant
locations.

Keep the optionally available serial number at hand, to present it to
users when desired. This aspect was
Reported-By: Karl Palsson <karlp@tweak.net.au>
2020-08-28 16:28:47 +02:00
Gerhard Sittig 003ad0ab8c input/saleae: keep previous channels across cleanup() call
The previous implementation of the cleanup() routine in the saleae input
module kept user specified options, but lost the previously created list
of sigrok channels. Keep it.

Also make sure that reset() voids the previous copy after grabbing its
value. To not unexpectedly release resources which still get referenced.

This shall unbreak file-reload.
2020-08-26 17:06:15 +02:00
Gerhard Sittig f403cb9de9 scpi-pps: use remote and local modes for HMP4000
Stop using the unusal "mixed" mode (local interface available during
remote operation) for HMP4000, applications may not be prepared for this
use case. Use traditional "remote" and "local" modes instead. This change
also ends remote mode after the application is done using the device.
2020-08-25 21:06:01 +02:00
Gerhard Sittig 22f76e188b scpi-pps: Add more HMP4000 series devices
List both vendor names "HAMEG" and "ROHDE&SCHWARZ" in the scpi-pps
driver, either responses were seen for HMP4000 devices. Unfortunately
vendor names don't support regex matches, so they require individual
profile items. The items also "violate" the alpha sort order in the list
of profiles, but keeping the series' models together is more important.

Add a declaration for the HMP4030 device which re-uses the HMP4040 data
but open codes the smaller channel count. Ideally the .probe_channels()
routine would receive the scpi_pps item as a parameter, and could yield
model specific result data from common information for the series. The
implementation in this commit is the least intrusive approach until
something better becomes available.

This shall cover the whole HMP4000 series:
  https://www.rohde-schwarz.com/product/hmp4000
2020-08-25 20:59:31 +02:00
Florian Schmidt bd5f0a143e scpi-pps: add support for Hameg / Rohde & Schwarz HMP4040
This commit introduces initial support for the HMP4040 power supply by
Rohde & Schwarz. It allows to configure the device and "statically" read
back current state. Automatic status updates with per-channel details
are not available yet (common support is missing).

[ gsi: drop status update remainder, address minor style nits ]
2020-08-25 20:58:54 +02:00
Gerhard Sittig 24a953382c doc: update README.devices for GWInstek VCP (CP210x in disguise)
Reference the vendor's Windows specific "driver" download for the
CP210x chip with a non-default VID:PID. Provide an example how to
assign the Linux driver to that device (interactive, no udev rule).
2020-08-25 19:38:23 +02:00
Gerhard Sittig f91c6940ab scpi_serial: add "GWInstek VCP" (PID 0x0030) as seen in GDM-834x 2020-08-25 19:38:23 +02:00
Gerhard Sittig 395c1850b7 scpi-dmm: factor out some OL detection limits
Prepare the "plus/minus infinity" checks for OL conditions to use
model dependent limits. This commit does not change behaviour.
2020-08-25 19:38:23 +02:00
Gerhard Sittig 7d95afb9be scpi-dmm: add SR_CONF_CONN getter
Add config_get() support for conn= specs. This is a best-effort approach.
Failure to get the SCPI connection text is non-fatal during probe.
2020-08-25 19:38:23 +02:00
v1ne 6f9234e6f3 ols: Detect Demon Core, use its canonic command names
Document Demon Core commands and associated metadata magic numbers.
See http://web.archive.org/web/20190317154112/
http://mygizmos.org/ols/Logic-Sniffer-FPGA-Spec.pdf for documentation.

Detect the Demon Core presence, use more symbolic names in related
code paths to eliminate magic numbers, switch to their canonic names.

Reviewed-By: Wolfram Sang <wsa@kernel.org>
2020-08-24 07:57:13 +02:00
v1ne 2755ab36f3 ols: Refactor, deduplicate logic packet code
Reviewed-By: Wolfram Sang <wsa@kernel.org>
2020-08-24 07:57:06 +02:00
v1ne dcdc2848b7 ols: Use symbolic name for "success" error code.
Reviewed-By: Wolfram Sang <wsa@kernel.org>
2020-08-24 07:43:03 +02:00
v1ne 58a75642e9 ols: Make constant names more precise, clarify comment
Reviewed-By: Wolfram Sang <wsa@kernel.org>
2020-08-24 07:33:13 +02:00
v1ne a80bed7656 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 <wsa@kernel.org>
2020-08-24 07:29:03 +02:00
v1ne a2b1a53bb4 ols: Symbolic name for magic value, reflect units in variable names
Reviewed-By: Wolfram Sang <wsa@kernel.org>
2020-08-24 07:26:43 +02:00
v1ne f1a37f3924 ols: Remove stray command
It's nowhere documented and nowhere used.

Reviewed-By: Wolfram Sang <wsa@kernel.org>
2020-08-24 07:26:01 +02:00
v1ne 0ccc6f7cdf ols: Make use of zero-initialization.
No need to assign zero after gmalloc0(). Move comments to declaration.

Reviewed-By: Wolfram Sang <wsa@kernel.org>
2020-08-24 07:24:27 +02:00
Frank Stettner b54d9b4974 libsigrok.h: Fix comment for unit Joule. 2020-08-23 13:10:00 +02:00
Frank Stettner fe8c5aef1f libsigrok.h: Add Joule, Coulomb, and Ah units.
Also extend a comment on energy in comparison to power.
2020-08-22 21:53:56 +02:00
Frank Stettner 82ff704449 libsigrok.h: Add MQ for electric charge. 2020-08-22 21:53:56 +02:00
Frank Stettner f5247d953f teleinfo: Fix measured quantity (energy, not power). 2020-08-22 21:53:39 +02:00
Gerhard Sittig 98b7b08956 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.
2020-08-22 19:04:31 +02:00
Gerhard Sittig ce384e074f 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.
2020-08-22 19:00:05 +02:00
Timo Kokkonen 66665b0932 README.devices: Document enabling GW Instek GDM-397 serial output mode. 2020-08-22 09:10:42 +02:00
Timo Kokkonen a3ec8a9aa1 serial-dmm: Add GW Instek GDM-397 meter support.
This meter appears to be rebranded UNI-T UT61B, but with
improved input protection.
2020-08-22 09:10:42 +02:00
Gerhard Sittig e37e301e26 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
2020-08-22 09:10:29 +02:00
Gerhard Sittig d643e6bc39 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.
2020-08-22 09:10:29 +02:00
Gerhard Sittig 048250d0e0 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
  ...
2020-08-22 09:10:29 +02:00
Timo Kokkonen 860ee00ab1 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.
2020-08-20 12:48:13 -07:00
Timo Kokkonen 4c80a27284 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.
2020-08-20 12:48:00 -07:00
Gerhard Sittig 25879a34e9 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.
2020-08-17 20:32:08 +02:00
Gerhard Sittig 33aa8117e3 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.
2020-08-17 20:01:02 +02:00
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