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);
^~~~~~~~~~~~~~~
Gerhard Sittig [Sun, 30 Sep 2018 02:45:27 +0000 (04:45 +0200)]
serial-dmm: introduce support for subdriver specific channel names
Default to the existing "P1" etc naming scheme for analog channels of
serial-dmm subdrivers. Add support for subdriver specific channel names
(which can reference the channel number if they desire). This is useful
for devices with multiple displays, or special purpose devices where
other names than P1 can better reflect the channel's nature.
Gerhard Sittig [Sun, 30 Sep 2018 02:36:39 +0000 (04:36 +0200)]
serial-dmm: count analog DMM channels starting at 1
Commit 556a926d432dd introduced support for multiple displays in
subdrivers of serial-dmm, but also changed user visible channel numbers
to start from 0. Restore the previous behaviour, start counting from 1
which users may perceive as more natural (serial-dmm used to start at P1
in the past, scopes start with CH1 as well).
On Windows, this device can either enumerate as 04b4:602a or 04b5:602a,
depending on which vendor driver is currently being used, so we have to
support both in the hantek-6xxx driver as well.
Martin Ling [Thu, 20 Sep 2018 00:45:22 +0000 (01:45 +0100)]
Fix read past end of array in sr_analog_si_prefix_friendly.
In the case where the input unit was not in the array, the for loop would
complete, but the following test would then read past the end of the array
since 'i' would already have been incremented to the array size.
Spotted because unitless data was getting SI prefixes with no unit, though
this would not have been deterministically reproducible.
Martin Ling [Mon, 10 Sep 2018 15:10:31 +0000 (16:10 +0100)]
scpi-pps: Don't block waiting for a value on capture stop.
The comment says "A requested value is certainly on the way", but the code no
longer works this way. The receive handler requests a value and blocks until
it is received. There is no value pending between receive handler calls, so
this code now only leads to a timeout.
Gerhard Sittig [Mon, 4 Jun 2018 21:21:01 +0000 (23:21 +0200)]
input: improve robustness, avoid NULL dereference in sr_input_send()
Applications might pass NULL for the buffer, and input modules might
accept it (or just cope). Eliminate a potential NULL dereference in
the emission of diagnostics messages.
On Windows, this device can either enumerate as 04b4:6022 or 04b5:6022,
depending on which vendor driver is currently being used, so we have to
support both in the hantek-6xxx driver as well.
Uwe Hermann [Sat, 1 Sep 2018 19:11:45 +0000 (21:11 +0200)]
Consistently use the _WIN32 #define.
The _WIN32 variant is available pretty much on all compilers, others
might not be. G_OS_WIN32 would probably be an equally well-suited
alternative, but for now we standardize on _WIN32.
Uwe Hermann [Sat, 1 Sep 2018 19:02:35 +0000 (21:02 +0200)]
ipdbg-la: Fix two compiler warnings on Windows.
This is happening because the send() and recv() functions
have different prototypes on POSIX and Windows. Using the casts
is required on Windows and doesn't hurt on POSIX systems.
[...]/protocol.c: In function 'tcp_send':
[...]/protocol.c:161:26: warning: pointer targets in passing argument 2 of 'send' differ in signedness [-Wpointer-sign]
out = send(tcp->socket, buf, len, 0);
^
In file included from [...]/protocol.c:24:0:
[...]/include/winsock2.h:997:34: note: expected 'const char *' but argument is of type 'const uint8_t * {aka const unsigned char *}'
WINSOCK_API_LINKAGE int WSAAPI send(SOCKET s,const char *buf,int len,int flags);
^
[...]/protocol.c: In function 'ipdbg_la_tcp_receive':
[...]/protocol.c:201:32: warning: pointer targets in passing argument 2 of 'recv' differ in signedness [-Wpointer-sign]
int len = recv(tcp->socket, buf, 1, 0);
^
In file included from [...]/protocol.c:24:0:
[...]/include/winsock2.h:992:34: note: expected 'char *' but argument is of type 'uint8_t * {aka unsigned char *}'
WINSOCK_API_LINKAGE int WSAAPI recv(SOCKET s,char *buf,int len,int flags);
^
Uwe Hermann [Sat, 1 Sep 2018 19:01:43 +0000 (21:01 +0200)]
ipdbg-la: Fix data_available() implementation on Windows.
[...]/protocol.c: In function 'data_available':
[...]/protocol.c:73:38: error: 'bytes_available' undeclared (first use in this function)
ioctlsocket(tcp->socket, FIONREAD, &bytes_available);
^
[...]/protocol.c:73:38: note: each undeclared identifier is reported only once for each function it appears in
[...]/protocol.c:84:1: warning: no return statement in function returning non-void [-Wreturn-type]
}
^
Gerhard Sittig [Tue, 28 Aug 2018 16:18:37 +0000 (18:18 +0200)]
fx2lafw: silence error message in query for channel group's device options
The fx2lafw(4) driver supports mere logic analyzers as well as mixed
signal devices, but does not support channel group specific device
options. Avoid an error message when channel group device options get
queried, the condition is perfectly legal and non-fatal.
How to reproduce:
$ pulseview -d fx2lafw
$ sigrok-cli -d fx2lafw -g Logic --show
Gerhard Sittig [Sat, 18 Aug 2018 13:31:09 +0000 (15:31 +0200)]
saleae and other FX2: show firmware name when loading fails
The "firmware load failed" message would be even more helpful if users
could learn which firmware file failed to load. Add those filenames to
various FX2-based drivers.
Uwe Hermann [Wed, 29 Aug 2018 22:13:26 +0000 (00:13 +0200)]
ipdbg-la: Fix incorrect copyright headers.
As per Daniel Anselmi <redacted> in an email conversation, the
code was actually written by Eva Kissling <redacted>
(as indicated in the commit logs as well). Fix the headers accordingly.
Uwe Hermann [Wed, 29 Aug 2018 22:02:16 +0000 (00:02 +0200)]
ipdbg-la: Consistently use the same naming everywhere.
Use "ipdbg-la" everywhere to refer to the driver, including
in function name prefixes etc. There's no need to encode
website details (.org) into the driver/function name(s).
Uwe Hermann [Sun, 22 Jul 2018 15:07:26 +0000 (17:07 +0200)]
Fix multiple C++ bindings warnings with gcc 8.
bindings/cxx/classes.cpp: In function ‘int sigrok::call_log_callback(void*, int, const char*, __va_list_tag*)’:
bindings/cxx/classes.cpp:242:17: warning: catching polymorphic type ‘class sigrok::Error’ by value [-Wcatch-value=]
} catch (Error e) {
^
In file included from bindings/cxx/classes.cpp:1667:
bindings/cxx/enums.cpp: In static member function ‘static Glib::VariantBase sigrok::ConfigKey::parse_string(std::__cxx11::string, sr_datatype)’:
bindings/cxx/enums.cpp:789:13: warning: catching polymorphic type ‘class std::invalid_argument’ by value [-Wcatch-value=]
} catch (invalid_argument) {
^~~~~~~~~~~~~~~~
bindings/cxx/enums.cpp:804:13: warning: catching polymorphic type ‘class std::invalid_argument’ by value [-Wcatch-value=]
} catch (invalid_argument) {
^~~~~~~~~~~~~~~~