Gerhard Sittig [Mon, 6 Jan 2020 08:59:21 +0000 (09:59 +0100)]
input/csv: trim surrounding whitespace from header line channel names
When CSV import grabs channel names from the first line in the file then
the text strictly between column separators (a comma) was used. Which
resulted in channel names like " channel 1". Trim leading and trailing
space before unquote, to better fulfill most users' expectation. Users
still can quote the input data for special cases if desired.
Gerhard Sittig [Sun, 25 Apr 2021 08:03:47 +0000 (10:03 +0200)]
rdtech-dps: research to reduce serial comm transfer volume again
The DPS devices default to a rather low UART communication bitrate. The
generous retrieval of more Modbus registers than strictly necessary for
the periodic acquisition of analog channel values and state tracking may
or may not be an issue.
Instrument all call sites in api.c to the device state gathering calls
such that the protocol.c side transparently can reduce the transfer
volume depending on which level of detail the caller may expect given
its current context. Under optimal circumstances this might cut the
traffic in half, which DPS devices may benefit from.
This commit adds the infrastructure to potentially reduce transfer
volume, but does not change behaviour. The "config" reasons may need
further partitioning if Modbus register access really turns out to be
a severe bottleneck. The API lends itself to that extension easily. The
approach which gets prepared in this commit needs to get runtime tested
by those who got access to the hardware.
Gerhard Sittig [Sun, 25 Apr 2021 07:03:22 +0000 (09:03 +0200)]
rdtech-dps: introduce support for RD6006 and other Riden RD models
The RD devices differ from DPS devices in their default communication
bitrate (115200), register content endianess (BE), and register set
layout (addresses for registers). In either case 16bit registers get
accessed by means of Modbus communication over a serial channel. The
interpretation of the registers' values mostly is the same as for DPS
devices once a register with the same meaning got identified. Device
identification includes a 32bit serial number which DPS devices appear
to not provide.
All other product features are the same, and map to identical sigrok
mechanisms. That's why re-using the rdtech-dps driver to add rdtech-rd
support is considered desirable. This implementation shares all code
"above" the raw register addressing and raw value interpretation. All
logical processing, configuration interface, state tracking and data
submission to the session feed, are shared among the different device
types.
Declare support for the RD6006, RD6012, and RD6018 models. Their specs
were taken from the 2020.12.2 instruction manual. The driver was tested
with an RD6006 device (firmware version 1.28). Unfortunately automatic
device detection is not possible or will not be reliable, which is why
users need to specify the respective model by picking one of the two
drivers. Within a driver variant the device identification and use of
the device are automatically dealt with.
Gerhard Sittig [Tue, 13 Apr 2021 21:52:59 +0000 (23:52 +0200)]
rdtech-dps: layer separation between API and protocol, style nits
The existing power supply driver for Riden DPS/DPH devices unfortunately
duplicated intimate details of modbus communication and register layout
including interpretation of raw register values across several source
files. Do separate the physical transport and the register layout and
register fields interpretation layers. This brings the driver in line
with the usual api.c and protocol.c arrangement of responsibilities, and
prepares the future addition of other similar devices.
Address a few style nits while we are here. Include <config.h> in all
source files, and alpha-sort include directives. Address minor data type
nits. Reduce indentation in code paths. Propagate more error codes.
Update comments which lagged behind the code, adjust grammer (eliminate
"actual" false friends). Eliminate a few magic numbers and redundancies,
switch to the more recent endianess aware byte stream reader API where
beneficial, to eliminate redundant offset math.
Other nits seem to have gone unnoticed before: The indices of all sigrok
channels were identical (all zero). Signed print formats were used for
unsigned data.
This implementation compiles, but wasn't runtime tested due to lack of
hardware. A rough estimate of transfer volume and transport throughput
suggests that the 10ms cycle time no longer can be kept, may end up
around 25ms (40 cycles per second). This can get avoided by adding more
code to tell the configuration requests, the acquisition start, and the
measurements grabbing during acquisition apart. It's assumed though that
the 10ms glib poll interval did not translate to such fast measurement
gathering. The firmware may typically provide data at lower rates anyway.
The generic source code may look overly complicated or redundant at
first glance, but compilers' generated code will greatly get optimized.
Simplified maintenance because of reduced cognitive load is considered
more important.
Gerhard Sittig [Thu, 25 Feb 2021 20:31:21 +0000 (21:31 +0100)]
kingst-la2016: address trivial style nits (whitespace, braces, line length)
Improve readability by addressing the trivial style nits in the driver.
Break the channel list into two times eight instead of nine plus seven
items. Put braces around all branches if one of them has braces. Add
braces to multi line branches despite most of the branch just being a
comment -- it's still many lines. Break extra long text lines, adjust
the position of operators when single expressions span multiple lines.
Drop unnecessary parentheses around single variables and auto
incrementing pointer dereferences. Adjust whitespace especially for
pointer data types, and arith operators.
Helge Kruse [Sat, 30 Jan 2021 14:46:46 +0000 (15:46 +0100)]
kingst-la2016: Eliminate non-portable packed structs for USB transfer layout
Eliminate packed structs in the construction and in the reception of
USB transfers, since these are rather non-portable. Use common support
for endianess aware access to byte streams instead. This unbreaks the
driver for MinGW builds, and increases portability and maintainability
on all other sigrok supported platforms.
Helge Kruse [Sat, 30 Jan 2021 13:49:02 +0000 (14:49 +0100)]
kingst-la2016: Upload firmware to correct USB configuration 1
The ezusb_upload_firmware() routine opens the USB device and selects the
current configuration. The specified value must match the previously read
configuration descriptor. This commit unbreaks the firmware download for
MinGW builds which link against libusb-1.0.20-rc3-event-abstraction-v4.
Petteri Aimonen [Sun, 28 Feb 2021 13:32:08 +0000 (15:32 +0200)]
scpi-dmm: Gracefully handle meters that lack OPC command.
The SCPI standard requires OPeration Complete command,
but some Owon meters do not implement it. This commit
makes the probe try OPC once, and if it gets no reply
it assumes it is not supported.
Richard Allen [Sat, 16 Jan 2021 19:31:31 +0000 (13:31 -0600)]
gwinstek-gpd: Retry device identification on failure
Try the identification command up to three times
if the device responds with 'Invalid Character.',
which can happen if the device has buffered part
of a command but not executed it.
Gerhard Sittig [Tue, 2 Feb 2021 20:09:54 +0000 (21:09 +0100)]
scpi-pps: add R&S HMP2000 model specs
Re-use HMP4000 options and channel groups, only keep separate channel
specs for HMP2000 devices. HMP2030 has three identical 32V/5A channels.
HMP2020 has one 10A channel and one 5A channel.
Gerhard Sittig [Tue, 2 Feb 2021 20:07:29 +0000 (21:07 +0100)]
scpi-pps: adjust R&S HMP4000 current resolution for 10A channels
Specs published by R&S suggest that 10A channels support 0.2mA resolution,
while only 5A channels resolve to 0.1mA (up to 1A full scale, 1mA above 1A).
v1ne [Tue, 31 Mar 2020 18:21:47 +0000 (20:21 +0200)]
ols: Clear "disabled groups" flags before setting them
This fixes a bug where the channel group setting would not be overwritten in a
new run, but instead the channel group settings of both runs would be merged
together.
ols: Display actual expanded sample instead of the raw sample
While the raw sample is the actual received data, the expanded sample is the
crucial data I as a developer am interested in seeing. At least if I assume that
the sample expansion works.
Gerhard Sittig [Tue, 29 Dec 2020 17:31:38 +0000 (18:31 +0100)]
dmm/bm52x: unbreak build when serial comm is not available
Make another code path in the Brymen BM52x packet parser optional which
snuck in earlier and broke compilation when serial_comm dependencies are
not met.
Ideally the src/dmm/ parser code would not get built at all in that
case, but building a parser with reduced functionality and not using it
later because its callers are conditional is as good, and is what other
DMM packet parsers did in the past.
How to reproduce:
$ configure --without-libserialport --without-libhidapi --without-libbluez
$ make
Gerhard Sittig [Fri, 25 Dec 2020 11:47:01 +0000 (12:47 +0100)]
ftdi-la: work around missing USB strings during device probe
Some FTDI chip based products ship with EEPROM content which makes
libftdi fail to lookup the USB strings, which breaks the scan for the
device's presence. The previous implementation was strict and only
accepted the absence of a serial number. This implementation also copes
when vendor and model cannot be gathered from the device, and provides
fallback values based on VID:PID numbers.
Also factor out a magic number for string lengths. Stick with dynamic
allocation since 3x 32bytes would be rather huge a local stack use, and
future maintenance might bump that string length again.
[ gsi: magic number in one spot, bounded string assignment, style nits ]
Introduce a text to number conversion routine which supports non-decimal
bases and optional suffixes, but returns unsigned results and thus covers
a larger range of values. This kind of amends commit 97aa41e9b59c which
introduced the sr_atol_base() routine.
Gerhard Sittig [Tue, 3 Nov 2020 17:25:18 +0000 (18:25 +0100)]
driver_list: unbreak list of builtin drivers for LTO configurations
Check for the availability of the "no_reorder" linker attribute, which
keeps the list of builtin drivers in shape on LTO enabled build setups.
Keep backwards compatibility for platforms which lack support for the
"no_reorder" attribute. Phrase the implementation such that other
keywords as well as user provided external specs are possible.
Gerhard Sittig [Wed, 30 Sep 2020 07:59:32 +0000 (09:59 +0200)]
serial-dmm: add support for the Brymen BM820s family
The BM820s series uses the same 10000 counts protocol as BM520s does,
but lacks the capability of recording measurements. Re-use the bm52x
DMM packet parser, but don't register the config get/set/list and
acquisition start callbacks.
It turns out that the packet request and packet validity check routines
need to be individual, since 0x82 is used instead of 0x52 as a magic
number in some places. Fortunately the complex payload parser is shared
among BM520s and BM820s series. This was tested with a BM829s meter.
Gerhard Sittig [Thu, 24 Sep 2020 21:01:26 +0000 (23:01 +0200)]
dmm/bm52x: add support for recorded measurements (memory data sets)
Extend the BM52x packet parser, add config get/set/list code to handle
the data source property. Either let the common serial-dmm code run the
acquisition of live readings, or locally retrieve the selected "session
page" and forward its measurements to the session bus. These separate
code paths are required because the protocol differs a lot between these
modes, a totally different set of requests and responses is involved,
response interpretation logic is impossible to share between live and
recorded measurements.
Gerhard Sittig [Thu, 24 Sep 2020 19:45:51 +0000 (21:45 +0200)]
dmm/bm85x: introduce DMM packet parser for Brymen BM850(a/s)
Implement a DMM packet parser for the BM850s protocol. This involves
variable length responses, which recently became a common serial-dmm
feature. Register the new parser under the "brymen-bm85x" device name.
This obsoletes the brymen-dmm driver which announces as "brymen-bm857".
This implementation was tested with the BM859s meter.
The text to number conversion with precision detection resolves the
last remaining issue of bug #1611.
Gerhard Sittig [Thu, 24 Sep 2020 19:18:21 +0000 (21:18 +0200)]
strutil: add text to float conversion which also gets precision from text
Provide a common string helper routine which converts input text to a
double precision floating point number, and also gets its precision in
the process.
Gerhard Sittig [Thu, 24 Sep 2020 14:33:20 +0000 (16:33 +0200)]
serial-dmm: more DMM parser callbacks (open, var length, config, start)
Extend the serial-dmm driver's common infrastructure to support more
per-parser (per-model) specific extensions. Add support for variable
length packets (motivated by BM85x), and pass the packet length to
parsers which accept it. Add callbacks which run after the COM port got
opened (motivated by BM85x). Add support for additional configuration
get/set/list properties (motivated by BM52x), including a hook into the
acquisition start and a state container which is owned by the parser.
Device specific acquisition start can check its local state which can
store the result of previous config get/set requests, and can arrange
for a different receive routine to execute (motivated by BM52x). The
default code path will execute serial-dmm's receive routine which keeps
invoking the DMM's packet parser for each registered display.
Prefer double precision values in the new parser callbacks. Also fixup
some data type issues: Use unsigned types for length and size specs as
well as timeouts, don't promote false booleans to NULL pointers, reduce
malloc() argument redundancy. Rephrase some instruction grouping and
update comments to simplify future maintenance. Get the current time
just once for improved consistency in the packet re-request code path.
Rename identifiers in the data reception path to improve readability.
Gerhard Sittig [Thu, 24 Sep 2020 14:29:06 +0000 (16:29 +0200)]
serial: extend stream detect for variable length packet checkers
The previous implementation of the packet detection in a serial stream
assumed that all packets are of equal length which is known in advance.
Extend the packet validity check interface such that caller provided
callbacks can either decide that the input is valid or invalid (terminal
decision), or request more receive data before a decision can be made
(deferral, coverring variable length packets, with a minimum size to
cover the header before a length becomes available and the total packet
length is known).
This commit extends the API, and adjusts the call sites to not break the
compilation. Actual variable length checkers are yet to be done. Improve
readability while we are here: Better reflect the purpose and units of
variables in their identifiers. Tweak diagnostics messages, update
inline and doxygen comments.
Gerhard Sittig [Thu, 22 Oct 2020 17:27:06 +0000 (19:27 +0200)]
input/vcd: fix a divide by zero bug in the analog-only case
When the input data exclusively contained analog data, then creation of
the submit buffer for logic data caused a division by zero. Fix the
create_feed() routine.
Gerhard Sittig [Sat, 17 Oct 2020 10:16:49 +0000 (12:16 +0200)]
input/vcd: suggest downsampling to users for reduced resource consumption
Naive creation of VCD files with inappropriately fine timescale specs
results in excessive resource consumption due to libsigrok's assumption
of a constant rate stream of sample data. A workaround is available and
documented, but users need to become much more aware.
Implement a reliable check for wasteful input data situations which
depends on the reception of _all_ input data, and can only alert users
late after potentially spending lots of time and assuming that available
resources allow completion of the import. Users could miss that check's
outcome.
Also implement early checks which (necessarily) are based on weaker
conditions, to already raise user's awareness while data import still is
executing. Phrase these early checks as computationally inexpensive as
possible, to not affect the main task of data import too much. Avoid
false positives by balancing the desire for early emission of messages
and picking appropriate conditions to test for.
This commit implements the foundation for early estimates and reliable
terminal checks, as well as the emission of messages which support users
and allow a more effective use of the file format. The specific limits
and tested conditions still may benefit from more tuning in the future.
The input module logic in this commit emits an information for harmless
cases, and emits warnings for "severe" cases where default option values
or incomplete user specs result in several orders of magnitude higher
resource consumption than necessary. GUI users may not notice, but the
library cannot help that given the current infrastructure -- the library
stricly does as the application tells it to, according to user input.
The best use is to run the CLI's --show feature on VCD files of unknown
content, to get an idea how to most appropriately configure a subsequent
file import. An alternative is to open the VCD file before import, check
the timescale in the header and the last two timestamps, to get an rough
estimate of a useful downsample factor.
This is motivated by but does not resolve bug 1624.
Gerhard Sittig [Sat, 17 Oct 2020 08:42:56 +0000 (10:42 +0200)]
input/vcd: unbreak U and - values for single bit input data
The previous implementation already mapped L/H/U/- literals for input
data values to the 0/1/0/0 logic levels which sigrok can handle. But
missed these literals in the condition which dispatches real/integer,
bit vector, and single bit data types. Which made VCD import fail for
some of the files in the SpinalWorkshop repo.
Extend the test condition for single bit values. This unbreaks the
import of the Apb3TimerTester.vcd and ApbPwmTester.vcd files, which
contained phrases like these:
Timo Kokkonen [Mon, 5 Oct 2020 09:04:57 +0000 (02:04 -0700)]
rigol-dg: Add device/firmware specific quirks support.
DG800/DG900 units seems to have issues with counter implementation:
- About 1 second delay is needed after enabling or disabling the counter.
Otherwise unit stops responding properly (start seeing USB errors).
- Second channel and counter cannot be enabled simultaneously.
Gerhard Sittig [Tue, 6 Oct 2020 17:26:36 +0000 (19:26 +0200)]
itech-it8500: avoid "new" as a variable identifier
Strictly speaking the "new" identifier is not a reserved word. Still
it's good practice not to use it for variables in C language sources.
Rename variables to "old_bit" and "new_bit" for consistency.
Gerhard Sittig [Tue, 6 Oct 2020 17:18:42 +0000 (19:18 +0200)]
itech-it8500: declaration nits
Rearrange the order of declarations in the protocol.h header. Start with
packet layout, continue with requests (commands), then responses (status),
before the device context and the set of routines.
Rename the status codes to STS_* in contrast to CMD_* codes. Use an enum
for different byte values, leave defines for packet sizes et al. Phrase
bit fields in terms of bit numbers not byte values.
Total nit: Change the breaks in the long list of add_source() args. Keep
event type and timeout together, similar to callback and its data.
Explicitly "break the flow" when internal status gathering fails, to
reflect that an error path is taken and the config call will fail. The
conditional assignment of response data in case of success could be
slightly misleading (it was to me during review).
Eliminate a goto which kind of circumvented the optional transmission of
a request to the device. Instead test whether a command was filled in to
determine whether a command needs to get sent.
Additionally BK Precision 8500 series loads (models 8500, 8502, 8510,
8512, 8514, 8518, 8520, 8522, 8524 & 8526) should work as well.
As ITECH is the OEM manufacturer for these BK Brecision models.
Return SR_OK in case of successful transmission of a packet request. The
previous implementation passed the serial layer's verbatim return value,
which was non-negative non-null (read: above zero) in case of success,
which is none of the expected return codes of a packet request routine.
This amends commit 379e95c587e1d and completes the adjustment which was
started in commit a4be2b327be8. The issue has gone unnoticed in the past
since it took not effect. The serial-dmm caller only tested for negative
return values.
Gerhard Sittig [Sun, 4 Oct 2020 17:48:42 +0000 (19:48 +0200)]
input/csv: trim cell content before conversion
Trailing whitespace in CSV cells broke the text to number conversion.
Trim the text content of cells before processing it. This is useful and
actually essential for data cells, and does not harm titles in header
lines, neither will it affect column format specs.
How to reproduce:
$ echo ' 3.14 , 2' | \
sigrok-cli -i - -I csv:header=false:column_formats=2a
sr: input/csv: Cannot parse analog text 3.14 in column 1 in line 1.
Timo Kokkonen [Sat, 3 Oct 2020 23:35:10 +0000 (16:35 -0700)]
rigol-dg: Fix reading current output signal duty cycle value.
Reading output signal duty cycle value didn't always work, since it relied
on old (cached) information about the currently active waveform. Changed to
always query channel status so this won't happen anymore.
Gerhard Sittig [Fri, 2 Oct 2020 09:18:57 +0000 (11:18 +0200)]
pce-322a: unbreak send_command() return code
Data was sent to the serial port, and the non-zero positive write length
was mistaken as an error, since it did not match the SR_OK code's value.
This snuck in with commit 379e95c587e1d in 2017-08.
Rephrase the check for successful serial writes in the pce-322a driver.
Pass on error codes from the serial layer in verbatim form. Check for
the exact expected write length and derive SR_ERR_IO upon mismatch. Do
return SR_OK upon success.
Reported-By: Michael Ströder <redacted> Tested-By: Michael Ströder <redacted>
Gerhard Sittig [Sun, 27 Sep 2020 10:09:47 +0000 (12:09 +0200)]
rigol-dg: reduce redundancy in malloc() calls
No need to duplicate the data type, just allocate enough memory to
hold the variable's value. Shuffle the order of items in the array
size calculation (number of items times the size of an item).
This implements support for Rigol DG1000z series digital signal
generators. Driver provides basic control via channel groups
("1", and "2"). Acquisition returns data from the built-in
frequency counter.
Ralf [Tue, 25 Aug 2020 06:19:18 +0000 (08:19 +0200)]
scpi: accept numbers like 4.0000E3 as integer value
MSO5000 returns memory depth value in that format, e.g.
sr: [04:21.491949] scpi_vxi: Successfully sent SCPI command: 'ACQ:MDEP?'.
sr: [04:21.501463] scpi: Got response: '4.0000E+03', length 10.
[ gsi: drop redundant assignment and parens, amend diag message ]
Gerhard Sittig [Sun, 27 Sep 2020 06:01:44 +0000 (08:01 +0200)]
serial: lower severity of failed stream detect message
Reduce the message's log level from ERR to INFO when the serial stream
detect routine cannot find a valid packet. Although an error code gets
returned, the condition need not be fatal (can be the result of trying
several peers before success or finally giving up). Let callers decide
on the severity of failure to detect a specific device's presence, and
provide more context in their message which is more helpful to users.
Interested readers still get the message at slightly raised log levels.
This avoids confusing user perceivable situations like these:
$ sigrok-cli --scan
sr: serial: Didn't find a valid packet (read 0 bytes).
sr: serial: Didn't find a valid packet (read 0 bytes).
The following devices were found:
demo - Demo device with 13 channels: D0 D1 D2 D3 D4 D5 D6 D7 A0 A1 A2 A3 A4
Gerhard Sittig [Sun, 27 Sep 2020 05:50:14 +0000 (07:50 +0200)]
ols: more robust device reset in acquisition stop
Use the existing ols_send_reset() routine because acquisition
termination can get initiated in several code paths. Make sure the
device will cease activity whatever state it happens to be in. This
amends commit 6d8182b643ae.
Ben Gardiner [Tue, 22 Sep 2020 03:27:40 +0000 (03:27 +0000)]
ols: send CMD_RESET on acquisition stop
Sending CMD_RESET will interrupt armed/untriggered acquisitions which is
very useful in Pulseview sessions since, without this, a next 'run' will
hang.
The reference impedance for dBm measurements comes in an unexpected
format. Isolate the 4..1200 Ohms value, ignore the (inappropriate?)
"0." and exponent parts of the response. Clearly reflect that Ohms
values are seen in different contexts (dBm reference, continuity,
resistance).
Reword comments in the BM850 response parser's code path for dBm
measurements. The reference value is shown when the function is entered
(verified here) or when the reference value changes (haven't seen this
here but a comment in the previous implementation said so).
Gerhard Sittig [Mon, 21 Sep 2020 18:32:21 +0000 (20:32 +0200)]
brymen-dmm: unbreak temperature response parsing
The BM850s temperature function response includes the C/F unit in an
unexpected position ("0.0272CE+3") which breaks number conversion. Drop
the C/F unit to unbreak the conversion.
This was observed with BM859s. Absence of the C/F unit in the response
is fatal in this implementation. If other meter firmware versions or
models don't suffer from that issue, the removal must be silent and
non-fatal.
Gerhard Sittig [Mon, 21 Sep 2020 18:20:13 +0000 (20:20 +0200)]
brymen-dmm: rephrase bfunc and value text parsing
When the BM850s response packet's payload gets interpreted, the DLE/STX
transport envelope is not of interest. Rephrase the bitfield inspection
to better reflect that 'bfunc' indicators get accessed (match the vendor's
documentation). Rephrase the calling parse routine to unobfuscate the text
field access. Unclutter assignments for the analog feed. Use a shorter
layout in debug messages, reflect raw input data and conversion results.
Gerhard Sittig [Mon, 21 Sep 2020 17:57:32 +0000 (19:57 +0200)]
brymen-dmm: improve text to number conversion robustness, signed OL
The BM850(a/s) response packets are a mix of binary and text content.
The text part of it is _not_ a regular ASCIIZ string. Enforce the NUL
termination before running standard C library string routines on it.
Rephrase the conversion routine to become more C idiomatic.
Also check the optional sign for overflow conditions, return either
positive or negative infinity as a result.
Gerhard Sittig [Sun, 20 Sep 2020 07:33:35 +0000 (09:33 +0200)]
brymen-dmm: style nits, apply comm param defaults, low battery warning
Rephrase how the default serial communication parameters get applied.
Preset the variable to the default value and let optional user provided
specs override these. This avoids an extra check which is difficult to
read and highly redundant. Add a comment for raised awareness that a
default port spec is undesirable because it's unreliable.
Raise the severity of low battery messages. It's worth warning the user
because measurements could be inaccurate.
Reduce indentation in continuation lines of a long routine signature,
and drop an empty line in a short struct while we are here.
Gerhard Sittig [Sun, 20 Sep 2020 07:23:45 +0000 (09:23 +0200)]
brymen-dmm: unbreak BM85x communication by pulsing RTS after COM port open
Either the Brymen meters in the BM850s series or their cables require an
RTS pulse to wakeup, without it there won't be a response during scan or
when requesting measurements. Follow the vendor's documented sequence for
a low RTS pulse after opening the serial port and before communication to
the device.
Gerhard Sittig [Sun, 20 Sep 2020 07:14:01 +0000 (09:14 +0200)]
serial: add routine to manipulate handshake state (RTS, DTR)
Introduce a routine in libsigrok's internal serial layer which lets
applications manipulate the state of handshake signals (RTS and DTR)
after the serial port got opened and configured. This allows for timed
pulses which cannot get expressed with static "rts=1" etc phrases in
parameter strings, and allows handshake signal control while leaving
bitrate and frame format untouched. Applications specify which signals
to modify while other signals remain as they are (ternary input).
Do implement the signal manipulation in the libserialport transport,
do nothing and silently pass in the HID and BT transports. These can
get extended later as the need arises, depending on the HID chips' and
RFCOMM peers' capability to control these signals. This extension is
transparent to application code (acquisition device drivers).
Gerhard Sittig [Sun, 20 Sep 2020 07:38:45 +0000 (09:38 +0200)]
serial: rephrase check for speed (bitrate) in parameter string routine
Use positive logic, put the error path for an unavailable value where
the check for its availability is. Do the regular activity on available
values in the straight code path with lesser indentation. Also group the
bitrate, frame format, and handshake params when breaking text lines.
Gerhard Sittig [Wed, 16 Sep 2020 19:25:33 +0000 (21:25 +0200)]
dmm/bm52x: introduce support for Brymen BM525s
Introduce a bm52x DMM packet parser which is modelled after the bm86x
implementation, and hook it up to the serial-dmm driver. This supports
the live readings (real-time download) of the Brymen BM525s logging DMM.
The timing follows the vendor documentation (0.5s between requests, and
4.0s absolute timeout after request transmission). Reading previously
recorded data (memory data sets) unfortunately does not fit well into
the serial-dmm approach, and needs to get addressed differently later.
Gerhard Sittig [Sun, 13 Sep 2020 14:35:59 +0000 (16:35 +0200)]
input/csv: provide double precision values to session feed
Common conversion support code accepts double precision input data for
analog packets. Use the 'double' data type in the CSV input module to
feed sample data to the session bus.
Gerhard Sittig [Sun, 13 Sep 2020 06:34:45 +0000 (08:34 +0200)]
analog.c: rephrase analog feed to float conversion routine
Rephrase the sr_analog_to_float() routine to further reduce redundancy.
Check early for a match of the input data and result format, to grab the
raw data without conversion in that case. Handle optional scale/offset
calculation in that fast code path, too.
Unify the instructions which convert input data from either integer or
floating point presentations to the result format. Use common stream
readers to retrieve input data in several formats, which eliminates
local conversion buffers. Move common sub-expressions (scale/offset) out
of loops. Run more calculations on double precision data before results
get trimmed to single precision.
Add and extend comments to improve future maintenance. Include (terse)
details of unsupported input data presentations in error messages.
This implementation was neither tuned nor measured for performance.
There still is a lot of redundancy among the branches which handle a
specific input data type. Rephrasing that approach interacts with the
yet to be done performance tuning, thus needs to get addressed later.
The current phrases' verbosity is believed to improve readability.
Gerhard Sittig [Sat, 12 Sep 2020 06:13:21 +0000 (08:13 +0200)]
libsigrok-internal.h: add more endianess aware stream reader routines
Add endianess aware readers including address incrementing variants for
those intrinsic data types which were missing in the previous version
yet are needed for sr_analog_to_float() adjustment.
Also move the 24bit reader to its position in the sort order.
Gerhard Sittig [Tue, 8 Sep 2020 19:07:33 +0000 (21:07 +0200)]
tests/analog: add more tests for analog feed to float array conversion
Extend test coverage for the sr_analog_to_float() conversion routine.
Pass data which is encoded in native, little and big endian format to
the routine. Pass single and double precision floating point data, and
integer data in different unit sizes and signedness. Cover scale/offset
calculations as well.
Also cover expected failed conversion for unsupported combinations of
input data format details (half/quad precision float, u64 integer).
Adjust the grouping of test cases in the sequence while we are here.
Move SI prefix, unit, and rational number related tests out of the
analog-to-float conversion group.
Timo Kokkonen [Tue, 8 Sep 2020 00:33:07 +0000 (17:33 -0700)]
analog.c: sr_analog_to_float(): Support for receiving double values.
Unbreak the conversion of input data in the floating point format when
the input data's format does not match the host's internal presentation,
thus grabbing raw data cannot be done.
Also accept the input data in double precision format which was not
supported before. Check for unsupported unit size values and emit an
error message similar to the integer code path.
This is motivated by bug #779 but does not resolve it. Adjusts common
conversion support, but sticks with single precision return data type
for API compatibility.
We pass no message, so use ck_assert instead of ck_assert_msg. This
results in an error with check 0.15:
tests/strutil.c:157:2: error: too few arguments to function '_ck_assert_failed'
157 | ck_assert_msg(saved_locale != NULL);