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.
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).
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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>.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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:
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.
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
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>
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.
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.
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).
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.
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.
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.
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.
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.
Gerhard Sittig [Thu, 15 Sep 2022 20:42:55 +0000 (22:42 +0200)]
korad-kaxxxxp: implement more generic ID response text checks
Either compare the device's response text for IDN queries against a
specific string literal (strict match, compatible with earlier driver
implementations). Or apply a more generic approach which expects to
find the vendor and model names, accepts optional version details,
and transparently deals with several quirks in the process.
Adjust user visible as well as developer centric diagnostics. The
fixed ID response literal became optional. Tell exact literal matches
from the matches of the generic vendor/device approach.
This commit only adds the support code, but does not modify the table
of supported models. Which results in the check logic to always use the
path which strictly matches the device's response against a literal.
The generic approach will only be taken when the supported models table
gets adjusted in future commits.
Gerhard Sittig [Thu, 15 Sep 2022 20:34:02 +0000 (22:34 +0200)]
korad-kaxxxxp: prepare more versatile ID response text checks
Add more quirks for IDN responses: Some devices would not report the
vendor in their response. Some devices suffer from trailing garbage.
Move IDN response text checks to a new model_matches() routine, stick
with the strcmp() implementation in this commit for compatibility.
This commit does not change the set of supported models, but prepares
the addition of more versatile IDN response checks in a future version.
Gerhard Sittig [Thu, 15 Sep 2022 20:28:32 +0000 (22:28 +0200)]
korad-kaxxxxp: unclutter table layout of supported models
Reduce the number of lines per item in the table of supported models
where appropriate. Only occupy two text lines for the rather lengthy
Velleman items. This shall simlify navigation in the models table.
Gerhard Sittig [Thu, 15 Sep 2022 20:24:11 +0000 (22:24 +0200)]
korad-kaxxxxp: eliminate numeric model ID in supported models table
Drop the first column in the table of supported models. Voltage/current
capabilities as well as quirks are immediately detected at scan time, no
other code paths outside of scan need to access that "model enum/index".
[ see a word-diff for the essence, a table column gets removed ]
Gerhard Sittig [Thu, 15 Sep 2022 20:18:42 +0000 (22:18 +0200)]
korad-kaxxxxp: eliminate numeric model ID (table index) in scan
Rephrase the successful lookup of a supported model by means of a
pointer to a models[] entry. Which eliminates the numeric index,
including the "sentinel" value which points outside of the table.
Use a signed integer for iteration over table items. Don't break
text lines between vendor and model fields, these fields form a
logical group from the user's perspective.
Gerhard Sittig [Thu, 15 Sep 2022 20:12:28 +0000 (22:12 +0200)]
korad-kaxxxxp: eliminate model check in OVP enabled quirk handling
Rephrase the check for the Velleman LABPS3005D quirk. Eliminate the
check for individual supported models in the main loop. The condition
gets detected at scan time already. Handling other affected models
becomes transparent.
Gerhard Sittig [Thu, 15 Sep 2022 20:07:25 +0000 (22:07 +0200)]
korad-kaxxxxp: add quirks flags to table of supported models
Out of the current set of supported models, the Velleman LABPS3005D is
the only device which requires special OVP enable handling. In future
implementations, more quirks could get identified or other models could
be affected. Add a quirks flags field to the models[] table, so that
other driver code paths need not care about individual models.
This commit only provides the flag. Calling code is not adjusted in this
commit, to reduce the diff size and simplify review. There are a lot of
"no quirks" additions in this commit already.
Gerhard Sittig [Thu, 15 Sep 2022 20:02:20 +0000 (22:02 +0200)]
korad-kaxxxxp: factor voltage/current capability out of models[] table
Move the number literals for supported voltage and current ranges and
their granularity out of the models[] table. Reference the ranges from
the models[] table by symbolic names, such that entries will read as
"a model which supports up to 30V and 5A", which is considered easier
to maintain. It's assumed that only few of these "templates" will be
required, the current set of supported devices gets away with 30V/60V,
and 3A/5A, and is able to express all of their combinations. See the
Korad KD6005, Tenma 72-2535, and Tenma 72-2550 models, which are the
only exceptions from the typical 30V/5A configuration.
Gerhard Sittig [Thu, 15 Sep 2022 19:54:12 +0000 (21:54 +0200)]
korad-kaxxxxp: reflow models[] table for capabilities comparison
The entries in the models[] table are wide, and occupy several text
lines each. Re-flow these lines such that channel count, voltage and
current capabilities will vertically align, to simplify the review of
which degrees of freedom the driver needs to actually support. As a
byproduct these phrases keep the IDN response text and the displayed
vendor and model names together on a text line. Which is useful for
grepping the source for user feedback.
It's assumed that listing every firmware version as a separate model
is both tedious, and rather fragile at the same time. It is to be seen
which of these models genuinely differ from all others, and whether
their IDN response is unique enough even if an incomplete match is
done on the response text.
[ see a word-diff, it's all whitespace, no behaviour has changed ]
Gerhard Sittig [Wed, 14 Sep 2022 17:52:48 +0000 (19:52 +0200)]
kingst-la2016: add another supported LA5016 model (bytes 0x0c 0x10)
User Daniel reports in bug #1799 that an LA5016 as of 2022-08 uses
magic byte values which were not listed in earlier implementations.
Add the very 12 (16) combination (in hex: 0x0c 0x10) which the user
reported. As well as 12 (0) for good measure -- most other models
have this "wildcard" entry, too.
Gerhard Sittig [Wed, 14 Sep 2022 17:50:01 +0000 (19:50 +0200)]
kingst-la2016: rephrase magic bytes in table of known models
Prefer the hex presentation for magic bytes retrieved from EEPROM to
identify Kingst LA models. Adjust the models[] array and diagnostics.
As a byproduct this keeps the table layout stable in future versions.
[ See a word-diff for the essence of the change. ]
Georg Hofmann [Tue, 13 Sep 2022 08:12:04 +0000 (10:12 +0200)]
korad-kaxxxxp: All received values are zero
Commit 5dfa77b5 introduced a regression in korad_kaxxxxp_get_value().
Positive non-zero return values from command transmission made the
routine fail for every invocation. Fixup the error check and advance
to response reception, do provide the values retrieved from the PSU.
Gerhard Sittig [Wed, 31 Aug 2022 15:37:05 +0000 (09:37 -0600)]
asix-sigma: check sdi before dereferencing a NULL pointer
The asix-sigma config_list() routine unconditionally dereferenced the
'sdi' pointer, which could be NULL. Properly check before dereferencing.
This issue was introduced in commit eabf9ca630f4. How to reproduce:
Gerhard Sittig [Sun, 21 Aug 2022 07:57:24 +0000 (09:57 +0200)]
input/vcd: do propagate parse error in file header
The vcd input module's parse_header() routine used the 'status' variable
in inappropriate ways. It was preset to false, then raised when the end
of the header was seen, and lowered when parse errors occurred. This made
parse errors go unnoticed because the flag always was raised at the end
of the header. The issue was introduced in commit 0ab36d2f5448.
Separate the "header seen" from "header valid" aspects. The "header seen"
is needed for loop control including resource management. The "valid" is
needed to propagate errors should they have happened at any time during
parsing.
Also adjust the process_buffer() and end() routines to cease processing
the input file's content after header parsing failed earlier. Which
addresses bug #1758 for VCD.
Gerhard Sittig [Thu, 3 Oct 2019 16:50:21 +0000 (18:50 +0200)]
scpi-dmm: prefer double over float data types more often
The 'float' data type uses 23 bits for the mantissa, which can express
some 6.9 decimal places. Some meters claim "6 digits" when in fact they
are 6.5 or so. Averaging over higher numbers of power line cycles (NPLC)
could additionally raise a meter's precision. Prefer double over float
for 6-digit devices already, just to err on the safe side.
The previous implementation only started using the double data type for
devices with 7 and more digits, and left a theoretical gap that's fully
closed now.
Gerhard Sittig [Sun, 14 Aug 2022 19:07:07 +0000 (21:07 +0200)]
ols: move sigrok channel creation from protocol.c to api.c
It's unexpected that several code paths redundantly create sigrok
channels, and that most of them reside in the protocol.c source file.
Concentrate channel creation in api.c instead in the scan() routine,
to remain aware during maintenance.
Fallback to the maximum channel count for SUMP compatibles, prefer
metadata gathered from the device when available, including quirks for
models which are known to deviate. Just setup the number during probe,
and create the channels at the end of scan() in common code.
Change the channel count struct member to unsigned while we are here.
Shorten a long comment line to not have to break it.
Gerhard Sittig [Sun, 14 Aug 2022 18:47:43 +0000 (20:47 +0200)]
ols: move device context creation from protocol.c to api.c
The get_metadata() routine was unfortunately named, and surprisingly did
more than its name suggested. Rename the routine to contain the ols_
prefix. Run communication to the device in protocol.c, but keep sdi and
devc creation in api.c where they are expected during maintenance. This
"unhides" where stuff is happening, and eliminates redundancy between
the models which support meta data to announce their features, and other
"compatibles" which are covered by generic fallback data.
Gerhard Sittig [Sun, 14 Aug 2022 18:27:25 +0000 (20:27 +0200)]
fx2lafw: add support for "probe names" scan option
Add support for the SR_CONF_PROBE_NAMES scan option. Optionally assign
user specified channel names instead of the driver's builtin names.
It's essential to create sdi and devc before scanning the probe names
spec. The previous logic which printed channel names to a local buffer
got replaced by a const table of channel names. This commit is a little
longer because checks are added, to make sure that future models with
more channels won't exceed the static const tables.
This implementation exclusively allows to specify logic channel names.
Analog channels keep the open coded naming pattern. Because the driver
supports different models with differing numbers of channels of several
types, covering analog channels in the "probe names" feature requires
more runtime effort to create the table of default channel names for the
specific device that was found. This remains as an option for a later
commit.
Gerhard Sittig [Sun, 14 Aug 2022 18:22:42 +0000 (20:22 +0200)]
asix-sigma: add support for "probe names" scan option
Add support for the SR_CONF_PROBE_NAMES scan option. Optionally assign
user specified channel names instead of the driver's builtin names.
This commit is a little more involved because channel names are also
referenced as external clock source. The lack of 'const' decoration in
the glib API and the presence of 'const' in the std_*() routines require
some intermediate storage and casts and duplicate length determination.
This is considered more desirable than a redundant length field in devc.
Gerhard Sittig [Sun, 14 Aug 2022 18:06:58 +0000 (20:06 +0200)]
strutil: add common parse logic for SR_CONF_PROBE_NAMES input specs
Add the public sr_parse_probe_names() and sr_free_probe_names() routines
so that device drivers can share a maximum amount of support code. The
input spec can either carry a list of names for individual signals, or
aliases can expand to a set of multiple signals which e.g. correspond
to a protocol or other popular/typical sets of signals. Which increases
usability. Order of items is arbitrary, recursion is not supported (yet
this internal implementation detail may change in a future version).
In the absence of an SR_CONF_PROBE_NAMES value the driver's list of
channel names is returned. Which yields completely backwards compatible
behaviour -- drivers can unconditionally call the parse routine. In the
presence of a configuration value the user spec is taken, aliases get
expanded (alias lookup is case insensitive).
Calling drivers can either have the list capped to a maximum size (pin
count is a natural limit), or get the result of whatever the user has
specified (dynamic size, grows as specs require). The user's probe names
by default get padded with the device's builtin probe names, unless the
spec starts with a '-' (dash), then exclusively the specified signal
names are used.
Calling code which resides in individual device drivers remains minimal.
Behaviour of individual drivers should be identical or very similar from
the user's perspective. The implementation is not tuned for performance,
the logic only executes once during device scan and is not sensitive.
This implementation supports the following aliases for maximum user's
convenience, covering the libsigrokdecode supported protocols with many
signals or with complicated names: ac97 i2c ieee488 jtag jtag-opt lpc
lpc-opt mcs48 microwire sdcard_sd seven_segment spi swd uart usb z80.
The "-opt" variants carry more optional signals which users may want to
inspect sometimes, while often the low logic channel count of typical
devices severely constraints how many signals can get assigned. Let
users pick what they prefer. A mix of a non-opt alias plus a few hand
listed extras is another option.
Adding more aliases is straight forward, and transparently benefts all
participating device drivers.
Outside of isolated inspection of a single protocol (special purpose
traffic recorders), combinations are useful as well to quickly assign
many signals in complex MCU setups which then require fewer adjustment
than full manual configuration:
Device drivers assign a fixed set of probe names during scan. Users can
rename previously created channels in the GUI as well as in the CLI,
though this is tedious, and depends on the application, as well as
depends on the names which the driver initially used to assign. Manual
assignment of protocol decoder inputs to device channel names is as
tedious.
Introduce the SR_CONF_PROBE_NAMES scan option, which assigns the user
provided names to the device's probes during scan already (for those
drivers which support the option). This commit declares the config key
but does not affect any driver yet.
Gerhard Sittig [Tue, 18 Jun 2019 17:06:49 +0000 (19:06 +0200)]
serial_hid: improve and tighten "find USB" for the HID transport
The .find_usb() method of the HID transport previously returned
connections which lacked the "hid/" prefix and chip type, thus could
later not be used with open() and data communication calls. Add the
missing decoration.
As a minor optimization, lookup the chip type and name from the caller's
VID:PID pair already if it's specific enough, still lookup the chip for
every enumerated device if the caller's VID:PID pair is unspecific.
Tighten the result set of the HID transport's USB search. Only return
connections which involve one of the supported chips. The other devices
very probably cannot be used to connect to measurement equipment anyway,
listing mice and keyboards and other unrelated stuff was found to be not
so useful.
Gerhard Sittig [Tue, 18 Jun 2019 17:26:04 +0000 (19:26 +0200)]
serial_hid: restrict .list() result set, supported chips only
The --list-serial output was excessively large for the HID transport,
listing mice and keyboards and other stuff that could never by used
for serial communication. Especially when one device provided multiple
interfaces, and on Windows where paths are rather long by default.
Limit the result set of the HID transport's .list() operation. Only
consider connections that we know how to communicate to (supported
chip type). The others are not usable anyway, so there is no point in
presenting them to the user.
Check pointers for validity before dereferencing them. This silences the
following compiler warnings:
../src/hardware/microchip-pickit2/api.c:275:8: warning: Access to field 'conn' results in a dereference of a null pointer (loaded from variable 'sdi')
if (!sdi->conn)
../src/hardware/microchip-pickit2/api.c:281:10: warning: Access to field 'samplerates' results in a dereference of a null pointer (loaded from variable 'devc')
rate = devc->samplerates[devc->curr_samplerate_idx];
../src/hardware/microchip-pickit2/api.c:287:11: warning: Access to field 'captureratios' results in a dereference of a null pointer (loaded from variable 'devc')
ratio = devc->captureratios[devc->curr_captureratio_idx];
Do inspect the return value of the routine which sends the command
before retrieving the response. This silences the following warnings:
../src/hardware/korad-kaxxxxp/protocol.c:179:3: warning: Value stored to 'ret' is never read
ret = korad_kaxxxxp_send_cmd(serial, "IOUT1?");
../src/hardware/korad-kaxxxxp/protocol.c:184:3: warning: Value stored to 'ret' is never read
ret = korad_kaxxxxp_send_cmd(serial, "ISET1?");
../src/hardware/korad-kaxxxxp/protocol.c:189:3: warning: Value stored to 'ret' is never read
ret = korad_kaxxxxp_send_cmd(serial, "VOUT1?");
../src/hardware/korad-kaxxxxp/protocol.c:194:3: warning: Value stored to 'ret' is never read
ret = korad_kaxxxxp_send_cmd(serial, "VSET1?");
../src/hardware/korad-kaxxxxp/protocol.c:202:3: warning: Value stored to 'ret' is never read
ret = korad_kaxxxxp_send_cmd(serial, "STATUS?");
Silence a compiler warning about not using an assigned value in later
instructions. This is about the EEVBlog 121GW meter's date and device
number in received serial packets, which are worth keeping around for
future versions of the driver.
../src/dmm/eev121gw.c:728:2: warning: Value stored to 'raw_serial' is never read
raw_serial = RB32(&buf[OFF_SERIAL_3]);
Gerhard Sittig [Sun, 16 Jun 2019 08:37:50 +0000 (10:37 +0200)]
dmm/bm86x: improve robustness of secondary display parsing
Return with unset MQ when parsing the number value for the secondary
display of BM86x fails. So that no invalid measurement result gets sent
to the session bus.
Reported-By: a helpful compiler warning
../src/dmm/bm86x.c:290:3: warning: Value stored to 'ret' is never read
ret = brymen_bm86x_parse_digits(&buf[9], 4, txtbuf,
Silence a compiler warning about assigning a value to a variable that's
not used in subsequent instructions. This 'have_chip' condition is worth
keeping around, in case the HID chip search code receives updates later.
Removing the assignment may complicate maintenance, or result in
incomplete diagnostics during research.
../src/serial_hid.c:1066:3: warning: Value stored to 'have_chip' is never read
have_chip = 1;
Drop assignments of values to variables which never took effect. Drop
assignments which strictly speaking were not required, but were added in
the past to silence warnings in different compiler versions.
../src/serial_bt.c:168:2: warning: Value stored to 'type' is never read
type = SER_BT_CONN_UNKNOWN;
../src/serial_bt.c:507:2: warning: Value stored to 'now_us' is never read
now_us = 0; /* Silence a (false) compiler warning. */
Shuffle variable declarations into the rough order in which they are
used in the function's body.