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) {
^~~~~~~~~~~~~~~~
src/input/wav.c: In function ‘receive’:
src/input/wav.c:345:51: warning: ‘%d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 6 [-Wformat-truncation=]
snprintf(channelname, sizeof(channelname), "CH%d", i + 1);
^~
src/input/wav.c:345:48: note: directive argument in the range [1, 2147483647]
snprintf(channelname, sizeof(channelname), "CH%d", i + 1);
^~~~~~
src/input/wav.c:345:5: note: ‘snprintf’ output between 4 and 13 bytes into a destination of size 8
snprintf(channelname, sizeof(channelname), "CH%d", i + 1);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Gerhard Sittig [Mon, 16 Jul 2018 19:19:36 +0000 (21:19 +0200)]
tests: add more cases for text to rational number conversion
Test the ".1" and "1." cases which are assumed to be problematic on
MacOS (or may not have been supported before a recent update). Add more
tests with leading signs as well as whitespace instead of a sign.
Gerhard Sittig [Thu, 19 Jul 2018 20:12:15 +0000 (22:12 +0200)]
strutil: insist in some mantissa for parse rational
The previous implementation accepted either empty integer or empty
fractional parts of a floating point number, but also when both parts
were missing ("." input). Insist in at least one of the parts to be
present.
Gerhard Sittig [Thu, 19 Jul 2018 19:10:15 +0000 (21:10 +0200)]
strutil: accept leading whitespace in parse rational
Programmatic output of floating point numbers might choose to print
spaces instead of an explicit '+' sign, to align the output with the
result of formatting negative numbers yet achieve a screen appearance
similar to what humans would have written. Skip leading whitespace
before insisting in seeing either signs or digits or decimals.
Gerhard Sittig [Thu, 19 Jul 2018 19:05:54 +0000 (21:05 +0200)]
strutil: handle empty fractional in parse rational
Accept numbers like "123." where the period (dot) is present yet the
fractional part is empty. Adding a period but no additional digits is a
popular method of turning an otherwise integer literal into a float.
Compilers and strtod() routines accept this notation, too, so we have to
expect seeing such input.
Gerhard Sittig [Mon, 16 Jul 2018 19:00:06 +0000 (21:00 +0200)]
tests: echo text input when rational conversion fails
The previous implementation only echoed the p/q conversion results _if_
the return code signalled success but the result was unexpected. Although
the errno value for failed conversion attempts (non-zero return codes)
is not too helpful, seeing which text input failed the test is desirable.
Gerhard Sittig [Sat, 21 Jul 2018 20:30:05 +0000 (22:30 +0200)]
input/vcd: abort VCD import when timestamp counts backwards
The VCD specification requests that timestamps will strictly increase as
one advances through the file. Add another check where the previous
implementation resulted in a tight loop and made the application stall.
Do print an error message and abort file processing in that case.
Gerhard Sittig [Wed, 27 Jun 2018 21:57:45 +0000 (23:57 +0200)]
output: fixup trigger marker position in ascii/bits/hex output modules
Adjust the calculation of the '^' marker's position in T: lines of the
-O ascii/bits/hex output modules such that it matches the sample data
lines' layout. Add comments which discuss the motivation of the marker
position's calculation, which differs among each of those modules.
Strictly speaking -O bits was already correct. But I chose to adjust and
comment the logic such that multiple output modules follow a common
pattern. If performance is an issue, the bits.c change might be worth
reverting.
Andrej Valek [Sun, 29 Apr 2018 20:38:47 +0000 (22:38 +0200)]
hantek-4032l: Separate USB receive callbacks.
Callback for data transfer is separated from status. This change will be
used for better data transfer sending/receiving. Cast signal, that trigger
has been captured was moved into state: H4032L_STATUS_FIRST_TRANSFER.
Gerhard Sittig [Sun, 3 Jun 2018 08:31:17 +0000 (10:31 +0200)]
input/logicport: don't re-create channels after input module reset
Split the creation of channels and groups as well as the creation of the
session feed buffer into separate routines. Re-allocate the buffer after
reset but do not re-create the channels and groups.
This implementation assumes that after reset() of the input module, the
very same set of channels (including their order, names and enabled
state, as well as group membership) results from processing the
subsequently fed file content. Reading rather different configurations
from the same input file by means of repeated reset and re-read may not
work as expected.
Gerhard Sittig [Sun, 3 Jun 2018 06:37:10 +0000 (08:37 +0200)]
input/logicport: silence a non-fatal glib runtime assertion
Explicitly check GString pointers for validity before calling glib
routines that would access string content. This silences an assertion
error for a non-fatal runtime condition:
Gerhard Sittig [Sun, 3 Jun 2018 06:05:43 +0000 (08:05 +0200)]
input: clear sdi_ready flag and receive() buffer in common code
Rephrase common input reset logic such that additional common code can
execute after the individual module's reset callback. No behaviour has
changed, the module's reset callback still is optional, and identical
log output gets emitted.
Do clear the sdi_ready flag in the common sr_input_reset() routine, so
that all input modules will parse header information again before
processing sample data when subsequent calls receive new file content.
Void the input module's receive() buffer from common reset code. This
unbreaks the feature of re-reading previously consumed input files.
Extend comments in the common reset and free code paths, which involve
the modules' reset and cleanup routines, which interact in non-trivial
ways. Discuss the responsibilities of common and individual routines, to
remain aware during maintenance.
Frank Stettner [Sat, 9 Dec 2017 18:45:02 +0000 (19:45 +0100)]
scpi-pps: Reimplemention of switching channel groups (PSU channels)
Acquisition won't work correctly in a multi-threaded environment, when
config_set() and config_get() are called with a channel group.
The channel switching itself has moved to scpi/scpi.c, to be able to
handle switching in a thread safe way.
Frank Stettner [Sat, 11 Nov 2017 15:29:55 +0000 (16:29 +0100)]
scpi: Synchronize read, write and write+read operations.
This ensures that SCPI read/write/write+read operations are thread safe.
F.e.: If a write operation expects a return value (in other words: a
read operation), it is not allowed to be interrupted by another write
operation.
To simplify things, the SCPI helper functions are moved from
scpi/helpers.c to scpi/scpi.c and also are renamed to fit the naming
scheme.
libgpib in particular will abort the program execution in case of
concurrent operations.
Gerhard Sittig [Fri, 25 May 2018 17:13:11 +0000 (19:13 +0200)]
input/chronovu_la8: claim responsibility for LA16 files, devel comments
The chronovu_la8 input module is capable of handling either file type,
generated by LA8 or LA16 vendor software. Automatic detection is not
available, but user provided channel counts work fine.
Adjust the input module's name and description, and claim support for
.kdt as well as .kd1 files.
Add developer notes on implementation details, the file content's
constraints, and potential future adjustment.
Gerhard Sittig [Sun, 13 May 2018 10:28:07 +0000 (12:28 +0200)]
input/chronovu_la8: only send data to the session, don't send the header
The file format is funny, a data part is leading (fixed size) and a
"header" part follows. The previous implementation sent the header part
to the session, too, pretending it was part of the data. This change
limits the number of samples that get sent to the session.
Comment on the file layout and header fields while we are here. This
information got lost in commit 02e24c0ce0d8 when the input module got
converted from do-it-yourself file operations to having intrinsic
handler routines invoked from common logic which handles the file.
Gerhard Sittig [Mon, 21 May 2018 18:08:14 +0000 (20:08 +0200)]
input/logicport: unobfuscate 64-bit-clean bit mask literals
Prefer the more portable UINT64_C() macro over the UL suffix when a
literal needs to span "more than 31 bit positions". Adjust other
locations for consistency across the source file.
Gerhard Sittig [Mon, 21 May 2018 17:55:58 +0000 (19:55 +0200)]
input/trace32_ad: fix potential buffer overflow for unexpected input data
Commit 8c4bff1d25e1 introduced a routine which prints what mostly should
be text, and avoids non-printable characters. This implementation used an
incorrect format string, which could result in data getting written past
the end of a buffer. Fix the format string.
Uwe Hermann [Sat, 19 May 2018 20:04:22 +0000 (22:04 +0200)]
hwdriver.c: Fix two scan-build warnings.
src/hwdriver.c: In function ‘log_key’:
src/hwdriver.c:648:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
opstr = op == SR_CONF_GET ? "get" : op == SR_CONF_SET ? "set" : "list";
^~
src/hwdriver.c: In function ‘check_key’:
src/hwdriver.c:681:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
opstr = op == SR_CONF_GET ? "get" : op == SR_CONF_SET ? "set" : "list";
^~
Uwe Hermann [Sat, 19 May 2018 19:58:10 +0000 (21:58 +0200)]
siglent-sds: Fix multiple scan-build warnings.
src/hardware/siglent-sds/api.c:596:3: warning: Argument to g_free() is the address of a global variable, which is not memory allocated by malloc()
g_free(cmd);
^~~~~~~~~~~
src/hardware/siglent-sds/api.c:641:3: warning: Argument to g_free() is the address of a global variable, which is not memory allocated by malloc()
g_free(cmd);
^~~~~~~~~~~
Gerhard Sittig [Sun, 13 May 2018 06:56:09 +0000 (08:56 +0200)]
bindings: wrap sr_input_scan_file() in the C++ language binding
Allow C++ applications to have the input format automatically detected,
and get a corresponding InputFormat instance. This makes the format match
logic available to PulseView.
Gerhard Sittig [Sat, 12 May 2018 16:09:31 +0000 (18:09 +0200)]
input/trace32_ad: data type nits, log verbosity in header parsing
Log determined header format when parsing trace32 file headers. Keep
another log message during regular processing, but silence it during
format match.
Use more appropriate data types for local and instance variables. Adjust
format strings accordingly.