]> sigrok.org Git - libsigrok.git/log
libsigrok.git
7 months agordtech-dps: clear the "acquisition started" condition
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.

7 months agordtech-dps: address simple style issues
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.

7 months agordtech-dps: undo undesired register re-read logic change
Gerhard Sittig [Thu, 28 Sep 2023 10:37:51 +0000 (12:37 +0200)]
rdtech-dps: undo undesired register re-read logic change

Commit 02a4f485de76 snuck in a change that should not have gone there.
Revert the logic which re-reads Modbus registers several times before
declaring failure. Use the previous implementation as intended.

7 months agordtech-dps: touch up comments
Gerhard Sittig [Thu, 28 Sep 2023 10:30:05 +0000 (12:30 +0200)]
rdtech-dps: touch up comments

Address style issues in comments. Extend and rephrase some for improved
readability and awareness during maintenance. Move comments to before
the code which they relate to.

7 months agordtech-dps: adjust header includes (config.h is not a system header)
Gerhard Sittig [Thu, 28 Sep 2023 10:28:50 +0000 (12:28 +0200)]
rdtech-dps: adjust header includes (config.h is not a system header)

7 months agohameg-hmo: separate RTH002 and RTH004 model declarations
Gerhard Sittig [Thu, 28 Sep 2023 10:22:01 +0000 (12:22 +0200)]
hameg-hmo: separate RTH002 and RTH004 model declarations

Commit 10e6dfd1f921 introduced differing trigger sources for RTH1002 and
RTH1004, but shared a single scope_models[] entry with identical data for
both devices.

Use separate scope_models[] entries for RTH1002 and RTH1004, reference
their respective capabilities which differ among models.

Move the RTH1004 trigger sources next to RT1002, the declarations appear
to not assume a specific order anyway.

7 months agordtech-dps: Prevent null pointer exception
Soeren Apel [Thu, 28 Sep 2023 10:18:30 +0000 (12:18 +0200)]
rdtech-dps: Prevent null pointer exception

7 months agochronovu-la: Add checking of VendorId
Marek Antoniak [Fri, 3 Dec 2021 12:50:21 +0000 (13:50 +0100)]
chronovu-la: Add checking of VendorId

7 months agohameg-hmo: Add support for R&S RTH100x
xandinator [Sat, 12 Feb 2022 23:45:56 +0000 (00:45 +0100)]
hameg-hmo: Add support for R&S RTH100x

7 months agohantek-dso: add "forced" trigger source
Miroslav Sustek [Tue, 19 Apr 2022 18:47:40 +0000 (20:47 +0200)]
hantek-dso: add "forced" trigger source

This special trigger source mimics the trigger mode that is called
"Auto" in the original Hantek's "DSO2090 Software" and in
https://github.com/OpenHantek/OpenHantek6022 open-source project.
In the original https://github.com/OpenHantek/openhantek open-source
project the trigger mode is called "Wait/Force".

This feature can be used to immediately capture a single frame.
Example usage with sigrok-cli:
```
sigrok-cli --driver hantek-dso --frames 1 --config triggersource=forced
```

This enables us to use the oscilloscope for data logging in scripts.

Only after I implemented this I realized that if you have an extra probe,
you can set the triggersource to "EXT" and connect the EXT input
to the 1kHz calibration signal output on the back of the device
and that will trigger every millisecond. However, I still think that
the "forced" trigger source can be useful.

7 months agocontrib/60-libsigrok.rules: Add other Saleae devices.
Petr Hodina [Tue, 9 Aug 2022 07:46:29 +0000 (09:46 +0200)]
contrib/60-libsigrok.rules: Add other Saleae devices.

These PIDs and VIDs are based on udev rules from Logic 2 app. I can confirm the
one for Saleae Logic Pro 8.

7 months agoagilent-dmm: Fix compatibility with Agilent U1242A
Alex Hornung [Fri, 9 Sep 2022 13:56:05 +0000 (14:56 +0100)]
agilent-dmm: Fix compatibility with Agilent U1242A

The U1242A sends conf responses as follows,

    CONF? response '"VOLT +1.000000E+00,+1.000000E-04"

    CONF? response '"TEMP:ENV CEL"'

So update the regex patterns to cope with these.

7 months agodmm/bm??x: Add Wayback Machine links to brymen documentation
François Revol [Tue, 27 Sep 2022 22:58:06 +0000 (00:58 +0200)]
dmm/bm??x: Add Wayback Machine links to brymen documentation

7 months agordtech-dps: add support for RD6006P, RD6012P and RD6024
Mikael Djurfeldt [Mon, 16 Jan 2023 22:43:44 +0000 (23:43 +0100)]
rdtech-dps: add support for RD6006P, RD6012P and RD6024

RD6012P has two current ranges, so support for getting/setting/listing
range is added. This also means that the model table is reorganized to
support multiple ranges.

In order for the range setting and the current multiplier to be up to
date, the function rdtech_dps_update_range is called when
required. This function reads the range register of the device.

7 months agorigol-ds: Fix #1831 by supporting DS1xxxZ Plus & RPL1116 logic ports
AristarchosOfSamos [Thu, 16 Mar 2023 08:20:14 +0000 (10:20 +0200)]
rigol-ds: Fix #1831 by supporting DS1xxxZ Plus & RPL1116 logic ports

The DS1xxxZ Plus models are MSO ready, they contain the connector to attach a RPL1116 16 port digital head.
Having a DS1xxxZ Plus and a connected RPL1116 effectively the instrument becomes a MSO1xxxZ.

