]> sigrok.org Git - libsigrok.git/log
libsigrok.git
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.

13 months agordtech-tc: rephrase PAC consistency check, discuss sample data layout
Gerhard Sittig [Thu, 16 Mar 2023 01:56:50 +0000 (02:56 +0100)]
rdtech-tc: rephrase PAC consistency check, discuss sample data layout

Rephrase access to the PAC chunks and the consistency check of the total
192 bytes data image in terms of one 64 bytes unit. Which eliminates
other magic numbers. Add a comment for awareness during development.

Prefer read_u32le() endianess conversion helpers for reliability. Use
big endian readers for four-character-codes to increase readability.
Address style nits in the process: Use booleans for checksum and
consistency checks. Eliminate else after return. Consolidate error
messages. Prefer indexing an array over pointer arithmetics. Group
related instructions in the same block.

13 months agordtech-tc: use literal string for poll command instead of array
Gerhard Sittig [Thu, 16 Mar 2023 01:31:37 +0000 (02:31 +0100)]
rdtech-tc: use literal string for poll command instead of array

Use a char pointer for the poll command which is a string literal. Which
eliminates the "necessity" to strip the NUL terminator from an array
after its construction. The strlen() for literals also gets resolved at
compile time. Which means that execution cost remains identical.

Rename the variable to lower case, it's not a preprocessor symbol.

13 months agordtech-tc: eliminate excessive indentation, address whitespace issues
Gerhard Sittig [Thu, 16 Mar 2023 01:28:51 +0000 (02:28 +0100)]
rdtech-tc: eliminate excessive indentation, address whitespace issues

[ see a whitespace ignoring diff for review ]

13 months agordtech-tc: alpha-sort and group include directives
Gerhard Sittig [Thu, 16 Mar 2023 01:26:57 +0000 (02:26 +0100)]
rdtech-tc: alpha-sort and group include directives

13 months agordtech-um: migrate from binary helper channel to feed queue
Gerhard Sittig [Wed, 15 Mar 2023 21:46:14 +0000 (22:46 +0100)]
rdtech-um: migrate from binary helper channel to feed queue

Use common feed queue support for the submission of analog values to the
sigrok session. This leaves the extraction of the value from binary data
images with a factor of 1 for binary helpers, but uses existing code to
scale the value (which operates at higher accuracy) and to submit values
to the sigrok session.

It's up to debate whether a scaling factor value of { 10, 1000, } can be
recognized as 10mV by readers, and how this phrase relates to the other
spec of 2 significant digits. Might be acceptable. Offsetting and MQ flags
are not used by this driver. The exponent representation was used in the
channels table because some models support 100uA resolution for current.
Engineering exponents are preferred for readability (rationals are not
"normalized" to scientific presentation with "odd" exponent values).

Register a device clear routine so that the driver releases resources
that were allocated during scan and device instance creation.

13 months agordtech-um: rework serial reception and processing, including re-sync
Gerhard Sittig [Wed, 15 Mar 2023 19:39:10 +0000 (20:39 +0100)]
rdtech-um: rework serial reception and processing, including re-sync

The previous implementation was expensive on the serial transport and
kept calling into this layer for individual bytes, to simplify the logic
which synchronized to the packetized input stream. And it used to block
in main loop calls until reception of a packet completes, which could
take some 200ms in the RFCOMM setup, and not much less for USB CDC.

Rework the call chain from main loop receive callbacks to processing
packets. Grab receive data in large chunks from the serial layer. Try
to rate limit the synchronization to the packet stream and associated
diagnostics messages. Process more return values and stop acquisition
upon errors. Move the checksum test to the packet content processor.
Check acquisition limits in the spot which just submitted more data
(keep another check in the periodic callback to handle time limits).
Strive for fast yet rate limited transmission of periodic measurement
requests, to initiate the reception of more sample values.

Shorten more lines (and avoid continuations and line breaks) by renaming
routines and variables. Pass packet content references such that content
handlers need not know about reception details, and reception can chunk
data differently in future versions.

This implementation became rather complex, most of all because of UI
concerns and robustness, as well as potential for future extension of
the scope of these code paths. The loss of synchronization and slow
reception of packets in chunks in combination with periodic request
transmission based on intervals results in "interesting" behaviour.
Maybe something simpler is desirable which is more expensive to run
but easier to maintain and reason about?

