Commit Graph

5477 Commits

Author SHA1 Message Date
Timo Kokkonen b1eb94bbef 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.
2020-10-06 22:04:42 +02:00
Gerhard Sittig 92cd85149a 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.
2020-10-06 22:02:20 +02:00
Gerhard Sittig 8c8fff4773 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.
2020-10-06 22:02:20 +02:00
Gerhard Sittig 78b07caf11 itech-it8500: rephrase config get/set/list, reflect error paths
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.
2020-10-06 22:02:20 +02:00
Timo Kokkonen f21b6983e8 itech-it8500: ITECH IT8500 series DC electronic load driver.
This driver supports ITECH IT8500 series electronic loads:
 IT8511+, IT8511A+,
 IT8512+, IT8512A+, IT8512B+, IT8512C+, IT8512H+,
 IT8513A+, IT8513B+, IT8513C+, IT8514C+, IT8514B+, IT8516C+

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.
2020-10-06 22:02:20 +02:00
Timo Kokkonen c16effaedc itech-it8500: Initial driver skeleton. 2020-10-06 22:02:20 +02:00
Timo Kokkonen 34ce5b0439 hwdriver: New entries for DC Load "CW" (Power) and "CR" (Resitance) modes.
Added following new entries:
	- SR_CONF_POWER
	- SR_CONF_POWER_TARGET
	- SR_CONF_RESISTANCE_TARGET
2020-10-06 22:02:20 +02:00
Gerhard Sittig d7838e4804 dmm/metex14: unbreak packet request helper return code
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.
2020-10-06 20:59:27 +02:00
Gerhard Sittig 1f8ef363cb README.devices: add JTAGulator section for Logic Analyzer mode
Manual activity is required to enable the SUMP protocol support on the
JTAGulator. Link to the vendor's wiki article for users' convenience.
2020-10-06 20:32:04 +02:00
Gerhard Sittig cd11e33c5d 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.
2020-10-04 20:00:16 +02:00
Timo Kokkonen d999f2b61e 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.
2020-10-04 13:00:59 +02:00
Timo Kokkonen 9ce14905cb rigol-dg: Add Rigol DG800 and DG900 series support.
This adds support for all Rigol DG800/DG900 series models.

DG800 series: DG811, DG812, DG821, DG822, DG831, DG832
DG900 series: DG952, DG972, DG992
2020-10-04 13:00:35 +02:00
Timo Kokkonen feeafbc003 udev: Add Rigol DG800 and DG900 series VID/PID. 2020-10-04 13:00:28 +02:00
Gerhard Sittig a4be2b327b 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 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>
2020-10-03 07:20:00 +02:00
Gerhard Sittig 5a0303474c 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).
2020-09-28 09:11:02 +02:00
Timo Kokkonen 4c98253dba udev: Add Rigol DG1000z Series VID/PID. 2020-09-28 09:11:02 +02:00
Timo Kokkonen 02feeb30b9 rigol-dg: Initial Rigol DG1000z driver implementation.
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 ]
2020-09-28 09:08:37 +02:00
Timo Kokkonen 068db0fbe6 rigol-dg: Initial driver skeleton. 2020-09-28 09:03:37 +02:00
Timo Kokkonen 63eec38073 hwdriver: Add SR_CONF_DUTY_CYCLE & SR_CONF_PHASE. 2020-09-28 09:02:52 +02:00
Ralf 2dddd5bd5e 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 ]
2020-09-27 12:51:39 +02:00
Gerhard Sittig 0c52026459 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
2020-09-27 12:33:19 +02:00
Gerhard Sittig 7dd1dd9f7d 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 6d8182b643.
2020-09-27 07:53:09 +02:00
Ben Gardiner 6d8182b643 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.

Signed-off-by: Ben Gardiner <ben.l.gardiner@gmail.com>
2020-09-24 12:54:32 +00:00
Gerhard Sittig 8e79890770 brymen-dmm: unbreak dBm reference impedance interpretation
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).
2020-09-21 21:37:06 +02:00
Gerhard Sittig 3f8453b274 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.
2020-09-21 21:29:43 +02:00
Gerhard Sittig 66b349841a 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.
2020-09-21 21:29:27 +02:00
Gerhard Sittig 56213aa027 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.
2020-09-21 19:57:32 +02:00
Gerhard Sittig 11addc897a 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.
2020-09-20 10:44:20 +02:00
Gerhard Sittig 648f32d119 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.

This fixes bug #1595.

Reported-By: Karl Palsson <karlp@tweak.net.au>
2020-09-20 10:44:20 +02:00
Gerhard Sittig 3ad30b4e19 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).
2020-09-20 10:44:20 +02:00
Gerhard Sittig b1184024fe 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.
2020-09-20 10:42:54 +02:00
Gerhard Sittig 400bc4ffab 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.
2020-09-19 12:52:41 +02:00
Gerhard Sittig abcb13855f serial-dmm: only do bytes to text conversion at higher log levels
Check the current log level before starting the potentially expensive
bytes to text conversion for a debug message (dump DMM packets).
2020-09-19 12:32:35 +02:00
Gerhard Sittig ce3fe37969 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.
2020-09-18 16:42:37 +02:00
Gerhard Sittig e62b284c1c 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.
2020-09-18 16:42:37 +02:00
Gerhard Sittig e4bcc63de6 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.
2020-09-18 16:42:37 +02:00
Gerhard Sittig 6205515cc8 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.
2020-09-18 16:42:37 +02:00
Timo Kokkonen f37f11ec6b 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.
2020-09-18 16:42:37 +02:00
Jiri Slaby 505a55f789 tests: strutil, use ck_assert
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);
2020-09-15 08:56:21 +02:00
Gerhard Sittig 5208214739 input/saleae: improve L2D undersampling, do provide sample data
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.
2020-09-02 19:52:44 +02:00
Gerhard Sittig 565c8c3545 korad-kaxxxxp: remove obsolete code (clear before read, timeout literal)
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.
2020-09-01 17:15:54 +02:00
Gerhard Sittig d2cc60bd45 korad-kaxxxxp: speed up scan process, rephrase response read routine
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>
2020-09-01 17:11:36 +02:00
Gerhard Sittig fcacf532f5 korad-kaxxxxp: style cleanup in device scan, keep serno at hand
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>
2020-08-28 16:28:47 +02:00
Gerhard Sittig 003ad0ab8c input/saleae: keep previous channels across cleanup() call
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.
2020-08-26 17:06:15 +02:00
Gerhard Sittig f403cb9de9 scpi-pps: use remote and local modes for HMP4000
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.
2020-08-25 21:06:01 +02:00
Gerhard Sittig 22f76e188b scpi-pps: Add more HMP4000 series devices
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
2020-08-25 20:59:31 +02:00
Florian Schmidt bd5f0a143e scpi-pps: add support for Hameg / Rohde & Schwarz HMP4040
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 ]
2020-08-25 20:58:54 +02:00
Gerhard Sittig 24a953382c doc: update README.devices for GWInstek VCP (CP210x in disguise)
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).
2020-08-25 19:38:23 +02:00
Gerhard Sittig f91c6940ab scpi_serial: add "GWInstek VCP" (PID 0x0030) as seen in GDM-834x 2020-08-25 19:38:23 +02:00
Gerhard Sittig 395c1850b7 scpi-dmm: factor out some OL detection limits
Prepare the "plus/minus infinity" checks for OL conditions to use
model dependent limits. This commit does not change behaviour.
2020-08-25 19:38:23 +02:00