But that "CH_INFO(4, false)" means 4 analog channels and NO digital channels.
As said though, the DS1xxxZ Plus variants got the D0..D15 digital ports abilities already so this line treats the DS1xxxZ Plus as a plain DS1xxxZ without the digital ports.

A very simple remedy is to change the CH_INFO(4, false) to CH_INFO(4, true)
So those two lines should be changed
from
{SERIES(DS1000Z), "DS1074Z Plus", {5, 1000000000}, CH_INFO(4, false), std_cmd},
{SERIES(DS1000Z), "DS1104Z Plus", {5, 1000000000}, CH_INFO(4, false), std_cmd},
to
{SERIES(DS1000Z), "DS1074Z Plus", {5, 1000000000}, CH_INFO(4, true), std_cmd},
{SERIES(DS1000Z), "DS1104Z Plus", {5, 1000000000}, CH_INFO(4, true), std_cmd},
and the problem will be solved.

7 months agoscpi-pps: Add support for OWON SPE6103
Sahaj Sarup [Sun, 27 Aug 2023 05:56:14 +0000 (11:26 +0530)]
scpi-pps: Add support for OWON SPE6103

Signed-off-by: Sahaj Sarup <redacted>
7 months agoscpi-dmm: add support for OWON XDM1041
Sahaj Sarup [Sun, 27 Aug 2023 11:00:47 +0000 (16:30 +0530)]
scpi-dmm: add support for OWON XDM1041

Signed-off-by: Sahaj Sarup <redacted>
7 months agoraspberrypi-pico: protocol.c cleanup
Soeren Apel [Wed, 27 Sep 2023 20:48:47 +0000 (22:48 +0200)]
raspberrypi-pico: protocol.c cleanup

7 months agoraspberrypi-pico: protocol.h cleanup
Soeren Apel [Wed, 27 Sep 2023 19:44:42 +0000 (21:44 +0200)]
raspberrypi-pico: protocol.h cleanup

7 months agoraspberrypi-pico: api.c cleanup
Soeren Apel [Wed, 27 Sep 2023 19:38:20 +0000 (21:38 +0200)]
raspberrypi-pico: api.c cleanup

7 months agoraspberrypi-pico: Change %llu to %lu where needed
Soeren Apel [Wed, 27 Sep 2023 17:53:12 +0000 (19:53 +0200)]
raspberrypi-pico: Change %llu to %lu where needed

7 months agoraspberrypi-pico: Formatting; support force_detect, analog sizes
AC0BI [Fri, 13 Jan 2023 14:36:44 +0000 (07:36 -0700)]
raspberrypi-pico: Formatting; support force_detect, analog sizes

7 months agoraspberrypi-pico: Comment clean up, support a more general use case model
AC0BI [Tue, 20 Dec 2022 16:54:26 +0000 (09:54 -0700)]
raspberrypi-pico: Comment clean up, support a more general use case model

7 months agoraspberrypi-pico: Rev2 updates
AC0BI [Wed, 13 Apr 2022 03:26:42 +0000 (21:26 -0600)]
raspberrypi-pico: Rev2 updates

7 months agoraspberrypi-pico: Fix serial comm parameters
pico-coder [Mon, 14 Mar 2022 20:57:21 +0000 (14:57 -0600)]
raspberrypi-pico: Fix serial comm parameters

7 months agoraspberrypi-pico: Cleanup whitespace, add a serial_close to api.c scan function
AC0BI [Wed, 2 Mar 2022 04:44:26 +0000 (21:44 -0700)]
raspberrypi-pico: Cleanup whitespace, add a serial_close to api.c scan function

7 months agoraspberrypi-pico: First release of raspberry pi pico driver code
AC0BI [Tue, 1 Mar 2022 15:31:43 +0000 (08:31 -0700)]
raspberrypi-pico: First release of raspberry pi pico driver code

7 months agoraspberrypi-pico: Initial driver skeleton.
AC0BI [Tue, 1 Mar 2022 04:22:47 +0000 (21:22 -0700)]
raspberrypi-pico: Initial driver skeleton.

7 months agorigol-ds: Add DS4014
ldashing [Thu, 20 Jul 2023 21:35:56 +0000 (23:35 +0200)]
rigol-ds: Add DS4014

7 months agotcp: check for poll(2) and select(2), workaround for shutdown(2) API
Gerhard Sittig [Wed, 27 Sep 2023 15:15:02 +0000 (17:15 +0200)]
tcp: check for poll(2) and select(2), workaround for shutdown(2) API

The poll(2) API is not universally available. Check for its presence
before referencing it. Fallback to select(2) in its absence. Check for
the availability of select(2) as well. If neither is available, there
is no (portable) way of checking a file descriptor's readability.

The SHUT_RDWR identifier is not available in winsock. But a different
symbol with identical meaning is available. Use it as a fallback.

This amends commit fcab496c12b2 which introduced common TCP support.

7 months agodevantech-eth008: make request for digital output optional
Gerhard Sittig [Mon, 25 Sep 2023 12:38:58 +0000 (14:38 +0200)]
devantech-eth008: make request for digital output optional

This is for consistency with other optional features like digital input
and analog input. Only transmit digital output related requests to the
firmware when the model supports it.

See whitespace ignoring diff for the essence.

7 months agodevantech-eth008: support digital and analog input channels
Gerhard Sittig [Mon, 25 Sep 2023 12:28:59 +0000 (14:28 +0200)]
devantech-eth008: support digital and analog input channels

Implement support for digital input and analog input on those models
which provide these features beyond digital output (relays).

This was written without access to the hardware, and is untested.