13 months agordtech-um: rephrase channel count in profile description
Gerhard Sittig [Wed, 15 Mar 2023 18:01:57 +0000 (19:01 +0100)]
rdtech-um: rephrase channel count in profile description

Use ARRAY_AND_SIZE() instead of the ALL_ZERO terminator for the list
of channels in a model's profile. This improves iteration readability,
avoids off-by-one issues, eliminates "empty slot?" checks in numerical
iteration over indices. Rename channel list identifiers to reduce the
text line length in the source code.

13 months agordtech-um: adjust read/write timeout style for text line length
Gerhard Sittig [Wed, 15 Mar 2023 17:47:54 +0000 (18:47 +0100)]
rdtech-um: adjust read/write timeout style for text line length

Avoid the combination of function calls and the evaluation of their
return values for flow control in the same statement. Which improves
readability during maintenance. Rename identifiers to keep text line
lengths within style constraints.

Comment on non-trivial global parameters, and essential periodic jobs
in the main loop callback while we are here.

13 months agordtech-um: data type nits, common expressions, for loop iteration
Gerhard Sittig [Wed, 15 Mar 2023 17:17:31 +0000 (18:17 +0100)]
rdtech-um: data type nits, common expressions, for loop iteration

Address several style nits: Use size types where appropriate. Avoid
repeated complex expressions in the profile lookup. Don't mix different
types of iterations in a for() loop (traversal of a channels list, and
indexing the channels' blob access details). Rename a generic identifier
in the probe routine.

13 months agordtech-um: tone down and extend diagnostics messages
Gerhard Sittig [Wed, 15 Mar 2023 17:03:01 +0000 (18:03 +0100)]
rdtech-um: tone down and extend diagnostics messages

Reflect tested conditions in diagnostics messages, and tell more
conditions apart where possible. Take the user's perspective in these
messages.

Address programming style while we are here: Prefer read_u16be() over
RB16() for robustness. Use intermediate variables to avoid repeated
converter calls. Transparently advance over the received data length
(the read size and the separated increment had no perceivable relation
in the source code).

13 months agordtech-um: use common helper to parse conn= and serialcomm= specs
Gerhard Sittig [Wed, 15 Mar 2023 16:55:19 +0000 (17:55 +0100)]
rdtech-um: use common helper to parse conn= and serialcomm= specs

Use the common sr_serial_extract_options() helper when conn= specs
are mandatory (and serialcomm= remains optional).

13 months agordtech-um: eliminate redundant data types in memory allocation
Gerhard Sittig [Wed, 15 Mar 2023 16:52:40 +0000 (17:52 +0100)]
rdtech-um: eliminate redundant data types in memory allocation

Just allocate the size of the involved variable. Eliminate redundant
data type specs where inconsistency would go unnoticed.

Link the device context earlier to the device instance while we are
here. Immediately after allocation of the dynamic memory so that the
relation remains obvious.

13 months agordtech-um: concentrate poll period handling in one spot
Gerhard Sittig [Wed, 15 Mar 2023 16:24:44 +0000 (17:24 +0100)]
rdtech-um: concentrate poll period handling in one spot

The handling of "command sent at ..." and the emission of periodic poll
requests is non-trivial, and was scattered around different locations.
Concentrate all of the time scaling and delta calculation and updating
internal state into a single spot, and allow callers to force the first
emission when desired (acquisition start needs this). Which eliminates
repeated calls into the microseconds getter.

Not advancing the last checkpoint, and keep sending requests until
successful transmission, remains identical to the previous version of
the implementation. In practise transmit errors are rare.

13 months agordtech-um: rephrase checksum verification routines
Gerhard Sittig [Wed, 15 Mar 2023 16:11:30 +0000 (17:11 +0100)]
rdtech-um: rephrase checksum verification routines

Rename the unfortunately named poll_csum() callback. It neither polled
for receive data nor calculated checksums for the caller. It verifies
that a received packet's checksum is plausible, and returns a boolean.

Address coding style nits in the process. Adjust data types. Use size
types where appropriate. Don't use characters when bytes are meant. Use
booleans for the checksum test result. Shorten identifier names to trim
text line length. No need to "take the address" of a routine. Remove
dead code, model dependent checksum approaches are handled by registered
callbacks in profiles. Eliminate else after return. Prefer read_u16be()
endianess routines over RB16() preprocessor macros. Prefer lower case
hex digits. Make the code reflect that the last 16bit or 8bit entity in
the received data packet gets checked. Use "calc" and "recv" names for
awareness which variable holds which value.

13 months agordtech-um: style nits, move assignment out of declaration blocks
Gerhard Sittig [Wed, 15 Mar 2023 16:03:02 +0000 (17:03 +0100)]
rdtech-um: style nits, move assignment out of declaration blocks

Move initial assigment, subsequent updates, and checks of resulting
variable content closer to each other. Don't hide code in declaration
blocks. Eliminate redundant assignments that don't take effect, yet
can hide programming errors. Increases awareness during maintenance.

13 months agordtech-um: alpha-sort and group include directives
Gerhard Sittig [Wed, 15 Mar 2023 16:00:41 +0000 (17:00 +0100)]
rdtech-um: alpha-sort and group include directives

Put <config.h> first. Then system headers. Then application headers.

13 months agordtech-um: address style nits (whitespace, braces)
Gerhard Sittig [Wed, 15 Mar 2023 15:36:01 +0000 (16:36 +0100)]
rdtech-um: address style nits (whitespace, braces)

Eliminate excessive indentation and other whitespace nits. Alignment of
tables wasn't working anyway. Put braces around complex statements that
span multiple lines, or trim line length differently where appropriate.

13 months agordtech-um: increase digits count for models with higher resolution
Gerhard Sittig [Wed, 15 Mar 2023 17:52:32 +0000 (18:52 +0100)]
rdtech-um: increase digits count for models with higher resolution

The table of UM25C channels differs from other models. The V and I
channels provide a higher resolution, their scaling factors differ.
Update the number of significant digits, too, which went unnoticed.

13 months agoserial_bt: move lookup code next to database of known device names
Gerhard Sittig [Thu, 16 Mar 2023 09:56:36 +0000 (10:56 +0100)]
serial_bt: move lookup code next to database of known device names

Move the scan_is_supported() routine close to the scan_supported_items[]
table which is traverses. Comment on the database's motivation, and its
current capabilities. This will be helpful should the table need to move
to a separate source file as the database grows over time.

13 months agoserial_bt: prepare support for additional params in scan results
Gerhard Sittig [Thu, 16 Mar 2023 00:01:04 +0000 (01:01 +0100)]
serial_bt: prepare support for additional params in scan results

The scan_supported_items[] table contains a list of known device names,
and connection types that are used to communicate to them. Prepare the
presentation of more parameters in scan results when a device is known
to require these.

13 months agoserial_bt: increase scan duration for BT/BLE connections
Gerhard Sittig [Wed, 15 Mar 2023 23:45:20 +0000 (00:45 +0100)]
serial_bt: increase scan duration for BT/BLE connections

Some devices are slow to respond to scans. Increase the scan duration
from 2s to 3s. Tested with RDTech UM25C. Should be acceptable when a
manual scan takes some 6 seconds (BT and BLE) instead of 4.

13 months agoserial_bt: add UM25C to list of known device names
Gerhard Sittig [Wed, 15 Mar 2023 23:37:52 +0000 (00:37 +0100)]
serial_bt: add UM25C to list of known device names

Register that RFCOMM can be used when the device name is UM25C.

13 months agoserial_bt: update comments on conn=bt/... parameters
Gerhard Sittig [Wed, 15 Mar 2023 23:35:20 +0000 (00:35 +0100)]
serial_bt: update comments on conn=bt/... parameters

Commit 0e4a85a9254c added support for parameters that follow the BT/BLE
remote address in conn= specs. Update developer comments near the parse
routine.

13 months agofeed queue: add scale/offset support, rename MQ/unit routine
Gerhard Sittig [Wed, 15 Mar 2023 22:43:42 +0000 (23:43 +0100)]
feed queue: add scale/offset support, rename MQ/unit routine

Use the scale and offset support for analog measurement values which is
part of the existing sr_analog_encoding API. Rename the routine which
configures MQ and unit before submission of analog data.

This drops local redundant scaling support. And brings feed queue on par
with the binary helpers implementation.

13 months agofeed queue: unbreak MQ and unit support in analog feeds
Gerhard Sittig [Sun, 5 Mar 2023 17:06:30 +0000 (18:06 +0100)]
feed queue: unbreak MQ and unit support in analog feeds

Unbreak the compilation of the feed queue. The error was introduced
in commit 43e6f7a7798f which added MQ and unit support.

13 months agofeed queue: add scaling, MQ and unit to analog feed submission
Gerhard Sittig [Sun, 5 Mar 2023 12:38:28 +0000 (13:38 +0100)]
feed queue: add scaling, MQ and unit to analog feed submission

Allow for the analog data to scale during submission, and pass caller
specified MQ including flags and units to the sigrok session. Using
these specs is optional, default behaviour is backwards compatible.
Accumulated data gets flushed before the configuration changes. This
allows the migration of binary helper using drivers to feed queue.

13 months agobinary helpers: touch up Doxygen comments (in/out params, clutter)
Gerhard Sittig [Sun, 5 Mar 2023 10:19:02 +0000 (11:19 +0100)]
binary helpers: touch up Doxygen comments (in/out params, clutter)

Provide 'in' and 'out' directions for function parameters. Unclutter
struct declarations by putting comments after their fields. Eliminate
redundant "binary blob" phrases.

13 months agobinary helpers: address minor style nits, break long text lines
Gerhard Sittig [Sun, 5 Mar 2023 10:16:58 +0000 (11:16 +0100)]
binary helpers: address minor style nits, break long text lines

Break long text lines in source code files, and break them in more
appropriate locations (keep groups of related function parameters).

14 months agoudev: add Siglent SDM3055 USB identification rule
Electro707 [Tue, 23 Mar 2021 21:12:02 +0000 (17:12 -0400)]
udev: add Siglent SDM3055 USB identification rule

Add the USB identification for the Siglent SDM3055 multimeter and the
SDS1104X-E scope.

14 months agoscpi-dmm: add support for Siglent SDM3055
Electro707 [Tue, 23 Mar 2021 21:12:02 +0000 (17:12 -0400)]
scpi-dmm: add support for Siglent SDM3055

14 months agoscpi: add Siglent to the vendor alias list
Electro707 [Tue, 23 Mar 2021 21:12:02 +0000 (17:12 -0400)]
scpi: add Siglent to the vendor alias list

14 months agoREADME.devices: document conn=bt/ extensions for more optional parameters
Gerhard Sittig [Mon, 20 Feb 2023 19:03:19 +0000 (20:03 +0100)]
README.devices: document conn=bt/ extensions for more optional parameters

The conn=bt/ syntax grew support for optional additional parameters. Add
them to the README.devices page for awareness.

14 months agoserial_bt: support more key=value parameters for conn=bt/ specs
Gerhard Sittig [Mon, 20 Feb 2023 18:58:50 +0000 (19:58 +0100)]
serial_bt: support more key=value parameters for conn=bt/ specs

Extend the syntax for conn=bt/ specs. Accept RFCOMM channel numbers, as
well as BLE handles for RX, TX, and CCCD, as well as a CCCD value. This
allows users to unbreak their "cables" without necessity of adjusting
source code.

14 months agokorad-kaxxxxp: add quirk for long processing times of commands
Gerhard Sittig [Sat, 25 Feb 2023 16:45:57 +0000 (17:45 +0100)]
korad-kaxxxxp: add quirk for long processing times of commands

Some Korad compatibles are said to take rather long a time between
reception of adjacent commands. It's not just that the response is
delayed, or that execution takes a long time. It's worse in that the
next request isn't received, and later responses don't correspond
to the requests which host software associates them with. A driver
implementation detail then "reads" 0.000 current values when the
PSU failed to respond to the "IOUT?" request.

Add a quirk flag. Allow for extra processing time after SET commands
and the GET command for STATUS. Add the Velleman PS3005D V1.3 model
with this quirk. Behaviour does not change for other devices.

This implementation is based on a submission that was provided by
Pilatomic <redacted>.

14 months agokorad-kaxxxxp: eliminate excessive whitespace in continued signatures
Gerhard Sittig [Sat, 25 Feb 2023 15:39:26 +0000 (16:39 +0100)]
korad-kaxxxxp: eliminate excessive whitespace in continued signatures

Continuation lines in routine signatures should be indented by one TAB
(which is sufficient) or two (which is luxury). Four TABs is excessive,
and does not improve readability. Eliminate the excess whitespace.

14 months agokorad-kaxxxxp: address style nits, redundant data type in malloc
Gerhard Sittig [Sat, 25 Feb 2023 15:36:45 +0000 (16:36 +0100)]
korad-kaxxxxp: address style nits, redundant data type in malloc

Rephrase malloc calls, eliminate a redundant yet unnecessary data type
duplication. Just get how much space the variable happens to require.

14 months agokorad-kaxxxxp: tweak first "give time to process" invocation
Gerhard Sittig [Sat, 25 Feb 2023 15:29:28 +0000 (16:29 +0100)]
korad-kaxxxxp: tweak first "give time to process" invocation

The give_device_time_to_process() routine unconditionally calculated
with a "time since last command transmission" value which may not have
been assigned to in the first invocation of a getter or setter.

Just don't sleep at all when nothing was sent before. Avoids a
dependency on implementation details of signed integer math.

14 months agokorad-kaxxxxp: rephrase how config setter transmits commands to device
Gerhard Sittig [Sat, 25 Feb 2023 15:20:48 +0000 (16:20 +0100)]
korad-kaxxxxp: rephrase how config setter transmits commands to device

The korad_kaxxxxp_set_value() routine was phrased in redundant and hard
to read ways that were error prone during maintainance. A variables pair
for "command" and "value" variables was assigned to, depending on the
involved parameter of the config setter. And only later in another code
section the text message got combined and was sent to the device. Error
paths which handled unknown keys or non-settable parameters returned
early but had to balance resources on their way out.

This rephrased implementation immediately constructs the text message
when dispatching parameters and looking up their values. Can use more
appropriate printf(3) formats in the respective construction. Emits the
same amount of diagnostics. Releases resources upon exit which were
released during execution. Eliminates dynamic allocation of a 20 byte
buffer.

Tested-By: Pilatomic <redacted>
14 months agoHACKING: separate assignment from program flow, endianess helpers
fenugrec [Wed, 30 Nov 2022 14:27:20 +0000 (09:27 -0500)]
HACKING: separate assignment from program flow, endianess helpers

14 months agohp-3478a: Fix range strings for current and resistance mode
Frank Stettner [Sun, 12 Feb 2023 12:10:43 +0000 (13:10 +0100)]
hp-3478a: Fix range strings for current and resistance mode

The range strings for the resistance mode were missing the unit (R). The
range strings for both current modes (DC and AC) were wrongly using volts
instead of amps.

14 months agoicstation-usbrelay: Initial ICStation USBRelay driver.
Frank Stettner [Sat, 7 Aug 2021 12:16:42 +0000 (14:16 +0200)]
icstation-usbrelay: Initial ICStation USBRelay driver.

Implement support for several ICStation USBRelay models with 2, 4, and 8
channels. Allows to identify the cards after power-on, and subsequent
relay control.

IMPORTANT: An implementation detail in the vendor firmware prevents the
host application from identifying the device after entering command mode.
Identification will fail, and the identification request instead gets
mistaken for another relay control request (turns on relays 1-4, 6, 8).
A power cycle is required before the host application can reconnect to
the device.

14 months agoicstation-usbrelay: Initial driver skeleton.
Frank Stettner [Fri, 6 Aug 2021 20:04:47 +0000 (22:04 +0200)]
icstation-usbrelay: Initial driver skeleton.

14 months agogitignore: Add files/folders used or created by the clangd language server
Frank Stettner [Sat, 4 Feb 2023 14:12:24 +0000 (15:12 +0100)]
gitignore: Add files/folders used or created by the clangd language server

When using the clangd language server, it expects a compilation database
in the root directory, which must not be commited into the git repository.
Also the .cache/ directory, created by clangd can be ignored.

14 months agohp-3478a: fix values for digits properties
Frank Stettner [Fri, 23 Dec 2022 16:43:21 +0000 (17:43 +0100)]
hp-3478a: fix values for digits properties

Unify the hp-3478a driver with the other drivers regarding the use of the
digits properties in the analog payload. This commit adjusts the previously
unclear, but now clarified, use of these properties:

Number of significant digits after the decimal point, if positive. When
negative, exponent with reversed polarity that is necessary to express the
value with all digits without a decimal point.

14 months agodmm/mm38xr: fix values for digits properties
Frank Stettner [Fri, 23 Dec 2022 14:03:13 +0000 (15:03 +0100)]
dmm/mm38xr: fix values for digits properties

Unify the mm38xr package parser with the other drivers regarding the use of the
digits properties in the analog payload. This commit adjusts the previously
unclear, but now clarified, use of these properties:

Number of significant digits after the decimal point, if positive. When
negative, exponent with reversed polarity that is necessary to express the
value with all digits without a decimal point.

14 months agodmm/metex14: fix values for digits properties
Frank Stettner [Fri, 23 Dec 2022 11:20:44 +0000 (12:20 +0100)]
dmm/metex14: fix values for digits properties

Unify the metex14 package parser with the other drivers regarding the use of
the digits properties in the analog payload. This commit adjusts the previously
unclear, but now clarified, use of these properties:

Number of significant digits after the decimal point, if positive. When
negative, exponent with reversed polarity that is necessary to express the
value with all digits without a decimal point.

This commit partly reverts commit 7fb4ff0

14 months agoReword and clarify the doc strings for digits in the analog payload
Frank Stettner [Fri, 27 Jan 2023 12:28:05 +0000 (13:28 +0100)]
Reword and clarify the doc strings for digits in the analog payload

Clarifies the intended use of the properties sr_analog_encoding.digits and
sr_analog_spec.spec_digits used in the analog payload and also digits() in
the Analog class of the C++ bindings.

These properties hold the number of significant digits after the decimal
point, if positive. When negative, exponent with reversed polarity that is
necessary to express the value with all digits without a decimal point.

15 months agokingst-la2016: add another supported LA2016 model (bytes 0x0b 0x10)
Dave Platt [Sat, 28 Jan 2023 04:37:53 +0000 (20:37 -0800)]
kingst-la2016: add another supported LA2016 model (bytes 0x0b 0x10)

Add the 11 (16) magic bytes combination (in hex: 0x0b 0x10) which adds
a more recent Kingst LA2016 device to the list of supported models.

This addresses the device identification part of bug #1825.

16 months agobindings: add u32/SR_T_UINT32 support for config keys
Markus Heidelberg [Sun, 11 Dec 2022 00:28:55 +0000 (01:28 +0100)]
bindings: add u32/SR_T_UINT32 support for config keys

Previous bindings for C++ and other languages lacked support for the
uint32_t data type for config keys. Which terminated the program with
the message:

  Exception: internal error

The following PulseView commands reproduced the issue:

  $ pulseview -i /dev/null -I csv:single_column=1
  $ pulseview -i /dev/null -I csv:first_column=1
  $ pulseview -i /dev/null -I csv:logic_channels=1
  $ pulseview -i /dev/null -I csv:start_line=1

  $ pulseview -i /dev/null -I saleae:wordsize=1
  $ pulseview -i /dev/null -I saleae:logic_channels=1

  $ pulseview -i /dev/null -I vcd:numchannels=1

Add support for uint32_t data types in the C++, Python, and Ruby
language bindings.

[ gsi: separate stou32() helper ]

16 months agobindings/cxx: implement std::stoul() fallback when C++11 is missing
Gerhard Sittig [Sat, 17 Dec 2022 13:26:09 +0000 (14:26 +0100)]
bindings/cxx: implement std::stoul() fallback when C++11 is missing

Provide an implementation of stoul(3) when the targetted platform does
not provide it. This is modelled after the stoi() and stod() routines.

16 months agoinput/trace32_ad: use u64 instead of u32 for samplerate option
Markus Heidelberg [Mon, 5 Dec 2022 23:51:20 +0000 (00:51 +0100)]
input/trace32_ad: use u64 instead of u32 for samplerate option

The variable type is already u64 so this is consistent now inside of
this module and also with the other input parsers using a samplerate
option.

This also fixes a crash when invoking PulseView with the "samplerate"
command line option because u32 is not yet included in C++ bindings:

$ pulseview -i /dev/null -I trace32_ad:samplerate=1
Exception: internal error

16 months agoinput/csv: eliminate unneeded zero fill of analog samples in malloc
Markus Heidelberg [Sun, 27 Nov 2022 01:14:07 +0000 (02:14 +0100)]
input/csv: eliminate unneeded zero fill of analog samples in malloc

Zero filling the memory for analog sample data was not harmful, but
shadowed the issue which got fixed in commit e7ed37042611. Remove it.
Which also happens to unify memory preparation again for logic and
for analog data.

16 months agoinput/csv: unbreak assignment of zero values to analog channels
Gerhard Sittig [Sat, 3 Dec 2022 06:49:47 +0000 (07:49 +0100)]
input/csv: unbreak assignment of zero values to analog channels

Unconditionally assign the value of 0.0 to the current sample's position
of analog data for the session feed. Not assigning that zero value could
result in old data from previous chunks to transpire through, yielding
invalid output from CSV import when analog data is involved.

This amends commit 43bdef263420 which introduced support for analog
channels in the CSV input module. And phrased the implementation for
similarity with logic data's code paths, where bit manipulation is
more complex, and only high bits get applied to a previously cleared
sample memory. Which introduced that zero value ignoring issue.

Depending on software versions which used single or double precision
data types, either requires 2^20 or 2^19 samples to reproduce.

  input file content:

    CH1
    5.1
    5.2
    5.3
    5
    ... 524280 more "5" values ...
    5
    0
    0
    0 ; last 0.0 sample 2^19 correctly imported as 0.0
    0 ; wrongly imported as 5.1 (first sample from beginning)
    0 ; wrongly imported as 5.2 (second sample from beginning)
    0 ; wrongly imported as 5.3 (third sample from beginning)
    5
    5
    5

  command invocation:

    $ sigrok-cli -i example.csv -I csv:column_formats=a | tail

  incorrect output data:

    CH1: 5.000
    CH1: 0.000
    CH1: 0.000
    CH1: 0.000
    CH1: 5.100
    CH1: 5.200
    CH1: 5.300
    CH1: 5.000
    CH1: 5.000
    CH1: 5.000

Reported-By: Markus Heidelberg <redacted>
17 months agokorad-kaxxxxp: add model entry for Tenma 72-2705
Gerhard Sittig [Fri, 25 Nov 2022 08:28:46 +0000 (09:28 +0100)]
korad-kaxxxxp: add model entry for Tenma 72-2705

Add the "Tenma 72-2705" model to the list of supported devices
(single channel, 30V, 3A).

Reported-By: Dries <redacted>
17 months agoconfigure: Accept glibmm-2.68 as an alternative to glibmm-2.4
Gerhard Sittig [Tue, 22 Nov 2022 10:11:50 +0000 (11:11 +0100)]
configure: Accept glibmm-2.68 as an alternative to glibmm-2.4

Check for both glibmm-2.4 as well as glibmm-2.68. Prefer the former
when either is available, to remain backwards compatible.

This unbreaks builds on OS X with homebrew where only glibmm-2.68
is available.

Implementor's note: It's yet to get determined whether glibmm-2.68
is to get preferred, being the first stable release of that external
dependency. https://gitlab.gnome.org/GNOME/glibmm/-/blob/2.68.2/NEWS
The commit is phrased to simplify future adjustment of this preference.

This commit is based on work that was
Submitted-By: Fabrice Fontaine <redacted>
17 months agobindings/cxx: Increase compatibility for glibmm-2.68
Fabrice Fontaine [Mon, 3 Jan 2022 07:32:27 +0000 (08:32 +0100)]
bindings/cxx: Increase compatibility for glibmm-2.68

Prefer the DateTime data type which has been available since glibmm-2.4
version 2.26, and also is available in glibmm-2.68. While glibmm-2.68
no longer provides the TimeVal data type.

[ gsi: split Fabrice's commit, rephrase commit message ]

17 months agoconfigure.ac: check for highest available C++17/C++14/C++11 standard
Gerhard Sittig [Mon, 21 Nov 2022 17:50:18 +0000 (18:50 +0100)]
configure.ac: check for highest available C++17/C++14/C++11 standard

There are external libraries (boost, glibmm) as well as platforms (Mac
OSX 12) which "require" C++ language standards above 11. Detect the
highest available standard which is supported by the compiler.

Use a "have modern C++" variable to improve robustness and readability
of the C++ language standard check.

17 months agom4: update ax_cxx_compile_stdcxx.m4 to also cover C++17
Gerhard Sittig [Mon, 21 Nov 2022 18:27:19 +0000 (19:27 +0100)]
m4: update ax_cxx_compile_stdcxx.m4 to also cover C++17

This file corresponds to the git://git.sv.gnu.org/autoconf-archive
repository's file m4/ax_cxx_compile_stdcxx.m4 as of 2022-07-25 (see
commit 2bfeecc1d509).

17 months agodmm/bm86x: fix broken URLs
François Revol [Tue, 27 Sep 2022 23:27:53 +0000 (01:27 +0200)]
dmm/bm86x: fix broken URLs

17 months agodmm/bm85x: fix broken URLs
François Revol [Tue, 27 Sep 2022 23:26:14 +0000 (01:26 +0200)]
dmm/bm85x: fix broken URLs

17 months agodmm/bm52x: fix broken URLs
François Revol [Tue, 27 Sep 2022 22:58:06 +0000 (00:58 +0200)]
dmm/bm52x: fix broken URLs

18 months agokingst-la2016: adjust sample memory interpretation for LA5032
Gerhard Sittig [Sun, 16 Oct 2022 10:50:55 +0000 (12:50 +0200)]
kingst-la2016: adjust sample memory interpretation for LA5032

The 32-channel model in the Kingst LA series uses a different sample
memory layout than 16-channel models. The previously encoded assumption
of 3x (u32 + u8) to hold 32 channels within the same 15 bytes as other
models was incorrect. User feedback in bug #1805 suggests that the
transfer size and the sequence number size differs as well. Thus the
packet count per transfer differs, too. LA5032 holds 6 packets within
a transfer that spans 32 bytes.

Reported-By: Roman Shishkin <redacted>
18 months agokingst-la2016: update developer comments, motivated by LA5032 support
Gerhard Sittig [Sun, 16 Oct 2022 10:43:50 +0000 (12:43 +0200)]
kingst-la2016: update developer comments, motivated by LA5032 support

User feedback in bug #1805 provides information on the sample memory
layout for the 32-channel model in the Kingst LA series. Adjust comments
for improved readability/maintainability, and for awareness of variants
across different models.

Rework the send_chunk() comment. This routine deals with captures to the
device's internal RAM. Memory layout differs quite a lot between models
with 16 and with 32 channels.

Rephrase the stream_data() comment. This routine deals with continuous
streams of uncompressed data which bypasses the device's local memory.

Reported-By: Roman Shishkin <redacted>
18 months agokingst-la2016: unbreak streaming mode for LA5032
Gerhard Sittig [Sun, 16 Oct 2022 10:35:08 +0000 (12:35 +0200)]
kingst-la2016: unbreak streaming mode for LA5032

The Kingst LA series models share the same streaming mode memory layout.
All channels' chunks are 16 bits wide. The previous version worked for
16-channel devices, this change unbreaks the 32-channel device LA5032.

This fixes the streaming aspect of bug #1805.

Reported-By: Roman Shishkin <redacted>
19 months agokorad-kaxxxxp: factor out ID response lookup in the models table
Gerhard Sittig [Fri, 16 Sep 2022 08:14:01 +0000 (10:14 +0200)]
korad-kaxxxxp: factor out ID response lookup in the models table

Introduce a model_lookup() routine so that the table iteration need not
get duplicated across several call sites.

19 months agokorad-kaxxxxp: use ID text prefix with optional version for RND models
Gerhard Sittig [Fri, 16 Sep 2022 08:07:14 +0000 (10:07 +0200)]
korad-kaxxxxp: use ID text prefix with optional version for RND models

This allows to match the "320-KA3005P" response text, and present the
"KA3005P" model name to users without the "320-" prefix.

19 months agokorad-kaxxxxp: support optional version after fixed ID response text
Gerhard Sittig [Fri, 16 Sep 2022 08:03:30 +0000 (10:03 +0200)]
korad-kaxxxxp: support optional version after fixed ID response text

The combination of a literal expected ID response, and an optionally
trailing version information that need not be part of the driver's
strict expectation, would be useful to handle the RND devices' prefix.

Extend the "strict ID response text check", accept an optional version
text before checking for exhausted input. This commit only introduces
the support code, does not change the set of supported models.

19 months agokorad-kaxxxxp: trim down list of supported models (renames RND models)
Gerhard Sittig [Thu, 15 Sep 2022 20:44:53 +0000 (22:44 +0200)]
korad-kaxxxxp: trim down list of supported models (renames RND models)

Remove expected ID response literals from the list of supported models
when the generic "vendor and name" approach matches. Remove duplicate
entries (those which only differed in firmware version numbers or in
trailing garbage) which were obsoleted by the generic match approach.

This user perceivably "renames" previously and still currently supported
RND devices. Presents the RND vendor's "320-" prefix before the "KA3005"
stem. Should be acceptable given that this is the vendor's article name.
Exclusively affects display texts, the user provided driver name which
addresses the PSU remains as it was before.

The table of supported models now contains no entry with a fixed wanted
response text. But the match logic keeps support for this condition, so
that future entries can use it when required. RND entries could use it
when the "320-" prefix is undesirable, but version numbers are not
stripped transparently by the match logic's implementation.