Gerhard Sittig [Sun, 27 May 2018 07:56:49 +0000 (09:56 +0200)]
counter: emit wider annotations for data and word counts
Track the start of a data or word cycle. Avoid narrow ss=es annotations
which may be tedious to inspect by users in GUI applications. This
resolves the issue initially reported in bug #1210.
Gerhard Sittig [Sun, 27 May 2018 07:46:01 +0000 (09:46 +0200)]
counter: prepare for variable width annotations
Explicitly pass a start sample number to the .putc() method, to prepare
annotations where ss differs from es. This is motivated by bug #1210.
Stick with the narrow ss=es annotations for backwards compatibility.
Gerhard Sittig [Sun, 27 May 2018 07:35:25 +0000 (09:35 +0200)]
counter: use local variables instead of instance variables
Since values get accessed within the .decode() method exclusively, we need
not store data in instance variables of the decoder object. Use another
variable for the "reset edge" option as well for consistency.
Gerhard Sittig [Sun, 27 May 2018 07:27:08 +0000 (09:27 +0200)]
counter: move some init code to the start of decode()
Since PD API v3 the .decode() method is called exactly once, and
contains a main loop itself. Move initialization code that sets up
.decode() related logic to the start of the .decode() routine.
Gerhard Sittig [Sun, 27 May 2018 07:06:48 +0000 (09:06 +0200)]
counter: explicit option text to .wait() edge mapping
The previous implementation used the fact that libsigrok's internal API
happens to use the first letter of the user visible English option text.
Two locations mapped edge choices to API literals in different ways.
Unify them, introduce an explicit option text to literal value mapping.
(Many if not all decoder implementations do that. More adjustment to use
common code could be beneficial.)
Uwe Hermann [Thu, 17 May 2018 20:50:45 +0000 (22:50 +0200)]
configure.ac: Add some more compiler warning options.
Add the -Wshadow -Wformat=2 -Wno-format-nonliteral -Wfloat-equal
compiler options (supported by both gcc and clang) to get notified
of more potential issues in the code.
Uwe Hermann [Wed, 16 May 2018 20:14:22 +0000 (22:14 +0200)]
srd_inst_channel_set_all(): Fix a compiler warning (-Wshadow).
instance.c:266:11: warning: declaration of ‘l’ shadows a previous local [-Wshadow]
GSList *l = g_slist_nth(di->decoder->channels, i);
^
instance.c:206:9: note: shadowed declaration is here
GList *l;
^
Uwe Hermann [Tue, 15 May 2018 22:21:56 +0000 (00:21 +0200)]
decoder.c: Fix a scan-build warning.
decoder.c:343:9: warning: Access to field 'ob_type' results in a dereference of a null pointer (loaded from variable 'py_default')
if (Py_TYPE(py_default) != Py_TYPE(py_item)) {
^~~~~~~~~~~~~~~~~~~
/usr/include/python3.6m/object.h:118:33: note: expanded from macro 'Py_TYPE'
#define Py_TYPE(ob) (((PyObject*)(ob))->ob_type)
^~~~~~~~~~~~~~~~~~~~~~~~~~~~
Uwe Hermann [Tue, 15 May 2018 22:09:53 +0000 (00:09 +0200)]
type_decoder.c: Fix a scan-build warning.
type_decoder.c:836:3: warning: Value stored to 'ret' is never read
ret = process_samples_until_condition_match(di, &found_match);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Gerhard Sittig [Sat, 12 May 2018 20:21:39 +0000 (22:21 +0200)]
mcs48: add reset method, make A12 optional, unassorted adjustment
Add the reset() method which recently has become essential. Make the A12
"memory bank" address line optional. Use more Python idioms. Update
comments.
The control signals had to move, to avoid gaps between D7 and A8 as well
as between A11 and A12 in the GUI decoder properties dialog. With
dynamic assignment in the UI and with named references in the CLI this
shall not harm. Unmodified automated tests still pass.
The logic is prepared to handle data, address, and "bank" pin groups at
arbitrary locations, A[11:8] and D[7:0] need not be adjacent any longer.
Support for more than one memory bank pin is prepared, but the number of
bank pins needs to get determined at the start of decode(), when this
feature is to get added in the future.
Decodes addresses and data read from an external ROM. The MCS-48
processors (8048, 8049, 8039, etc.) have an 8-bit data bus that latches
first the address then the data.
Gerhard Sittig [Mon, 16 Apr 2018 19:15:13 +0000 (21:15 +0200)]
dcf77: annotate unexpected bit numbers and values, do not abort execution
Improve robustness of the DCF77 decoder. Cope with "neiter 0 nor 1" bit
values (glitches can break the detection of pulse widths), as well as
unexpected bit numbers (more than 59 pulses per minute, can be a
follow-up error after e.g. glitches break one long pulse into two short
pulses). Do not process this invalid data, do emit error annotations.
Gerhard Sittig [Mon, 16 Apr 2018 19:12:16 +0000 (21:12 +0200)]
dcf77, lpc: rephrase bit string formatting
Create the text representation of a bit string by means of the builtin
.format() method and an appropriate specifier. Drop the non-obvious
sequence of bin() and slice and zfill() calls.
Gerhard Sittig [Mon, 23 Apr 2018 18:42:54 +0000 (20:42 +0200)]
instance: return SRD_ERR_TERM_REQ when execution shall terminate
The previous implementation internally noticed the "want terminate"
request, and skipped decoder execution to faster get to the end of the
input stream. But an OK return code was provided in that code path, and
more input data was sent by applications (sometimes for many seconds or
few minutes).
Do return a new SRD_ERR_TERM_REQ error code, such that applications can
tell failed execution from requested termination.
Gerhard Sittig [Mon, 23 Apr 2018 18:40:28 +0000 (20:40 +0200)]
instance: drop an unneeded "want wait() to terminate" reset assignment
It's uncertain why srd_inst_decode() which internally gets called by the
public srd_session_send() routine used to clear the want_wait_terminate
flag. This should be cleared upon decoder instance creation and state
reset, gets raised upon termination request, but shall not get cleared
in other spots, especially not upon the availability of new input data
while the stream shall be considered in the "about to terminate, skip
all subsequent execution" state.
Uwe Hermann [Sat, 21 Apr 2018 22:17:49 +0000 (00:17 +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 libsigrokdecode, but not for other handlers set
via srd_log_callback_set().
Uwe Hermann [Fri, 20 Apr 2018 19:40:12 +0000 (21:40 +0200)]
Show backtrace when decode() aborts due to an error.
The backtrace printing was actually already there, but was emitted using
sr_dbg(), which doesn't show up by default for most users. Make it an
srd_err() so that most users will see it.
Gerhard Sittig [Sun, 17 Dec 2017 21:24:10 +0000 (22:24 +0100)]
test: add simple "no data" test case for decoder "terminate and reset"
Introduce a "reset" group of tests. Whip up a first test step which runs
the "terminate and reset" routine for decoder stacks after session
creation, start, and meta data setup. No input data gets processed, no
decoder output is tested yet.
Gerhard Sittig [Sun, 17 Dec 2017 17:55:46 +0000 (18:55 +0100)]
session: add "terminate and reset" support for protocol stacks
Implement routines which terminate currently pending decoder operations
and reset internal state (on the C and Python sides) for instances as
well as sessions. This allows to re-use previously created stacks for
new input data.
Gerhard Sittig [Fri, 26 Jan 2018 20:02:25 +0000 (21:02 +0100)]
Decoder: check for duplicate register() calls in common backend code
Future implementations might call decoders' start() routine several
times, which makes them call register() again. It's desirable that the
common backend code copes with this condition, such that (the multitude
of) decoder implementations need not work around a specific constraint.
Gerhard Sittig [Sun, 4 Feb 2018 18:12:48 +0000 (19:12 +0100)]
instance: make sure oldpins array is available after reset
Introduce an oldpins_array_seed() helper routine, to make sure that each
call site which checks previous pin state will find valid data. This was
not always the case after decoder reset, which released the old pin data
while applications would not call srd_inst_new() again.
Preset newly allocated arrays with the default initial pin state, allow
optional application calls to specify differing initial values (when
specified by users), and keep the current state after first data was
processed.
Gerhard Sittig [Sun, 28 Jan 2018 21:59:59 +0000 (22:59 +0100)]
max7219: introduce constructor and reset() method
The "max7219" decoder used to have no constructor, which made me miss
it when reset() got introduced. Implement those two methods (which do
nothing, and thus won't change behaviour).
Gerhard Sittig [Sat, 13 Jan 2018 18:30:53 +0000 (19:30 +0100)]
microwire: introduce constructor and reset() method
The "microwire" decoder used to have no constructor, which made me miss
it when reset() got introduced. Implement those two methods (which do
nothing, and thus won't change behaviour).
Gerhard Sittig [Sat, 2 Sep 2017 10:52:32 +0000 (12:52 +0200)]
ir_nec: optionally accept input signals that include the carrier
Introduce optional detection of a carrier signal. Immediately "go active"
when edges are seen. "Go inactive" again in the absence of edges in a
specified period of time. Cope with input signals that already had the
carrier removed.
By default carrier detection is disabled, to remain pixel compatible to
the previous implementation. When a carrier frequency is specified and
thus detection is enabled, edges of already filtered input are shifted
by one carrier period, and thus changes the output of the decoder. For
unfiltered inputs that still contain the carrier, detection of activity
is reliable and immediate, but the active phase is extended by one
period of the carrier frequency (which is considered acceptable).
Gerhard Sittig [Thu, 28 Dec 2017 17:08:51 +0000 (18:08 +0100)]
parallel: expand 'wordsize' description (bits vs cycles)
Users may not know which unit the "wordsize" is supposed to get
specified in. Especially when it's not a number of bits, but instead
the number of bus cycles. Expand the description text accordingly.
Gerhard Sittig [Sun, 17 Dec 2017 22:59:16 +0000 (23:59 +0100)]
stepper_motor: make samplerate meta data optional
Only emit the speed annotations when a sample rate was specified. Cope
with the absence of a sample rate for the input stream. Decoding is
still possible, it's just that no timing information is available.
Gerhard Sittig [Sun, 17 Dec 2017 23:05:40 +0000 (00:05 +0100)]
i2s: make samplerate meta data optional
Only emit sound samplerate information when an input stream sample rate
was specified. Cope with the absence of a sample rate for the input
stream. Decoding is still possible, it's just that no timing information
is available.
Gerhard Sittig [Sun, 28 Jan 2018 19:49:48 +0000 (20:49 +0100)]
graycode, morse, pwm, usb_request, wiegand: cope with absent sample rate
Improve robustness of some more protocol decoders. Few of them never
checked for the availability of a sample rate in the first place, others
checked for the presence of a spec but would not cope with a value of 0.
Some checked the value only after processing it, which could result in
runtime errors.
Gerhard Sittig [Sun, 28 Jan 2018 19:02:09 +0000 (20:02 +0100)]
spi: cope when a sample rate of 0 was configured
The explicit test for None was not good enough. Change test conditions
such that sample rates only get processed when they got specified _and_
were not zero.