This completes support for the cards' features. Other models (ETH1610)
could get added when their model ID is known. WLAN enabled cards are
assumed to share model IDs with their Ethernet counterparts.

7 months agodevantech-eth008: declare more models, still digital-output only
Gerhard Sittig [Mon, 25 Sep 2023 12:18:55 +0000 (14:18 +0200)]
devantech-eth008: declare more models, still digital-output only

Add the ETH002, ETH484, and ETH8020 items to the list of supported
models. Adjust driver code paths for the differing DO image sizes of
these models (up to 20 relays which span up to three bytes width).
Support the R5..R8 gap for ETH484.

This was written without access to the hardware, and is untested.

7 months agodevantech-eth008: first driver implementation, relay output only
Gerhard Sittig [Sun, 24 Sep 2023 09:05:08 +0000 (11:05 +0200)]
devantech-eth008: first driver implementation, relay output only

Implement common support code to communicate raw binary requests and
responses over TCP sockets, and ETH008 specific requests to control
up to 8 relays as well as getting the card's supply voltage.

Other cards with differing channel counts, and with features beyond
relay control, have not been available during creation of this driver.
Their addition is prepared but untested. Password protection is not
implemented, but outlined in developer comments.

7 months agodevantech-eth008: Initial driver skeleton.
Gerhard Sittig [Sun, 24 Sep 2023 09:04:44 +0000 (11:04 +0200)]
devantech-eth008: Initial driver skeleton.

7 months agoserial: introduce support for raw TCP communication (send/recv bytes)
Gerhard Sittig [Sun, 24 Sep 2023 08:27:31 +0000 (10:27 +0200)]
serial: introduce support for raw TCP communication (send/recv bytes)

Add support for "conn=tcp-raw/<ip>/<port>" specs for serial transports.
This is consistent with previously existing SCPI transports, and is
compatible because there has not been TCP communication outside of SCPI
so far.

This implementation supports blocking mode and attempts to communicate
the very caller specified amount of data. Also suports non-blocking mode
and read timeouts, which can result in short reads.

Support for source add/remove exists, so that receive callbacks can
execute when receive data has become available. Other serial transport
methods are missing. There is no support for bitrate configuration,
flow control, flushing, UART frame formats, etc.

7 months agoscpi_tcp: use common TCP support in SCPI transport (tcp-raw, tcp-rigol)
Gerhard Sittig [Sun, 24 Sep 2023 08:42:00 +0000 (10:42 +0200)]
scpi_tcp: use common TCP support in SCPI transport (tcp-raw, tcp-rigol)

Use the recently added sr_tcp_dev_inst approach to TCP communication in
the tcp-raw and tcp-rigol SCPI transports. Eliminates redundancy in the
implementation.

Address style nits in the process: Use size types for length specs. Be
explicit about bytes and character conversions: Bytes are sent across
the TCP socket, while SCPI exchange typically involves text messages.
The previously used send(2) and recv(2) calls just passed void pointers.

Comment on the specific semantics of Rigol length specs that preceed the
response data. And how raw TCP attempts to determine the completion of a
reception while this length spec is absent. The previous implementation
would not reveal the motivation of this non-trivial logic.

7 months agotcp: introduce common support code for TCP socket communication
Gerhard Sittig [Sun, 24 Sep 2023 08:23:15 +0000 (10:23 +0200)]
tcp: introduce common support code for TCP socket communication

It appears that so far only SCPI and the Beagleboard have supported
communication across TCP sockets. And both have locally open coded
the corresponding logic.

Introduce common support for TCP communication. This implementation
provides simple new/free, connect/disconnect, read/write (including
non-blocking reads), source add/remove calls, and keeps the API under
the sr_tcp_ prefix.

This commit introduces common code, but does not adjust callers.

9 months agoinput/protocoldata: also accept comma separated data values
Gerhard Sittig [Sun, 30 Jul 2023 08:10:12 +0000 (10:10 +0200)]
input/protocoldata: also accept comma separated data values

Frame format specs in the header section accepted space and comma
separators already (though comma separated frame format details are
considered unusual). Protocol values in non-comment (text mode) lines
assumed strictly space separated fields.

Accept comma and semicolon too as data value separators for maximum user
convenience. Simplifies the import of post processed other text formats,
only requires the addition of headers and decoration (select control,
text to number conversion base), but allows re-use of all existing
values. Reduces diffs before and after manipulating original text into
protocoldata which sigrok can import.

These separators silently get ignored. They don't have a meaning in the
sense of interpreting "1, , 3" as three values. There is no concept of
empty fields in the sequence of data values. This is pure convenience.

9 months agoinput/protocoldata: reduce inter-frame gap for I2C waveforms
Gerhard Sittig [Thu, 13 Jul 2023 17:30:02 +0000 (19:30 +0200)]
input/protocoldata: reduce inter-frame gap for I2C waveforms

Space I2C data bytes the same as address bytes are spaced. Results in a
graphical presentation that is easier to inspect, and is less wasteful
at the same time (more data is seen at the same zoom level).

9 months agoinput: alpha-sort list of known input modules
Gerhard Sittig [Sun, 25 Jun 2023 21:53:44 +0000 (23:53 +0200)]
input: alpha-sort list of known input modules

Sort the 'extern' declarations and the input_module_list[] array items.
Does not change behaviour, just simplifies maintenance.

9 months agoinput/protocoldata: add input module for "protocol values" files
Gerhard Sittig [Tue, 14 May 2019 19:27:18 +0000 (21:27 +0200)]
input/protocoldata: add input module for "protocol values" files

