Gerhard Sittig [Sat, 12 May 2018 09:25:36 +0000 (11:25 +0200)]
input: add confidence (detection strength) to format_match()
When users don't specify the input format, applications can try to have
the format auto-detected. Some of the tests were weak and could result
in false positives.
Add a 'confidence' parameter to the input modules' format_match()
method. Claim high confidence (1) for those formats which can check
magic strings or the presence of essential keywords (vcd, wav). Claim
medium confidence (10) for those formats which happened to mis-detect
inputs in the past (trace32_ad). Claim weak confidence (100) for those
formats which totally lack reliable conditions and rather guess than
detect (chronovu_la8).
Prefer the best match in public scan routines. Return at most one module
to callers even if multiple modules matched, to keep the current API.
Gerhard Sittig [Tue, 24 Apr 2018 21:25:25 +0000 (23:25 +0200)]
input/logicport: introduce input module for LogicPort File (*.lpf)
Implement an input module for .lpf files, the "LogicPort File" format of
the Intronix LA1034 vendor software. This version supports wires with
enabled and inverted state, compressed samples, signal names, signal
groups (but not multiple assignment), and automatic format detection.
The logic which determines whether "the file header" was completely
received, and sample data can get sent to the session, implements an
assumption in the absence of a better and more reliable condition.
Invalid input gets rejected, but diagnostics is rather limited. Since
all channels get to be the member of a channel group, either specified
by the user in the input file, or arranged for in the input module, the
"missing separator" part of bug 1186 has become obsolete.
../include/libsigrok/libsigrok.h:653:19: warning: result of ‘1 << 31’ requires 33 bits to represent, but ‘int’ only has 32 bits [-Wshift-overflow=]
SR_CONF_GET = (1 << 31),
^~
src/analog.c:205:23: warning: declaration of ‘i’ shadows a previous local [-Wshadow]
for (unsigned int i = 0; i < count; i++) {
^
src/analog.c:178:18: note: shadowed declaration is here
unsigned int b, i, count;
^
[...]
Uwe Hermann [Wed, 16 May 2018 20:46:34 +0000 (22:46 +0200)]
sr_analog_to_float(): Fix a compiler warning (-Wshadow).
src/analog.c: In function ‘sr_analog_to_float’:
src/analog.c:194:9: warning: declaration of ‘offset’ shadows a previous local [-Wshadow]
float offset = analog->encoding->offset.p / (float)analog->encoding->offset.q;
^~~~~~
src/analog.c:177:8: note: shadowed declaration is here
float offset;
^~~~~~
Gerhard Sittig [Thu, 3 May 2018 19:51:46 +0000 (21:51 +0200)]
demo: optionally accept frame limit spec at scan time
Allow developers to specify the (default) number of frames at compile
time (default to "off" as before). Accept the frame limit spec at scan()
time as well. This is useful when applications don't run config_set() at
runtime.
Gerhard Sittig [Thu, 3 May 2018 19:26:07 +0000 (21:26 +0200)]
demo: make frame generation (and maximum frame count) a runtime option
The previous implementation supported the generation of frames as a
compile time option. This change lets users adjust the feature at
runtime.
In the absence of a frame count limit no frame begin/end markers get
sent (the default behaviour of the previous implementation). When a
frame count limit is specified, the respective number of frames gets
sent and acquisition stops.
The fixed amount of 1000 samples per frame is an arbitrary choice. This
compile time option is easily adjusted in the source code.
Gerhard Sittig [Sun, 13 May 2018 17:45:46 +0000 (19:45 +0200)]
demo: introduce graycode generator mode
Introduce support for the "graycode" logic pattern. Generate up to
64 bits of graycode output (all logic lines, no repetition, not limited
by the generator's internal pattern buffer). The implementation was
tested with 16 channels.
Gerhard Sittig [Sun, 13 May 2018 17:40:00 +0000 (19:40 +0200)]
demo: add convenient bit mask for "all logic channels"
Keep a context variable around with a bit mask for all logic channels.
This is convenient in setup and generation routines, to avoid garbage
in unassigned bit positions of session feed packets.
Gerhard Sittig [Sun, 13 May 2018 17:27:51 +0000 (19:27 +0200)]
demo: data type nits in the device context (enum, unsigned int)
Move the declaration of codes for pattern types before the declaration
of the context container such that the latter can reference the former.
Add 'int' to an unsigned variable that omitted the base type.
Gerhard Sittig [Tue, 24 Apr 2018 21:28:41 +0000 (23:28 +0200)]
input/trace32_ad: silence format errors during input format match
When auto-detection tries to find the input module that can handle a
file, unexpected input format should be considered non-fatal. Only emit
error messages when process_header() got invoked from process_buffer()
after initialization. Emit debug messages in early stages where no input
module context exists yet.
Uwe Hermann [Sat, 28 Apr 2018 21:39:59 +0000 (23:39 +0200)]
dreamsourcelab-dslogic: Properly set initial voltage threshold.
The initial voltage threshold in dev_open() was being set to a
default value in the devc->cur_threshold variable but not actually set
in the device itself.
Andrej Valek [Mon, 2 Apr 2018 18:01:19 +0000 (20:01 +0200)]
hantek-4032l: Fix structure packing.
- use pragma to handle different behavior between gcc and minGW bit-field packing
- bit-field integer variables needs to be align to 2-byte boundary
Compiler does not produce an error when accessing into non-__packed pointer.
However, the field might not be properly aligned for this type.
More information could be found on:
- https://sourceforge.net/p/mingw-w64/bugs/275/
- http://www.keil.com/support/man/docs/ARMCC/armcc_chr1359124990875.htm
Uwe Hermann [Sat, 21 Apr 2018 22:23:10 +0000 (00:23 +0200)]
log: Move log level check so that it affects all handlers.
Before this change, the loglevel check would only be performed for the
default log handler in libsigrok, but not for other handlers set
via sr_log_callback_set().
Uwe Hermann [Thu, 19 Apr 2018 21:23:35 +0000 (23:23 +0200)]
session_driver: Quickfix to prevent looped analog data reads.
A local buffer was too small, snprintf() was used to write the
name of the analog-1-1-xxx ZIP archive names in that buffer.
Due to the limited size, only 3 characters were usable for the last
number component, i.e. the code would loop around from analog-1-1-999
to analog-1-1-100 (instead of analog-1-1-1000).
As a quickfix, increase the buffer size by a large margin, a nicer
fix should be used later on.
James Churchill [Sun, 18 Feb 2018 06:54:01 +0000 (16:54 +1000)]
modbus: Return explicit SR_ERR values as required by modbus.c
The Modbus RTU implementation was inappropriately returning lengths
from the serial functions when the calling functions expect only an
sr_error_code value.
Gerhard Sittig [Sun, 4 Mar 2018 18:12:29 +0000 (19:12 +0100)]
output/csv: fix out-of-bounds array access in process_analog()
Make sure to not exceed the ctx->analog_samples[] array bounds. Don't
use the (huge) channel's index in the device's(!) channel list, instead
use the zero-based and dense index into the array of analog samples in
the accumulation buffer, before writing to the external file.
Gerhard Sittig [Sun, 4 Mar 2018 17:19:38 +0000 (18:19 +0100)]
output/csv: use longer names for iteration variables
The process_analog() logic is rather complex, dealing with the total
list of channels in the device (which can be of different types), and a
number of submitted samples for a specified list of channels. Replace
the rather short variable names for i, j, c (and num_channels) with
something longer that hopefully increases readability of the complex
loop bodies.
Note that this change merely renames identifiers, and does not change
behaviour.
Gerhard Sittig [Sun, 4 Mar 2018 16:51:29 +0000 (17:51 +0100)]
output/csv: reduce indentation in process_analog()
Instead of nesting indentation levels upon equality of a value, skip
iterations upon inequality. This reduces indentation, and might improve
readability.
[ Indentation changes, see 'diff -w -b' for the essence. ]
Frank Stettner [Sat, 11 Nov 2017 17:29:19 +0000 (18:29 +0100)]
arachnid-labs-re-load-pro: Change serial read in acquisition mode.
Use serial_readline in acquisition mode, otherwise data from the
Re:load Pro could get lost.
Use reloadpro_receive_data() for all commands when in acquisition
mode. When not using a single point of receiving data, data could get
lost.
Gerhard Sittig [Wed, 21 Feb 2018 17:04:29 +0000 (18:04 +0100)]
link-mso19: improve endianess conversion, avoid mem access alignment issue
Prefer sigrok's endianess conversion helper over the inet htons()
routine which is harder to read (is "network order" little or big?).
Writing the conversion results in units of bytes also avoids misaligned
memory access. The header length is odd, each payload item got written
as an uint16_t item to an odd address.