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 379e95c587 and completes the adjustment which was
started in commit a4be2b327b. The issue has gone unnoticed in the past
since it took not effect. The serial-dmm caller only tested for negative
return values.
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.
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.
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 379e95c587 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 <michael@stroeder.com>
Tested-By: Michael Ströder <michael@stroeder.com>
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.
Supported models: DG1022Z, DG1032Z, DG1062Z
[ gsi: added some coding style adjustment ]
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 ]
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
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 6d8182b643.
Sending CMD_RESET will interrupt armed/untriggered acquisitions which is
very useful in Pulseview sessions since, without this, a next 'run' will
hang.
Signed-off-by: Ben Gardiner <ben.l.gardiner@gmail.com>
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).
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.
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.
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.
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.
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.
This fixes bug #1595.
Reported-By: Karl Palsson <karlp@tweak.net.au>
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).
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.
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.
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.
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.
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.
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.
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);
The Saleae Logic exported files (Logic2 digital format) don't contain a
samplerate, so users need to specify the value. For values smaller than
the samplerate that was used during the capture undersampling will take
place. An implementation detail of the input module could result in
incorrect timing of sample values in the session feed. In extreme cases
none of the periods between signal edges qualified for submission. In
that case no sample data was sent to the sigrok session at all.
$ sigrok-cli -i digital_1.bin -I saleae:samplerate=1000
Keep the very timestamp at hand when the last sample data was submitted.
Only advance that timestamp when more sample data was sent. This avoids
the accumulation of timing errors for undersampling scenarios, and does
forward undersampled input data when the user provided sample period has
passed.
This fixes bug #1600.
The korad response read routine clears the receive buffers, so callers
don't have to. This amends commit d2cc60bd45.
The acquisition timeout is handled by common sw_limits support. Remove
the no longer referenced literal. This amends commit 3f9b48ae5f.
The Korad protocol relies on unterminated request and response strings,
which works well enough for fixed length acquisition and status queries.
But the variable length replies to identification requests suffered from
an implementation detail in the receive routine. A large timeout must be
used because supported devices reportedly are slow to respond. There is
no simple yet robust condition to detect the response's completion. The
scan code must prepare for the maximum response length across the set of
supported devices. Unfortunately the maximum amount of time was spent
waiting for the response to occupy the provided response buffer, before
a long total timeout expired.
Rework the korad driver's helper routine which gets a variable length
non-terminated text string. Keep the long initial timeout, and keep
iterating in that initial phase to quickly detect when response data
became available. But terminate the read sequence after a shorter period
without receive data after some initial receive data was seen. Assume
that identification responses get transferred at wire speed and without
additional delays beyond bitrate expectations. Acquisition and status
responses shall not be affected by this change.
This speeds up the scan for devices from roughly 5s to some 0.1s on
newer devices (KA3005P v5.5) and 0.5s on older devices (KA3005P V2.0).
This commit also addresses an issue in the response text termination,
where partial responses contained undefined data. The previous version's
return value was unspecific: Negative for fatal errors, but either zero
or non-zero for successful reads, with no way for callers to learn about
the received amount of data. The rephrased version always returns the
amount of received data, and adds internal documentation which discusses
the implementation's constraints and the motivation for the approach.
This is a modified version of the initial implementation which was
Submitted-By: Karl Palsson <karlp@tweak.net.au>
Cleanup style in the korad driver's scan() routine. Keep declarations
out of code blocks. Reduce redundancy and improve robustness in the
response buffer length calculation. Reduce clutter and group related
instructions together. Unobfuscate result checks, and keep the result
at hand (for diagnostics, or error propagation). Unobfuscate string
comparisons in the model ID lookups, terminate the search upon match.
Use a not so terse name for data that gets referenced at rather distant
locations.
Keep the optionally available serial number at hand, to present it to
users when desired. This aspect was
Reported-By: Karl Palsson <karlp@tweak.net.au>
The previous implementation of the cleanup() routine in the saleae input
module kept user specified options, but lost the previously created list
of sigrok channels. Keep it.
Also make sure that reset() voids the previous copy after grabbing its
value. To not unexpectedly release resources which still get referenced.
This shall unbreak file-reload.
Stop using the unusal "mixed" mode (local interface available during
remote operation) for HMP4000, applications may not be prepared for this
use case. Use traditional "remote" and "local" modes instead. This change
also ends remote mode after the application is done using the device.
List both vendor names "HAMEG" and "ROHDE&SCHWARZ" in the scpi-pps
driver, either responses were seen for HMP4000 devices. Unfortunately
vendor names don't support regex matches, so they require individual
profile items. The items also "violate" the alpha sort order in the list
of profiles, but keeping the series' models together is more important.
Add a declaration for the HMP4030 device which re-uses the HMP4040 data
but open codes the smaller channel count. Ideally the .probe_channels()
routine would receive the scpi_pps item as a parameter, and could yield
model specific result data from common information for the series. The
implementation in this commit is the least intrusive approach until
something better becomes available.
This shall cover the whole HMP4000 series:
https://www.rohde-schwarz.com/product/hmp4000
This commit introduces initial support for the HMP4040 power supply by
Rohde & Schwarz. It allows to configure the device and "statically" read
back current state. Automatic status updates with per-channel details
are not available yet (common support is missing).
[ gsi: drop status update remainder, address minor style nits ]
Reference the vendor's Windows specific "driver" download for the
CP210x chip with a non-default VID:PID. Provide an example how to
assign the Linux driver to that device (interactive, no udev rule).
In the current implementation the "flags" are exclusively used for
captures. Prepare the introduction of device flags by renaming the
capture related flags which are specific to an operation.
Reviewed-By: Wolfram Sang <wsa@kernel.org>