Implement an input module which accepts data values that may have been
gotten by arbitrary means (external capture utility, synthesized data),
and creates logic traces which mimic the respective protocol's format.
This pretends that a logic capture had been taken by sigrok means, which
can be fed to protocol decoders. The motivation is neither to perfectly
simulate a given protocol, nor to inject arbitrary error conditions and
edge cases, but instead to make externally provided data available to
sigrok protocol decoders.

The input module supports several user servicable options to describe
raw files which exclusively contain data bytes. Optional automatic file
format detection is also supported, as is an optional file header to
embed protocol properties with the bytes stream. Text formatted input
is supported as a strict alternative to raw data bytes, also supporting
comments as well as pseudo comments. The latter carry instructions to
control some aspects that are outside of the mere stream of data bytes.
Some protocols may exclusively be useful in combination with text input.

Protocol specific handlers can generate up to eight logic channels, an
arbitrary number of bits per protocol frame, including varying bit times
within a frame, and several quanta per bit time. It is assumed that this
implementation provides enough infrastructure to mimic an arbitrary set
of protocols beyond the initially supported set of UART, SPI, and I2C.

9 months agoinput/vcd: use common helpers for text lines/words splitting
Gerhard Sittig [Tue, 4 Jul 2023 16:40:19 +0000 (18:40 +0200)]
input/vcd: use common helpers for text lines/words splitting

Use recently added strutil helpers which isolate text lines in receive
buffers and which locate whitespace separated words on text lines. This
simplifies the processing of the data section of VCD input files.

It's essential to _not_ use these helpers when the receive buffer must
not get manipulated, like in file format matches, or when control data
sections span multiple text lines. Update comments to raise awareness.

9 months agotests: implement strutil tests for text line and word splitting
Gerhard Sittig [Sun, 2 Jul 2023 07:48:57 +0000 (09:48 +0200)]
tests: implement strutil tests for text line and word splitting

Add the test_text_line() and test_text_word() routines to cover the
splitting of text buffers into lines and the splitting of words on a
text line.

This implementation "suffers" from global vars at the file scope,
because moving the table of test cases into the test routine results in
compiler errors (initializer data not constant), the cause is uncertain.

9 months agostrutil: add common helpers for input text parsing (lines, words)
Gerhard Sittig [Sun, 2 Jul 2023 07:39:39 +0000 (09:39 +0200)]
strutil: add common helpers for input text parsing (lines, words)

Introduce the sr_text_next_line() and sr_text_next_word() routines which
split an input buffer into text lines and identify whitespace separated
words on a text line. Several input modules redundantly implement this,
having common support is desirable.

9 months agotests: raise maximum version text length (dirty flag)
Gerhard Sittig [Sun, 2 Jul 2023 07:20:49 +0000 (09:20 +0200)]
tests: raise maximum version text length (dirty flag)

The previous implementation of the version text length check accounted
for the major, minor, micro numbers and the git hash. Raise the upper
limit of the accepted text length range to also account for the optional
"dirty" flag. Update comments to keep awareness of the magic numbers in
the length calculation.

9 months agostrutil: accept 0b prefix when base is 2 (which is non-zero)
Gerhard Sittig [Sun, 25 Jun 2023 20:47:47 +0000 (22:47 +0200)]
strutil: accept 0b prefix when base is 2 (which is non-zero)

The sr_atoul_base() conversion routine only accepted the 0b binary
prefix when base was 0. Extend this to also accept the 0b prefix when
the caller specified base is 2. This unbreaks a valid use case.

12 months agoatorch: Implement support for DC and USB Meters
Mathieu Pilato [Sat, 4 Mar 2023 17:18:46 +0000 (18:18 +0100)]
atorch: Implement support for DC and USB Meters

Tested with ATORCH J7-c USB Meter and ATORCH DL24MP-150W Purple Electronic Load

12 months agoatorch: Initial driver skeleton
Mathieu Pilato [Sat, 4 Mar 2023 17:18:39 +0000 (18:18 +0100)]
atorch: Initial driver skeleton

12 months agobinary_helpers: remove unused u64 and float variants (dead code)
Gerhard Sittig [Sun, 30 Apr 2023 09:02:47 +0000 (11:02 +0200)]
binary_helpers: remove unused u64 and float variants (dead code)

Remove support for uint64_t and float data types in the extraction of
number values from byte streams. These are unused in current mainline.
The larger types even don't fit in the single precision result, the
32bit integer already suffers from precision loss during conversion
to float.

12 months agobinary_helpers: Add bv_get_value function.
Mathieu Pilato [Fri, 31 Mar 2023 08:09:12 +0000 (10:09 +0200)]
binary_helpers: Add bv_get_value function.

12 months agobinary_helpers: Rename bv_get_value to reflect it's length checking
Mathieu Pilato [Fri, 31 Mar 2023 08:02:20 +0000 (10:02 +0200)]
binary_helpers: Rename bv_get_value to reflect it's length checking

Rename the bv_get_value() routine to bv_get_value_len() to better reflect
that this implementation checks the input data image's length. A version
which doesn't check length will get introduced soon.

[ gsi: use a shorter name than in the initial submission ]

12 months agobinary_helpers: Reflect that bv_get_value() takes bytes as input
Mathieu Pilato [Fri, 31 Mar 2023 20:04:05 +0000 (22:04 +0200)]
binary_helpers: Reflect that bv_get_value() takes bytes as input

Prefer uint8_t pointers over void pointers in the bv_get_value()
signature for improved awareness.

12 months agobinary_helpers: Add support for 24 bits wide integers.
Mathieu Pilato [Fri, 31 Mar 2023 07:59:11 +0000 (09:59 +0200)]
binary_helpers: Add support for 24 bits wide integers.

