Frank Stettner [Wed, 20 Feb 2019 17:58:13 +0000 (18:58 +0100)]
demo: Set an initial mq, mq flag and digits to the analog package.
Without a measured quantity in packet.meaning->mq the C++ binding function
sigrok::Analog::mq() throws an exception and there is no way to check if
there is any measured quantity set in the analog package.
Wolfram Sang [Wed, 2 Jan 2019 12:15:25 +0000 (13:15 +0100)]
ols: add feature to support >256K memory
Add support for the Pepino-style of accessing >256K of memory. Because
this the only known extension of accessing >256K currently, we apply it
as soon as the sample size is bigger than 256K. Let's hope other
devices (if any) will follow this style. If not, we need to add support
depending on the device name later.
Wolfram Sang [Wed, 2 Jan 2019 12:15:24 +0000 (13:15 +0100)]
pipistrello: rename registers to match actual function
Magnus (creator of the Pipistrello) confirmed that he mixed up the
register names. The code was doing it correctly nonetheless but was
confusing to read because of this. Fix it to make it easier to
comprehend.
Wolfram Sang [Wed, 2 Jan 2019 12:15:20 +0000 (13:15 +0100)]
ols: refactor using max_channels
Let max_channels really carry the number of maximum channels the
hardware supports. We will handle the limitation of only half the
channels available in 200MHz mode later. Note that there won't be a
regression because we only set the variable but never check it. The
desired result of this patch is the removal of the NUM_CHANNELS macro.
The number of channels needs to be dealt with at runtime.
Wolfram Sang [Wed, 2 Jan 2019 12:15:17 +0000 (13:15 +0100)]
ols: drop wrong usage of macro
commit f51acd69 ("ols: combine demux samples") wrongly replaced the bit
pattern of 0x20 with the number of channels which just happens to be 32
as well. So, the code works but is confusing to read. Reword the
for-loop to make it more comprehensible.
Wolfram Sang [Wed, 2 Jan 2019 12:15:16 +0000 (13:15 +0100)]
ols: use 32bit for handling sample counts
The OLS protocol sends 16bit values to specify the sample count and
delay count. However, this 16bit value is the number of 32bit words to
be sampled, so the actual sample count is 4 times larger and does not
fit into a uint16_t. Extend it to support the full range of 256K
(LogicShrimp will need this) and to prepare support for devices with
even more memory (Pepino).
Gerhard Sittig [Thu, 5 Oct 2017 23:38:26 +0000 (01:38 +0200)]
uni-t-ut32x: rephrase the receive buffer and packets relation
The previous implementation assumed that a receive data chunk ends
exactly with a sensor packet's end. Yet the buffer had 32 bytes while
the packets have 19 bytes.
Separate the data reception from the packet processing. Collect whatever
chunks the USB connection provides, and scan the resulting buffer for
packets. Cope with either incomplete or corrupt or misaligned packets as
well as with multiple packets in receive chunks. The latter might happen
upon initial synchronization, when a device already sends data or the
serial port buffered previously communicated data.
In the regular case, the computer will process so fast that each single
character will be handled individually. We don't mind. The frequency is
some 60 times per second, and the data volume is 19 bytes. The software
works for the regular case, and synchronizes fast at startup or after
comm errors.
Gerhard Sittig [Thu, 5 Oct 2017 22:34:05 +0000 (00:34 +0200)]
uni-t-ut32x: improve robustness of packet parser, more diagnostics
Always print the data bytes of received buffers in the packet parser,
then check some more fixed fields to not process invalid packets, then
process the packet content as the previous implementation did.
Call the packet parser for incomplete packets and discarded input
buffers as well (initial synchronization, re-sync after comm errors).
This results in the availability of more diagnostics during development.
Pass the packet's location and size from outside. This prepares the
logic to cope with situations where the receive buffer contains multiple
(potentially incomplete) packets.
Gerhard Sittig [Thu, 5 Oct 2017 22:09:44 +0000 (00:09 +0200)]
uni-t-ut32x: use ASCII literals in packet parser, symbols for magic numbers
Slightly unobfuscate the UT32x packet parser. The protocol is mostly
ASCII based, checks for hex numbers may be unexpected. Use symbolic
identifiers for the packet length and some special characters.
Gerhard Sittig [Thu, 5 Oct 2017 09:35:25 +0000 (11:35 +0200)]
uni-t-ut32x: pre-set to default conn= spec
The previous implementation of the UT32x driver expected to see a conn=
spec, without it no device is found. Default to the USB identification
of the CH9325 chip, to make the driver work out of the box. Users still
can provide conn= specs and override the default for other cables.
Gerhard Sittig [Sun, 30 Dec 2018 11:31:20 +0000 (12:31 +0100)]
doc: update README.devices (USB detection, enable serial comm)
Slightly rephrase README.devices since there is no strict distinction
into "fully automatic" and "always manual". Some drivers _accept_ conn=
specs when provided, _and_ support automatic detection of enumerable
devices, _and_ might implement defaults but also support overrides.
Nit, numerically sort the list of Uni-T cables (which is about to grow
in the future) for improved readability.
Add two more devices which require users to manually enable the serial
communication (Brymen BM257s, EEVBlog 121GW).
Gerhard Sittig [Tue, 11 Dec 2018 14:14:13 +0000 (15:14 +0100)]
microchip-pickit2: first driver implementation (acquisition works, triggers don't)
Fill in the scan, open/close, get/set/list, acquisition start/stop logic
such that data acquisition with a PICkit2 works.
Trigger support needs more attention. User specified triggers either
seem to not take effect, or the trigger position is not in the expected
location. It's yet to get determined what's the issue.
This implementation is based on protocol information gathered from the
pk2-la project.
Gerhard Sittig [Tue, 11 Dec 2018 15:52:06 +0000 (16:52 +0100)]
brymen-bm86x: drop redundant free call, fixup channel index
Remove a free() call in an error path for a list which immediately
before the call was determined to be NULL. Use index 0 and 1 for
channels P1 and P2 respectively (the previous implementation used 0
for both channels).
Gerhard Sittig [Sat, 17 Nov 2018 18:51:31 +0000 (19:51 +0100)]
scpi-dmm: run OPC queries immediately before essential commands
The current implementation of the SCPI DMM driver is conservative about
checking the device's being operational, but the *OPC? queries are found
in unfortunate locations. Run the OPC query right before running the
next "actual" command, not afterwards. And certainly not between sending
requests and potentially gathering responses in subsequent calls.
This commit does not change current behaviour, but improves maintenance
before pending commits.
Gerhard Sittig [Sat, 17 Nov 2018 18:43:38 +0000 (19:43 +0100)]
scpi-dmm: return MQ table entry to "get MQ" routine callers
The "get MQ" helper routine communicates SCPI responses and translates
them to internal "MQ and flag" values. Optionally return the MQ table
entry reference to callers, so they don't have to repeat the table
lookup when the function's default precision is required, or should
future "start acquisition" requests need to refer to the meter's current
function.
Gerhard Sittig [Sat, 17 Nov 2018 15:26:51 +0000 (16:26 +0100)]
scpi-dmm: add support for model specific device options
Supported SCPI DMM devices will differ in the set of options and whether
parameters can get queried or configured. Use a "generic" set of devopts
during scan and for simpler models, prepare support for other sets of
devopts for more complex models.
Gerhard Sittig [Sun, 4 Nov 2018 18:54:17 +0000 (19:54 +0100)]
scpi-dmm: Implement support for Agilent 34405A, prepare others
Implement the scpi-dmm driver in such a generic way that it could work
with several protocol variants and with differing models which happen to
use any of these protocol variants. Prepare a list of supported models
with their respective SCPI command set, set of DMM functions and their
precision.
Add support for Agilent 34405A. The ten functions of this device got
tested and are operational, in continuous mode as well as with sample
count or capture time limits. The driver can query the current meter's
function, can change the function, and can run acquisitions in either
the current mode or with a user specified function selection. There is
some potential for improvement: AUTO/MIN/MAX/HOLD indicators are not
supported by this implementation.
Gerhard Sittig [Wed, 7 Nov 2018 19:22:54 +0000 (20:22 +0100)]
scpi: introduce string un-quote helper routine
The SCPI protocol may communicate strings in quoted form, enclosed by a
matching pair of single or double quote characters, and occurances of
this very quote character within the string get doubled (escaped). Add a
common routine to undo the quotes.
Gerhard Sittig [Sat, 3 Nov 2018 13:52:00 +0000 (14:52 +0100)]
fluke-45: fix minor memory leaks in the probe routine
Free the SCPI hardware info after successful model detection, too. Only
allocate the device instance when a supported model was found. Link the
device context earlier right after allocation, for easier verification.
Gerhard Sittig [Sat, 3 Nov 2018 13:28:56 +0000 (14:28 +0100)]
fluke-45: avoid NULL dereference in the probe routine
The Fluke 45 probe routine tries to detect whether the serial port is
"in echo mode" (which already is questionable before the IDN query).
In the absence of a response, the library segfaults. Fix it.
Jon Burgess [Sun, 14 Oct 2018 23:17:09 +0000 (00:17 +0100)]
Free list returned by sr_session_dev_list()
==214948== 16 bytes in 1 blocks are definitely lost in loss record 161 of 6,440
==214948== at 0x4C2EE0B: malloc (vg_replace_malloc.c:299)
==214948== by 0x650F435: g_malloc (in /usr/lib64/libglib-2.0.so.0.5600.3)
==214948== by 0x6527056: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.5600.3)
==214948== by 0x65284B0: g_slist_copy_deep (in /usr/lib64/libglib-2.0.so.0.5600.3)
==214948== by 0x592BBA6: sr_session_dev_list (session.c:402)
==214948== by 0x56EF7B5: sigrok::Session::Session(std::shared_ptr<sigrok::Context>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >) (classes.cpp:932)
==214948== 16 bytes in 1 blocks are definitely lost in loss record 162 of 6,440
==214948== at 0x4C2EE0B: malloc (vg_replace_malloc.c:299)
==214948== by 0x650F435: g_malloc (in /usr/lib64/libglib-2.0.so.0.5600.3)
==214948== by 0x6527056: g_slice_alloc (in /usr/lib64/libglib-2.0.so.0.5600.3)
==214948== by 0x65284B0: g_slist_copy_deep (in /usr/lib64/libglib-2.0.so.0.5600.3)
==214948== by 0x592BBA6: sr_session_dev_list (session.c:402)
==214948== by 0x56F1EB1: sigrok::Session::devices() (classes.cpp:967)
Align the scaling items such that all numbers are aligned. Drop unneeded
"prefixes" for the 2nd display's tables, the main and sub displays already
have their individual tables which reside in their respective groups.
Add an "eevblog-121gw" subdriver entry for the EEVblog 121GW multimeter.
Use device dependent channel names instead of the default "P1" etc names.
It's assumed that the device's binary packet data is available at a COM
port. This means that an external BT to UART gateway is required until
BLE communication will be one of libsigrok's native connection types.
Gerhard Sittig [Fri, 28 Sep 2018 16:39:23 +0000 (18:39 +0200)]
dmm/eev121gw: introduce parser for EEVblog 121GW 19-byte binary packets
Introduce the dmm/eev121gw.c source file with parse routines for the
EEVblog 121GW meter's 19-bytes binary packets. Get the values and MQ
properties of the device's several displays (main, sub, bar) in several
individual parse calls.
This commit introduces initial support for the device. Some of the modes
and features are untested, as are some of the device's ranges.
Due to some SCPI command changes that Siglent made, the connection
failed due to the wrong commands being send to the device.
This might fix parts of bug #1242, though initial tests show that
further changes might be needed.
[Note: This commit consists of multiple squashed commits from
marchelh <redacted> and various fixups and rebasing
operations by Uwe Hermann <redacted>]
Gerhard Sittig [Mon, 8 Oct 2018 15:07:07 +0000 (17:07 +0200)]
serial: dump DMM packets during stream detection
Regular operation of serial DMM drivers optionally can dump packet bytes
after the intialization phase has synchronized to the stream. Failure to
synchronize to the stream left developers without a dump, which complicates
research what went wrong.
Do dump packet content while the serial_stream_detect() routine tries to
synchronize to the stream. Use the spew level since the dump occurs upon
every attempt, which translates to: every received byte until a valid
packet was seen (or the synchronization phase expired).
Gerhard Sittig [Sat, 29 Sep 2018 18:46:45 +0000 (20:46 +0200)]
serial-dmm: print data bytes according to specific meter's packet length
The previous implementation always dumped 23 data bytes for received
packets. This could result in truncated diagnostics information, and/or
access to invalid buffer content.
Rephrase the packet dump routine such that the specific meter's exact
packet length gets dumped, and use the common hex dump support code.
Gerhard Sittig [Sat, 6 Oct 2018 17:02:03 +0000 (19:02 +0200)]
strutil: introduce hex dump routines (allocate a text buffer)
Introduce common support for hex dumps in the string util collection.
There are explicit allocation and release routines for the textual
representation of the data bytes, so that callers are free to chose
whether and how to decorate the dump and where to send the message.
Gerhard Sittig [Sat, 13 Oct 2018 09:06:16 +0000 (11:06 +0200)]
input/vcd: add channel list checks for file re-read
Keep (part of) previous results around when the VCD input module gets
reset, and check the header of the next import against previous runs to
avoid issues in applications. This addresses the VCD specific part of
bug #1241, and resolves the remaining part of bug #1306.
Gerhard Sittig [Sat, 13 Oct 2018 06:19:00 +0000 (08:19 +0200)]
device: introduce routines to compare channels and channel lists
Applications are not prepared to handle changes in the channel list
between multiple acquisitions from the same source (device drivers
or input modules). Introduce common helpers to compare channels and
channel lists.
Gerhard Sittig [Sat, 13 Oct 2018 06:16:18 +0000 (08:16 +0200)]
device: introduce common sr_channel_free() support code
There was the sr_channel_new() allocation routine, but releasing that
allocation was open-coded in call sites. Add the sr_channel_free()
routine for code re-use and consistency.
Gerhard Sittig [Fri, 12 Oct 2018 09:07:12 +0000 (11:07 +0200)]
input/vcd: Expand the reset() logic
This addresses part of bug #1306. The reset() method of the VCD input
module was incomplete, and did not process new data upon second read.
Improve robustness and add missing reset instructions. Void invalid
pointers and avoid NULL dereferences in cleanup paths.
Uwe Hermann [Tue, 18 Sep 2018 21:21:40 +0000 (23:21 +0200)]
Fix various gcc 8 compiler warnings related to ARRAY_SIZE.
Example:
In file included from src/hardware/kecheng-kc-330b/protocol.h:26,
from src/hardware/kecheng-kc-330b/api.c:22:
src/hardware/kecheng-kc-330b/api.c: In function ‘config_list’:
src/libsigrok-internal.h:51:34: warning: division ‘sizeof (void *) / sizeof (void)’ does not compute the number of array elements [-Wsizeof-pointer-div]
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
^
src/libsigrok-internal.h:55:32: note: in expansion of macro ‘ARRAY_SIZE’
#define ARRAY_AND_SIZE(a) (a), ARRAY_SIZE(a)
^~~~~~~~~~
src/libsigrok-internal.h:964:43: note: in expansion of macro ‘ARRAY_AND_SIZE’
std_opts_config_list(key, data, sdi, cg, ARRAY_AND_SIZE(scanopts), \
^~~~~~~~~~~~~~
src/hardware/kecheng-kc-330b/api.c:296:10: note: in expansion of macro ‘STD_CONFIG_LIST’
return STD_CONFIG_LIST(key, data, sdi, cg, NULL, drvopts, devopts);
^~~~~~~~~~~~~~~