Andreas Sandberg [Sun, 29 Sep 2019 21:48:52 +0000 (22:48 +0100)]
fluke-dmm: Cleanup Fluke 28x QM handling
The code that parses QM responses from Fluke 28x DMMs uses a long
series of if-else statements to determine the type of measurement
reported by the device. Rewrite this to use a conversion table that
contains a mapping between DMM units and Sigrok's internal units.
strutil: Add a helper to get the precision of a float
There are a few different instruments where the precision of a
measurement can be determined from the number of decimals in the
reported floats. Add a helper to determine this.
The implemented version of sr_count_digits performs more stringent
error checking than the original version in
sr_atod_ascii_digits. There are two reasons for this: First, we can no
longer rely on atod failing if the provided value is invalid. Second,
there are exotic float formats accepted by atod that we don't support
and we don't want to be in a situation where atod accepts a value and
count digits returns an incorrect value.
Marc Schink [Thu, 12 Sep 2024 12:18:20 +0000 (14:18 +0200)]
bindings/python: Use implicit namespaces
The use of 'namespace_packages' is deprecated [1] and for Python >= 3.3,
implicit/native namespaces should be used. There are no incompatibilities
as we require Python >= 3.8. More details can be found in [2] and [3].
Ralf [Thu, 22 Oct 2020 16:37:21 +0000 (18:37 +0200)]
rigol-dg: Add some more waveforms for MSO5000
Known issue: Read-back of parameters does not work.
Caused by changing :SOUR:APPL to :SOUR:FUNC, because APPL only
supports NOIS, PULS, RAMP, SIN, SQU, USER.
When MSO5000 is configured to a different waveform, there is no answer at all.
sr: [00:00.051760] scpi_vxi: Successfully sent SCPI command: 'SOUR1:APPL?'.
sr: [00:02.056361] scpi_vxi: Device read failed for 192.168.1.250 with error 15
g-user [Tue, 8 Feb 2022 21:24:32 +0000 (22:24 +0100)]
zeroplus-logic-cube: Add external clock settings
Enables the "external clock mode" in the Zeroplus LAP-C Logic
Cube driver (falling and rising edge) so that this mode also can be used in
sigrok-cli and pulseview
Mike McCauley [Tue, 28 Jun 2022 00:51:29 +0000 (10:51 +1000)]
serial-dmm: Add support for Digitech QM1576 serial protocol parser
The protocol is described at https://www.airspayce.com/mikem/QM1578/protocol.txt
You can use this decoder with libsigrok and Digitech QM1578 via ESP32 Bluetooth-Serial converter available from the author at: https://www.airspayce.com/mikem/QM1578/QM1578BluetoothClient.ino which connects to the QM1578 over Bluetooth LE, fetches the data stream and sends it on the serial port to the host, where this driver can read it with this command for example:
Ken Taylor [Sat, 7 Oct 2023 09:02:12 +0000 (02:02 -0700)]
openbench-logic-sniffer: Properly set samplerate range
Driver does query max_samplerate from SUMP metadata,
but previously replied to SR_CONF_SAMPLERATE with fixed
1Hz-200MHz range. Update to use max_samplerate as top
of range.
May fix http://sigrok.org/bugzilla/show_bug.cgi?id=1465
Some output modules, like srzip, calculate unitsize from maximum number of
channels in the session; and throw an error if the actual datastream uses
bigger size. Remove hardcoded value of 4 and calculate it from maximum number
of channels, supported by the device. Other driver seem to do the same.
This fixes "Unexpected unit size" saving a capture, made by an OLS device with
small number of channels.
The bug was found by using gillham's Arduino analyzer
(https://github.com/gillham/logic_analyzer), which supports a maximum of 8
channels. According to the error message, srzip expected unitsize == 1.
Marc Schink [Wed, 7 Feb 2024 15:15:31 +0000 (16:15 +0100)]
Add SR_CONF_INVERTED
Many device such as oscilloscopes, signal and delay generators are
capable to invert signals or change their polarity.
Add a new configuration to implement such a feature. The term 'inverted'
is chosen in favor of 'polarity' because the former can be unambiguously
represented by a boolean value.
Gerhard Sittig [Mon, 1 Jan 2024 13:37:50 +0000 (14:37 +0100)]
output/csv: use intermediate time_t var, silence compiler warning
There are platforms where timeval and time_t disagree on the width of
the data type of the field which holds seconds. Passing a pointer to an
unexpected type results in warnings (and probably unreliable execution).
Assign the value which is gotten from a timeval to an intermediate
time_t variable, so that the ctime() invocation becomes portable.
Properly use %zu for size_t, and %PRIu64 for uint64_t data types. This
silences build warnings which previously went unnoticed because their
occurance depends on the target platform.
Gerhard Sittig [Fri, 29 Dec 2023 11:39:05 +0000 (12:39 +0100)]
output/srzip: reduce text line length, remove "dead code"
Move an instruction to reduce its text line length. Also happens to put
the calculation of remaining buffer space and the current write position
in closer proximity, improving maintainability in the process.
Remove an assignment after appending to the archive and before iterating
the input samples loop again. Eliminates code that never took effect.
The value gets determined at the loop body's start anyway.
Gerhard Sittig [Fri, 29 Dec 2023 11:32:45 +0000 (12:32 +0100)]
output/srzip: accept arbitrary input and output unit sizes
Commit c03aaf342c3f introduced a check and refused to store sample data
when the feed would not exactly match an expected width that was derived
from the device's or input's total count of logic channels. Earlier
versions assumed the match but never checked (immediately forwarded
session feed content to the ZIP archive). Existing applications may not
be prepared to process the resulting archive where meta data and samples
disagree on essential properties. The fatal condition aborted execution,
which was perceived as a regression. A message was added later to
communicate that the condition was hit, but its WARN severity was
misleading, and its meaning still was obscure to users.
This commit extends the reception of sample data in the session feed and
its accumulation in the local buffer before ZIP archive appends. Any
combination of input and output unit sizes are accepted. It's perfectly
legal for sources to not communicate data for disabled channels, as well
as to communicate wider data images than strictly necessary to simplify
their support for a variety of input formats or device models. Details
are available to users at higher log levels (INFO). Default levels only
communicate fatal conditions (which should be implementation flaws now
exclusively).
The issue reproduces especially well with input formats that are rather
flexible, or device drivers which support a range of devices with many
configurations or models of differing capabilities. The issue was most
recently reported for the OLS driver and an Arduino SUMP firmware. Given
how many input modules and device drivers can feed into a few output
modules, it's assumed that addressing the general issue in a common
location is preferrable over local adjustment of individual input
modules or device drivers. Adjusting both places doesn't harm either,
increases overall robustness.
The implementation results in a negligable runtime overhead for the
regular case of matching unit sizes (a few integer checks). And an
acceptable overhead when the session feed is wider than the srzip
archive's unit size (multiple memcpy() calls where previously was only
one which would have been incorrect without the consistency check). The
code path which needs to apply padding to the output is most expensive,
but the implementation is only as expensive as it needs to be. The added
cost only occurs in the case of mismatches, which were not handled at
all before this change. The combination of extensive diagnostics and
internal consistency checks shall increase robustness and help during
future maintenance.
Gerhard Sittig [Fri, 29 Dec 2023 11:24:06 +0000 (12:24 +0100)]
output/srzip: rename variables for samples counts
The srzip output module deals with a number of samples that are of a
given width (unit size). Rename variables to better tell item counts
from byte counts. See a word diff for review.
Gerhard Sittig [Fri, 29 Dec 2023 11:17:31 +0000 (12:17 +0100)]
output/srzip: rename variable for archive unit size
The srzip output module needs to deal with two unit sizes. One that got
derived from the device's or input's logic channels' total count, and
will end up being used in the ZIP archive. And one which is seen when
the session feed provides sample data.
Rename the identifier to reflect this distinction. See a word diff for
the essence of the change.
Also rephrase the zip_append_queue() invocation for improved
readability. Use line breaks to illustrate parameter sets which are
related, and separate them from other parameters which are unrelated.
Gerhard Sittig [Thu, 21 Dec 2023 20:24:33 +0000 (21:24 +0100)]
greatfet: feed the session with constant width sample data
Rename identifiers to tell the sigrok session feed's width and the width
of sample data in device firmware communication apart. Always feed the
session with sample data of a width which corresponds to the device's
channels count. Some output modules and applications may not be prepared
to handle different cases.
Gerhard Sittig [Thu, 21 Dec 2023 20:22:43 +0000 (21:22 +0100)]
tests: adjust test coverage for power of two and input value 0
An input value 0 for the sr_next_power_of_two() routine is not invalid
any longer. Remove the test case that is expected to fail. Add a regular
case to cover that code path instead.
Gerhard Sittig [Thu, 21 Dec 2023 20:20:55 +0000 (21:20 +0100)]
strutil: support special case in power of two calculation
The sr_next_power_of_two() helper routine rejected input value 0
(an index), considered this case invalid. It is not, requires 1 bit
to hold the value. Return a "power of two" value of 1 for that input,
callers expect that result.
Gerhard Sittig [Mon, 27 Nov 2023 18:12:11 +0000 (19:12 +0100)]
hantek-dso: eliminate the "forced trigger" option value
Commit c93f113879a0 introduced a hack on top of an unfortunate choice.
It seems counter intuitive to open code a default trigger source on an
arbitrary channel, and have users override it with the "forced" value
to _not_ use a trigger.
The normal approach would be to specify a trigger when a trigger should
be used, and to not specify a trigger when no trigger should be used.
Eliminate the "forced" choice in the trigger_sources[] list. Start with
a not-set value. Accept when a value is specified (a "genuine" choice).
Don't bother adding support to "un-set" the previously specified choice.
This leaves the intuitive support for trigger specs that shall be used,
and only uses triggers when they were specified. Does not provide means
to "un-set" an earlier specified trigger config as the implementation
did before the 2023-09 change, which would be the 2021-02 status.
If the approach implemented here should be considered undesirable, then
a "none" option value should be introduced, something that much better
communicates to users what's happening and what the consequence of a
config choice would be.
This commit also adjusts the "ugh" code path which differed from the
"capture empty" code path. Fixes a resource leak in the config set path.
The "set trigger source" and "set trigger and samplerate" commands don't
agree on the phrase for the trigger source in the wire format. But have
been doing that before the forced trigger introduction, behaviour
remains unchanged here.
Gerhard Sittig [Sun, 29 Oct 2023 16:40:16 +0000 (17:40 +0100)]
greatfet: support capture of the upper pin bank (first pin 8)
Present all 16 channels to users. By default lower channels are enabled
and upper channels are disabled. Support the configuration where users
capture upper channels after disabling lower channels. Device firmware
provides the "first pin" feature and only communicates pin states for
the upper bank to the host.
This mode of operation can be useful to inspect different signal sets
without physically moving probes. Upper bank capture combines well with
higher rates at lower pin counts.
This implementation in theory also covers 16 channel captures, though
the firmware does not officially support multi-bank captures. Emit a
warning when this setup gets detected, but don't refuse operation and
attempt a best effort capture.
This commit also improves reliability in paths where failed acquisition
starts shutdown the operation, before another request gets serviced.
Gerhard Sittig [Sun, 29 Oct 2023 16:37:59 +0000 (17:37 +0100)]
greatfet: don't print misleading "unknown" libusb error text
Only lookup libusb error messages for negative return values which
communicate error codes. Positive return values are transmission counts
and are not an error.
The "UNKNOWN" messages only were seen at higher log levels. Users were
not affected by the issue.
Gerhard Sittig [Fri, 6 Oct 2023 16:09:58 +0000 (18:09 +0200)]
greatfet: first operational GreatFET One driver implementation
This sigrok driver for the GreatFET One device as a logic analyzer is
based on https://github.com/Qyriad/libsigrok and was massaged to use
common infrastructure where appropriate, and adjust coding style to
match the sigrok.org project's code base.
This implementation supports the acquisition of 8 channels at rates up
to 40.8MHz, and higher rates up to 204MHz for reduced channel counts.
Soft triggers are not supported in this implementation, ideally common
support would cover this more transparently in the future.
Tested with v2021.2.1 firmware as available via 'pip install greatfet'.
Support for 16 channels is prepared but disabled by default. Requires
firmware support which is not officially available.
Marek Vasut [Sat, 28 Oct 2023 07:12:48 +0000 (09:12 +0200)]
ols: Get GString content from proper API calls
Use the g_string_free() routine's return value instead of pulling the
string content out of the buffer structure bypassing the library's API.
This improves portability and readability, also happens to silence an
"ignoring return value" warning which is seen with GCC 13.2.0.
See https://docs.gtk.org/glib/method.String.free.html#return-value for
a discussion of the g_string_free() return value.
Gerhard Sittig [Tue, 17 Oct 2023 19:28:16 +0000 (21:28 +0200)]
output/srzip: decorate read pointer as const for awareness
Recipients of sample data as received from the data feed should consider
this data read-only, they are handed a reference to a message which is
also sent to other recipients.
Add the 'const' decoration in the output/srzip module to raise awareness
during future maintenance.
Gerhard Sittig [Tue, 17 Oct 2023 19:25:00 +0000 (21:25 +0200)]
yokogawa-dlm: silence compiler warning (passing an empty array)
Rephrase the config_list() routine such that it does not attempt to
access the first item in an empty array. Be explicit about the digital
channel group's devopts being empty by design, add a comment.
The compiler warning could have been a false positive, but phrasing the
source code differently doesn't harm either, eliminates uncertainty.
Gerhard Sittig [Tue, 17 Oct 2023 19:22:32 +0000 (21:22 +0200)]
tests: implement strutil test cases for power-of-two calculation
Add the "calc" section to the strutil tests, and implement test cases
which cover the power-of-two calculation routine. Cover small values
which are the immediate use case and the motivation for introducing the
helper routine.
Introduce the sr_next_power_of_two() routine which determines how many
bits are required to store a value. Decorate it as SR_API because some
applications may want it, but more importantly to make it available to
the test suite.
Gerhard Sittig [Sun, 15 Oct 2023 10:07:16 +0000 (12:07 +0200)]
juntek-jds6600: speedup serial communication, reduce timeouts
Wire traffic captures for serial-over-USB communication between the host
and the signal generator suggests that: Device firmware's reponses are
immediate. The 115200 UART is the limiting factor, USB FS adds little.
Comment on these findings for later reference. Reduce timeouts and
remove delays where appropriate. This dramatically speeds up the scan
for the device, and subsequent communication. Identification and getting
the current configuration takes a total of 70ms after this change.
Gerhard Sittig [Sun, 15 Oct 2023 08:31:15 +0000 (10:31 +0200)]
input/protocoldata: improve use of feed queue API
Improve feed queue related calls in the submission of capture start/end
idle phases, inter-frame idle phases, and bit time quanta of generated
protocol traffic. The submit-one API call accepts a repeat count which
eliminates caller's loops.
This also happens to eliminate a misguided yet harmless wrong use of the
feed queue API. An earlier implementation assumed "data pointer, and
data size" as arguments, and looped around that at the caller's. While
it's "data pointer, and repeat count". Used to work because sizeof(u8)
"was mistaken" as repeat count 1, so this flaw went unnoticed.
Propagate errors as they are seen, an earlier implementation silently
ignored them for frame payloads.
Gerhard Sittig [Sun, 15 Oct 2023 08:22:20 +0000 (10:22 +0200)]
feed_queue: add API to submit multiple sample values at once
Extend the common feed queue support API. Add a routine which accepts
multiple sample values that correspond to multiple sample points. This
eliminates the necessity for buffer handling and flush semantics at call
sites. And reduces overhead when callers previously had to submit one
sample value per API call when only single value submission existed.
Gerhard Sittig [Sun, 15 Oct 2023 08:08:11 +0000 (10:08 +0200)]
feed_queue: rename routines for submission of a single sample value
Common feed queue support originated from input module RLE compression.
Its API would accept a single sample value and optionally repeat that
value several times.
Rename the routines and its parameter for improved awareness. Adjust
existing callers: The asix-omega, atorch, kingst-la, rdtech-tc, and
rdtech-um acquisition device drivers, as well as the protocoldata,
stf, and vcd input modules.
Gerhard Sittig [Thu, 5 Oct 2023 16:11:18 +0000 (18:11 +0200)]
kingst-la2016: rephrase 'sdi' resource release during scan
Eliminate an incomplete local copy of sdi resource release code in an
error path of scan/probe. Use common code instead to free the sdi.
Assign opaque pointers to intermediate variables before passing their
values to other routines. Should slightly increase readability and
data type safety. Also close the USB handle if it's open at this time.
Gerhard Sittig [Mon, 2 Oct 2023 16:33:08 +0000 (18:33 +0200)]
bindings/python: rephrase for Python 3.9 deprecation (call API)
The PyEval_CallObject() routine was deprecated in Python 3.9, use
PyObject_CallObject() instead which has existed since at least 3.0.
There are also PyEval_InitThreads() deprecation warnings, but these
originate from SWIG generated code and are outside of our control.
Requires SWIG version 4.1 to silence these.
Address several robustness/reliability and style issues in the JDS6600
support code. Extend existing documentation to help future maintenance.
This work is based on review feedback that I received by user fenugrec
via IRC.
- Fix resource leaks in the scan/probe code path. Respond earlier to
failed communication during that startup phase after previous comms
worked.
- Adjust printf(3) format specifiers. Use more appropriate integer
formats for sr_atoul_base() results. "%lf" is not needed for doubles.
- More thorough argument checks at the start of routines. Be explicit
about narrow value ranges when wide data types are involved (function
code only uses a small part of the size typed variable's range).
- Quote example requests and responses in protocol.c so that readers can
match generating and processing code paths to wire traffic, without
having access to the device or its protocol description. Extend
diagnostics messages to optionally provide the full content of raw
communication, including the end-of-line condition and non-printables.
Regular sr_log() calls would strip these details, users could not
notice.
- Provide more comments on motivation and implementation details.
- Prettify the protocol.h context declaration. Put struct members on
their individual source code lines.
Gerhard Sittig [Thu, 28 Sep 2023 19:11:54 +0000 (21:11 +0200)]
zeroplus-logic-cube: address minor style nits
Prefer size types for indices and length specs. Separate function calls
from result inspection from flow control, to improve readability. Trim
text line length in complex expressions. Eliminate redundant data types
in malloc calls. Eliminate else after return. Remove dead code.
Gerhard Sittig [Thu, 28 Sep 2023 18:53:26 +0000 (20:53 +0200)]
zeroplus-logic-cube: move USB VID:PID check in scan before device access
Getting USB strings from faulty devices can be troublesome. Users report
segfaults when unrelated(!) devices get accessed during scan for certain
measurement devices.
Move the VID:PID check during scan before the USB string access. This
avoids access to unrelated devices.
Rephrase the check whether a USB device is a supported model. The
previous implementation's operation is questioned, the loop condition
looked suspicious.
Reported-By: Marek Antoniak <redacted> [the early check]
Gerhard Sittig [Thu, 28 Sep 2023 18:35:00 +0000 (20:35 +0200)]
chronovu-la: rephrase the USB vendor check during scan
Provide more information in the source code comment on the motivation to
only inspect a given USB VID during scan for ChronoVu LA devices. Use a
different identifier for the expected VID, the previous implementation
was rather misleading.
Gerhard Sittig [Thu, 28 Sep 2023 18:21:24 +0000 (20:21 +0200)]
chronovu-la: rephrase conn= checking in the scan routine
Prefer common support over DIY code to get the SR_CONF_CONN spec.
Simplify the check during USB enumeration whether a user provided
conn= spec applies. Sort local var decls to match their use. Setup
resulting 'devices' early.
Gerhard Sittig [Thu, 5 Oct 2023 15:21:07 +0000 (17:21 +0200)]
juntek-jds6600: implement device support, tested with Joy-IT JDS6600
Implement support for the essential signal generator part of the device,
tested with a 60MHz Joy-IT JDS6600 model: Two channels, enable/disable,
waveform, frequency, amplitude, offset, duty cycle selection, phase
between channels.
This version does not support external signals and frequency measurement
nor counting. Upload/download of arbitrary waveforms could work from the
serial communication's perspective, but sigrok lacks infrastructure/API
for waveform exchange or communication of blobs.
Tested with sigrok-cli and getters/setters. Quickly tested with SmuView.
Gerhard Sittig [Mon, 2 Oct 2023 16:34:30 +0000 (18:34 +0200)]
devantech-eth008: add more supported models, variable DI width, doc cleanup
Add support for differing DI (digital input) response sizes depending
on the model. Declare support for more models, including WIFI (their
feature set and protocol are identical, only their model ID differs).
Rework developer notes, keep the API slim and concentrate most stuff
in the implementation. Discuss USB CDC protocols and other potential
TODO items. Modbus most probably remains out of that driver's scope.
This implementation should cover most Ethernet (and Wifi) models, and
support their complete feature set from the sigrok perspective. The
most important limitation is missing support for channels' interaction
(when a pin can be any of AI and DI and DO).
Gerhard Sittig [Thu, 28 Sep 2023 10:49:12 +0000 (12:49 +0200)]
rdtech-dps: rephrase how model specific ranges are handled
Commit 02a4f485de76 implemented ranges support such that _all_ models
including every RD as well as DPS device announced ranges, it's just
that most of them happen to support a single range.
Use this fact, accept any zero based index, and drop the "normalization"
to strict 0/1 values except for one RD specific code path when getting
the current state of multi-range supporting devices. Tell models with
"effectively no ranges" from devices which "support multile ranges".
This shall increase robustness and improve maintainability. Simplifies
future extensions when more ranges are involved.
Gerhard Sittig [Thu, 28 Sep 2023 10:48:10 +0000 (12:48 +0200)]
rdtech-dps: clear the "acquisition started" condition
The 'acquisition_started' condition was set when the first acquisition
attempted to start, but was never cleared. Adjust error paths in the
acquisition start and the stop code path to update that variable.
Gerhard Sittig [Thu, 28 Sep 2023 10:40:48 +0000 (12:40 +0200)]
rdtech-dps: address simple style issues
Coding style nits: Use const data for model lists. Prefer size types.
Link sdi and devc immediately after allocation. Skip unused wire fields
by reading them too, avoid breaking the reviewer's flow.
Cosmetics, readability: Do place trailing commas in initializers. Reduce
text line length. Break long lines in more appropriate locations that
are more readable. Eliminate unmotivated pre-increment operators.