12 months agolibsigrok-internal.h: Add read_u24be helper function
Mathieu Pilato [Fri, 31 Mar 2023 19:59:15 +0000 (21:59 +0200)]
libsigrok-internal.h: Add read_u24be helper function

12 months agomake: move version suffix gathering from configure to compile time
Gerhard Sittig [Sat, 18 Mar 2023 16:18:15 +0000 (17:18 +0100)]
make: move version suffix gathering from configure to compile time

Check at configure time whether version control is available. Determine
at configure time which branch is being worked on, and re-configure when
the branch changes. Append "-git" to the package version when the source
tree is not tagged at configure time.

Get revision numbers and the dirty flag at compile time. Check whether
the source code revision exactly matches a tag at compile time. Derive
the version suffix from these details. Generate a git-version.h header
file which only the version.c source file references.

This embeds detailled version information into the library, where it is
available at runtime for the library and for applications. And severely
speeds up development iterations by avoiding full rebuilds of the whole
library when a git commit happened. The dirty flag may either require a
manual reconfiguration, or 'make version-clean', if that workspace state
is not automatically picked up. Which is considered acceptable for now,
because builds for distribution should always start with the configure
phase anyway. This uncertainty could only get avoided at the cost of
always creating the git-version.h header file in every build invocation.
Which would be easy to achieve, but remains for a future commit.

The approach was outlined by Martin Ling in 2018-09, see bug #1283. This
implementation additionally handles out-of-source builds, uses positive
logic for the header inclusion, and handles distribution builds from
tarballs or other non-versioned sources (assumes an empty suffix then).
Could also handle other sources of version details, or alternative VCS
implementations, thus passes more variables than strictly necessary from
configuration to compilation.

12 months agomicrochip-pickit2: support user assigned channel names at probe time
Gerhard Sittig [Sun, 9 Apr 2023 08:02:49 +0000 (10:02 +0200)]
microchip-pickit2: support user assigned channel names at probe time

Allow users to assign channel names at probe time already. Add support
for the SR_CONF_PROBE_NAMES scan option. Improves usability.

  $ sigrok-cli -d microchip-pickit2:probe_names=spi --samples 1024

12 months agomicrochip-pickit2: move channel creation to after device context alloc
Gerhard Sittig [Sun, 9 Apr 2023 08:00:34 +0000 (10:00 +0200)]
microchip-pickit2: move channel creation to after device context alloc

Create device instance (sdi) and device context (devc) first, before
creating channels and channel groups. Channel creation might want to
reflect on per-device properties which are kept in the context.

13 months agordtech-tc: Fix feed creation loop condition
Mathieu Pilato [Fri, 31 Mar 2023 10:16:24 +0000 (12:16 +0200)]
rdtech-tc: Fix feed creation loop condition

[ gsi: Amends commit b3df76683179. ]

13 months agofluke-dmm: Fix digit count in handle_qm_28x function.
Mathieu Pilato [Tue, 21 Mar 2023 09:36:59 +0000 (10:36 +0100)]
fluke-dmm: Fix digit count in handle_qm_28x function.

This requires splitting the measurement into mantissa and exponent,
as the exponent affects the significant digits count.

13 months agofluke-dmm: Fix counts_digits compatibility with 28x format
Mathieu Pilato [Mon, 20 Mar 2023 20:20:08 +0000 (21:20 +0100)]
fluke-dmm: Fix counts_digits compatibility with 28x format

Remove sign, then only take into account numerical characters (this
correctly excludes the exponent in the scientific notation used by
28x models).

13 months agofluke-dmm: Update digits count with regard to measurement exponent
Mathieu Pilato [Sun, 19 Mar 2023 23:10:44 +0000 (00:10 +0100)]
fluke-dmm: Update digits count with regard to measurement exponent

Also defer the creation of sr_datafeed_analog until the whole message
is parsed, and the number of significant digits is known.

13 months agobinary_helpers: remove scaling factor from binary field extraction
Gerhard Sittig [Thu, 30 Mar 2023 18:28:13 +0000 (20:28 +0200)]
binary_helpers: remove scaling factor from binary field extraction

All call sites use the sr_analog_encoding's support to scale values.
Drop the scaling support from the binary field extractor helper.
Adjust calling rdtech-um and rdtech-tc source code accordingly. See
a word diff for the essence.

13 months agordtech-tc: avoid too eager request retransmission
Gerhard Sittig [Sun, 19 Mar 2023 18:21:04 +0000 (19:21 +0100)]
rdtech-tc: avoid too eager request retransmission

The sequence of a scan/probe (which exchanges exactly one request and
response pair) before an acquisition (which requests another response,
then keeps re-requesting periodically) resulted in the transmission of
more requests shortly after a request was sent and before any response
started receiving at all. Which then resulted in unexpected lengths and
failed consistency checks for the receive data. This condition stuck
because rdtech-tc does not support the re-synchronization to the input
stream as rdtech-um does.

Defer transmission of requests until after receive data was seen (or
an acquisition start forces their transmission). Tested by repeatedly
running:

  $ sigrok-cli -d rdtech-tc:conn=bt/dialog/$MAC --continuous

13 months agordtech-tc: style nits in variable names
Gerhard Sittig [Sun, 19 Mar 2023 18:19:44 +0000 (19:19 +0100)]
rdtech-tc: style nits in variable names

Rename the AES_KEY[] to lower case, it's a variable not a preprocessor
symbol. Rename CRC variables to reflect what's calculated and what was
received.

13 months agordtech-tc: dump response payload at higher log levels
Gerhard Sittig [Sun, 19 Mar 2023 15:09:18 +0000 (16:09 +0100)]
rdtech-tc: dump response payload at higher log levels

The request is sent as is, responses are AES encrypted. Which voids the
point of transport layer dumps. Extend the rdtech-tc device driver, dump
the response content at spew levels after successful AES decryption and
validity checks. Pick a bytes per line count which matches the 64 bytes
chunked layout, yet reduces the number of created log output lines.

13 months agordtech-tc: request keyword differs between CDC and BLE transports
Gerhard Sittig [Sun, 19 Mar 2023 15:02:45 +0000 (16:02 +0100)]
rdtech-tc: request keyword differs between CDC and BLE transports

The TC66C firmware implements different keywords and different request
terminators across the USB CDC and the Bluetooth LE transports. Move the
string literal to the probe routine, construct the request text at the
time when the device is probed, then re-use it for the remaining session.

Check the receive buffer size and maximum reponse length for consistency
at compile time. Declarations are spread across source files.

13 months agordtech-tc: rename "buflen" variable, it's "read length"
Gerhard Sittig [Sun, 19 Mar 2023 14:35:33 +0000 (15:35 +0100)]
rdtech-tc: rename "buflen" variable, it's "read length"

The 'buflen' variable name could be misleading, as it's not the receive
buffer's size. Instead it is the amount of previously received response
data. Rename it to 'rdlen'.

13 months agoserial_bt: add TC66C to list of known names, suggest MTU value
Gerhard Sittig [Sun, 19 Mar 2023 18:32:28 +0000 (19:32 +0100)]
serial_bt: add TC66C to list of known names, suggest MTU value

Add "TC66C" to the list of known BLE device names. Map it to the
dialog BLE chip. Suggest an MTU value of 200.

13 months agoserial_bt: support the dialog DA14580 chip (seen in TC66C)
Gerhard Sittig [Sun, 19 Mar 2023 18:15:26 +0000 (19:15 +0100)]
serial_bt: support the dialog DA14580 chip (seen in TC66C)

Add support for dialog DA14580 chips, accept conn=bt/dialog/$MAC specs.
These BLE chips were seen in RDTech TC66C energy meters. They appear to
send notifications without the necessity to write CCCD values.

It's yet to get determined whether it's the chip or the device firmware
which requires MTU exchange. The default value in the 400 range (near
the absolute maximum MTU for BLE communication) is rather arbitrary a
choice, needs reconsideration in the future. Users always can override
as desired.

13 months agoserial_bt: add generic conn=bt/notify/<addr> "chip type"
Gerhard Sittig [Sun, 19 Mar 2023 16:51:26 +0000 (17:51 +0100)]
serial_bt: add generic conn=bt/notify/<addr> "chip type"

Add support for the rather generic 'notify' Bluetooth "chip type". This
avoids the necessity to come up with chip names for yet unsupported or
unknown BLE modules. Might be less confusing for users. All RX/TX/CCCD
handles must be provided by users.

13 months agoserial_bt, bluez: support MTU exchange in BLE reception
Gerhard Sittig [Sun, 19 Mar 2023 15:21:06 +0000 (16:21 +0100)]
serial_bt, bluez: support MTU exchange in BLE reception

The central must respond to peripherals' requests to exchange the MTU
value. If it doesn't then the connection terminates. The central has no
choice whether this exchange happens or when it does, applicability is
the consequence of using a specific device (a firmware implementation).
This was first observed with RDTech TC66C energy meters.

Add support for the mtu= parameter in conn=bt/ specifications. A good
default value is yet to get determined. The connection type or the chip
in use are insufficient conditions AFAICT. Currently it is assumed that
users specify the central's MTU when their device firmware requires the
exchange.

Use the "warning" severity for the diagnostics message when peripherals
request MTU exchange while the central won't respond (due to lack of a
value to respond with).

13 months agoserial_bt, bluez: rework diag in BLE reception, accept zero length data
Gerhard Sittig [Sun, 19 Mar 2023 14:59:31 +0000 (15:59 +0100)]
serial_bt, bluez: rework diag in BLE reception, accept zero length data

Rework how the sr_bt_check_notify() routine processes messages that were
received from a Bluetooth socket. Comment on edge cases that we have yet
to see how they are handled. Extend the amount of details that are given
in diagnostics messages, and tune their verbosity level. The debug level
nicely illustrates how data flows, the spew level makes bytes available.

Consider zero length data chunks in receive code paths non-fatal. Accept
either NULL or non-NULL addresses when the length is zero. A NULL pointer
in combination with a non-zero length is considered fatal though.

13 months agotests: cover length checking incrementing endianess readers
Gerhard Sittig [Sun, 19 Mar 2023 19:17:21 +0000 (20:17 +0100)]
tests: cover length checking incrementing endianess readers

13 months agolibsigrok-internal.h: add length checking endianess helpers
Gerhard Sittig [Sun, 19 Mar 2023 17:09:30 +0000 (18:09 +0100)]
libsigrok-internal.h: add length checking endianess helpers

Introduce the read_u8_inc_len() and read_u16le_inc_len() routines which
read the respective numbers from binary input, advance the current read
position, and also track the remaining length of input data. Call sites
need not duplicate the data field width they advanced over.

The input stream is considered exhausted when there is insufficient data
to read another field. All subsequent reads will also terminate. Calling
applications need to check before reading when they expect specific sets
of adjacent fields to be available. It is assumed that most call sites
already do this (once for the whole input stream, not individually for
each conversion call of a field).

13 months agostrutil: add more space in hexdumps after 8 and 16 data bytes
Gerhard Sittig [Sun, 19 Mar 2023 17:06:06 +0000 (18:06 +0100)]
strutil: add more space in hexdumps after 8 and 16 data bytes

The previous implementation just had one space between bytes. Which
quickly becomes hard to read for longer runs. Add more spaces after
8 and 16 bytes each for improved readability.

13 months agolog: accept when applications void the log callback
Gerhard Sittig [Sun, 19 Mar 2023 14:57:24 +0000 (15:57 +0100)]
log: accept when applications void the log callback

Common support code in the libsigrok library passes all output through
an application specified log callback, while a default callback exists
which writes to stdout and stderr.

Accept when no callback at all is registered. Don't output text in that
case, succeed silently.

13 months agolog: rephrase default sr_logv() routine, strip CR and LF
Gerhard Sittig [Sun, 19 Mar 2023 14:52:53 +0000 (15:52 +0100)]
log: rephrase default sr_logv() routine, strip CR and LF

Unobfuscate how the unconditional prefix and the conditional timestamp
will prefix the caller's message. Separate the result check for emission
of the prefix/timestamp from the check for successful construction of
the caller's message text. Release the dynamic buffer in the error path.
Use pointers and character variables in the copy loop for readability.

Strip LF as well as CR from the resulting log output text. The previous
implementation exclusively stripped LF. Escaping non-printables is not
attempted in this version.

13 months agofluke-dmm: sort models by numbers, no behaviour change
Gerhard Sittig [Sun, 19 Mar 2023 10:44:34 +0000 (11:44 +0100)]
fluke-dmm: sort models by numbers, no behaviour change

As the list of supported models grows, let's keep their declaration and
processing in numerical order of their model name. This is a mechanical
adjustment, no change in behaviour.

13 months agofluke-dmm: reduce indentation in 18x/190/28x dispatch logic
Gerhard Sittig [Fri, 17 Mar 2023 14:13:15 +0000 (15:13 +0100)]
fluke-dmm: reduce indentation in 18x/190/28x dispatch logic

Address several style nits in the fluke-dmm driver. Rephrase a lengthy
if-else-if sequence by means of switch-case, so that conditions are
easier to review. Use glib to get the vector length. Handle the trivial
case first, which reduces indentation for the remaining complex logic.
Fixup comment style, break long text lines.

13 months agofluke-dmm: Add support for Fluke 87/89 DMMs.
Mathieu Pilato [Thu, 9 Mar 2023 15:34:07 +0000 (16:34 +0100)]
fluke-dmm: Add support for Fluke 87/89 DMMs.

13 months agofluke-dmm: Extract digit count from response.
Mathieu Pilato [Fri, 10 Mar 2023 08:27:35 +0000 (09:27 +0100)]
fluke-dmm: Extract digit count from response.

The DMMs kindly formats its responses with the proper number of digits.
Extract and use this value instead, to not use an arbitrary digit count.

[ gsi: apply the same logic to Fluke 190 ]

13 months agofluke-dmm: Do not consider 0.0 value an invalid measurement.
Mathieu Pilato [Fri, 10 Mar 2023 08:10:11 +0000 (09:10 +0100)]
fluke-dmm: Do not consider 0.0 value an invalid measurement.

(Issue seems an oversight from commit 357e341)

13 months agoconfigure.ac: put spaces around version operators in pkg-config requires
Gerhard Sittig [Sat, 18 Mar 2023 21:17:01 +0000 (22:17 +0100)]
configure.ac: put spaces around version operators in pkg-config requires

Putting a library name and its version as one bare word on the Requires:
line without spaces around the operators makes application builds fail
because the library isn't found. This amends commit b0b139d914b9.

13 months agoconfigure.ac: glibmm check, add quotes to version string
Gerhard Sittig [Sat, 18 Mar 2023 16:10:11 +0000 (17:10 +0100)]
configure.ac: glibmm check, add quotes to version string

Add quotes where glibmm version requirements are concatenated while the
strings contain ">=" relational operators. Avoid processing incomplete
text, and the creation of undesired files in the build output. Amends
commit ee9e086f1d6c.

13 months agoMakefile.am: register more minilzo files with automake
Gerhard Sittig [Sat, 18 Mar 2023 16:08:35 +0000 (17:08 +0100)]
Makefile.am: register more minilzo files with automake

The libsigrok project embeds a small minilzo distribution. List header
files next to their source files. And list all other files as extras.
Makes distributions complete again. Amends commit b9cd0c6a53a6.

13 months agoserial_bt: add support for JL AC6328 chips (RFCOMM and BLE)
Gerhard Sittig [Sat, 25 Feb 2023 17:21:53 +0000 (18:21 +0100)]
serial_bt: add support for JL AC6328 chips (RFCOMM and BLE)

Add support for the JL AC6328B chip which happens to communicate both
RFCOMM (traditional Bluetooth) as well as BLE.

Support was tested with ATORCH USB loads and meters. Add a few product
names so that scans can list the "cable" when detected. Suggest to users
(as part of scan result output) that RFCOMM channel 2 is needed which is
not the default number.

13 months agordtech-tc: send analog values in frames not samples
Gerhard Sittig [Thu, 16 Mar 2023 04:21:51 +0000 (05:21 +0100)]
rdtech-tc: send analog values in frames not samples

The RDTech TC energy meter provides six analog channels, the values of
which are taken at the same time from one consistent raw data image.
Send these values in frames, so applications can tell they are related.

This drops support for --samples specifications. And allows to read back
previously specified time limits.

Tested by means of:
  $ sigrok-cli -d rdtech-tc:conn=/dev/ttyACM0 --show
  $ sigrok-cli -d rdtech-tc:conn=/dev/ttyACM0 --frames 5

13 months agordtech-um: send analog values in frames not samples
Gerhard Sittig [Thu, 16 Mar 2023 12:00:34 +0000 (13:00 +0100)]
rdtech-um: send analog values in frames not samples

The RDTech UM energy meter provides six analog channels, the values of
which are taken at the same time from one consistent raw data image.
Send these values in frames, so applications can tell they are related.

This drops support for --samples specifications. And allows to read back
previously specified time limits.

Tested by means of:
  $ sigrok-cli -d rdtech-um:conn=bt/rfcomm/$MAC --show
  $ sigrok-cli -d rdtech-um:conn=bt/rfcomm/$MAC --frames 4

13 months agobinary helper: drop analog channel support (submit samples to feed)
Gerhard Sittig [Wed, 15 Mar 2023 22:59:02 +0000 (23:59 +0100)]
binary helper: drop analog channel support (submit samples to feed)

Remove the bv_send_analog_channel() routine and its data types. All
callers have migrated to the common feed queue API. Extracting numbers
from raw binary images remains the only use case for binary helpers.

Prefer read_u8() et al endianess aware readers over R8() preprocessor
macros. Reduce indentation in the switch() cases according to style.
Accept scale factor 0 to mean no scaling in addition to factor 1.
Update comments to avoid the redundant "binary blob" phrase.

13 months agordtech-tc: migrate to feed queue helper
Gerhard Sittig [Thu, 16 Mar 2023 04:18:10 +0000 (05:18 +0100)]
rdtech-tc: migrate to feed queue helper

Implement the submission of analog data to the sigrok session by means
of the common feed queue logic. Use the feed queue's scaling support.
Implement a .dev_clear() routine which releases resources.

This exlusively leaves the extraction of numbers from binary data as
the only remaining use case for the binary helpers logic.

13 months agordtech-tc: grab receive data in larger chunks
Gerhard Sittig [Thu, 16 Mar 2023 03:28:50 +0000 (04:28 +0100)]
rdtech-tc: grab receive data in larger chunks

The previous implementation used to read each of the 192 bytes in
individual calls into the serial layer. This implementation grabs
receive data in larger chunks, and accepts data to be in flight
between main loop callbacks.

USB CDC appears to reliably deliver 64 byte chunks (unsurprisingly).
BLE communication is yet to get tested, isn't operational with current
mainline BT support because MTU exchange is not implemented.

(Re-)synchronization to the stream of packets after hiccups remains
an option which this implementation does not provide, neither did
the previous implementation.

13 months agordtech-tc: rephrase probe/write timeout and poll interval for text length
Gerhard Sittig [Thu, 16 Mar 2023 03:13:00 +0000 (04:13 +0100)]
rdtech-tc: rephrase probe/write timeout and poll interval for text length

Rename identifiers, break long text lines in the handling of probe and
write/read timeouts as well as the request transmission intervals.

13 months agordtech-tc: detect receive and parse errors, terminate acquisition
Gerhard Sittig [Thu, 16 Mar 2023 03:03:04 +0000 (04:03 +0100)]
rdtech-tc: detect receive and parse errors, terminate acquisition

Pepper the code paths from main loop calls via serial reception to
data processing with return code checks and error handling. Terminate
acquisition when communication or data processing fail.

Check whether acquisition limits were reached immediately after more
values were submitted. Keep a periodic check in the main loop call to
handle duration limits.

Comment on essential steps in the execution sequence.

13 months agordtech-tc: concentrate request transmit handling in one spot
Gerhard Sittig [Thu, 16 Mar 2023 02:41:17 +0000 (03:41 +0100)]
rdtech-tc: concentrate request transmit handling in one spot

Move all "command sent at ..." calculation and update in a single spot
for improved awareness during development. Allow acquisition start to
force the transmission of the measurement request.

13 months agordtech-tc: avoid mixing several iterations in the same for loop
Gerhard Sittig [Thu, 16 Mar 2023 02:31:12 +0000 (03:31 +0100)]
rdtech-tc: avoid mixing several iterations in the same for loop

Separate the iteration of a channels list, and indexing their associated
binary helpers descriptions. Use the for() statement for list iteration
exclusively, avoid the comma operator.

13 months agordtech-tc: use size_t for memory sizes and indices
Gerhard Sittig [Thu, 16 Mar 2023 02:29:54 +0000 (03:29 +0100)]
rdtech-tc: use size_t for memory sizes and indices

13 months agordtech-tc: use common code to scan conn= and serialcomm= specs
Gerhard Sittig [Thu, 16 Mar 2023 02:27:47 +0000 (03:27 +0100)]
rdtech-tc: use common code to scan conn= and serialcomm= specs

13 months agordtech-tc: eliminate redundant type info in malloc call
Gerhard Sittig [Thu, 16 Mar 2023 02:25:00 +0000 (03:25 +0100)]
rdtech-tc: eliminate redundant type info in malloc call

Allocate whatever it takes to hold the variable. Don't open code the
type information again when inconsistency would go unnoticed.

Link devc earlier to sdi, ideally immediately after allocation.

13 months agordtech-tc: move assignments out of declarations
Gerhard Sittig [Thu, 16 Mar 2023 02:18:14 +0000 (03:18 +0100)]
rdtech-tc: move assignments out of declarations

Separate the declaration of variables from their manipulation. Keep
initial assignments and subsequent updates and evaluation of results
in closer proximity.

Group related instructions while we are here, avoid scatter. Break
long lines, and add braces around complex multi-line statements.