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.
Gerhard Sittig [Sat, 2 Sep 2017 16:48:03 +0000 (18:48 +0200)]
ac97: introduce first AC'97 decoder implementation (bits, slots, binary)
Introduce an "audio and modem control for PC systems" protocol decoder
(referred to as AC'97).
This implementation extracts bits and identifies frames, and annotates
the slots of a frame with mere integer values. Bit fields get decoded
depending on the slot numbers. Bit patterns in audio/modem data slots
can get exported as binary streams.
Some TODO items remain. Register access (read/write) gets annotated, but
neither gets interpreted nor affects the decoding of subsequent frames.
The RESET# line status does not get evaluated.
Uwe Hermann [Sat, 13 Jan 2018 17:07:57 +0000 (18:07 +0100)]
i2c: Drop obsolete 10bit slave address TODO.
Nobody has seen any such slave in the wild, yet. In the very unlikely
case that someone actually sees or needs this, patches are welcome
though (together with sample .sr files).
Stefan Brüns [Tue, 2 Jan 2018 01:17:07 +0000 (02:17 +0100)]
Add a trivial "counter" decoder
This decoder just counts the number of falling and/or rising edges. This
is especially useful for diagnosing protocols with a clock signal or a
fixed number of transitions per bit, e.g. pulse length coded.
It also provides a divider, which can be used to e.g. count the number
of words in I²C or SPI transfers.
Gerhard Sittig [Fri, 22 Dec 2017 20:07:28 +0000 (21:07 +0100)]
parallel: implement consistent number formatting
Print all annotations for individual data bit items and for the
de-multiplexed words in a consistent style with leading zeros and
constant width. This shall lend itself better to quick navigation
during visual inspection, as well as automatic processing.
Gerhard Sittig [Fri, 22 Dec 2017 14:16:27 +0000 (15:16 +0100)]
parallel: unbreak and improve "word" de-multiplexing
The previous implementation prepared but never fully enabled the
accumulation of several multi-bit items into words that span multiple
bus cycles (think: address or data de-multiplexing on memory busses).
Complete the accumulation, and fixup the end samplenumber for word
annotations. Fixup the endianess logic (the condition was inverted).
Rephrase calculation to be more Python idiomatic.
Default to word size zero, and only emit word annotations for non-zero
word size specs. This keeps the implementation backwards compatible and
still passes the test suite. Default behaviour is most appropriate for
interactive use in GUI environments, while automated processing will
find consistent behaviour across all setups (non-multiplexed busses, and
multiplexed busses with "words" that span one or multiple cycles).
Gerhard Sittig [Fri, 22 Dec 2017 14:12:07 +0000 (15:12 +0100)]
parallel: address minor style nits, no change in behaviour
Remove the redundant .itemcount variable, which exactly corresponds to
the length of the .items array.
Arrange retrieval of options and their evaluation closer to each other
for improved readability.
Use common logic to construct "words" from several multi-bit "items".
Arrange for endianess support by optionally reversing the array before
traversal.
Gerhard Sittig [Fri, 22 Dec 2017 12:55:45 +0000 (13:55 +0100)]
parallel: unify decode() code paths with and without clock signal
Instead of implementing two main loops for operation in the presence and
in the absence of a clock line, use a common main loop which operates on
pre-determined wait conditions.
Gerhard Sittig [Fri, 22 Dec 2017 17:51:00 +0000 (18:51 +0100)]
usb_power_delivery: enforce check order for start-of-packet sequences
The list of a dictionary's keys need not reproduce in identical order
everywhere. Make sure to run all start-of-packet sequence checks in the
decoder implementation in a specific order on each machine, such that
annotations get emitted with identical content and in the same order for
each execution of the decoder.
Gerhard Sittig [Fri, 22 Dec 2017 17:37:29 +0000 (18:37 +0100)]
usb_power_delivery: fixup a Python style nit (dict lookup fallback)
Use the dictionary's .get() method in combination with a default result
parameter, instead of an explicit "k in dictvar" test and a conditional
assignment.
Gerhard Sittig [Fri, 22 Dec 2017 17:33:58 +0000 (18:33 +0100)]
usb_power_delivery: enforce numerical order of RDO/PDO flag annotations
Annotations of the USB power delivery decoder contain multiple text
fragments that correspond to several flags in bit fields. The Python
runtime did not guarantee an order of emission and made the test suite
fail.
Sort the order in which RDO and PDO flags related text fragments get
constructed and concatenated. Print text for higher bit positions first
as this might feel more intuitive to users.
Gerhard Sittig [Mon, 20 Feb 2017 20:37:05 +0000 (21:37 +0100)]
all decoders: introduce a reset() method
Move initialization code of protocol decoders from the constructor to a
new reset() helper method. The libsigrokdecode backend could run this
method several times to clear the decoder's internal state, before new
data from another acquisition gets fed to decode() calls.
Gerhard Sittig [Fri, 22 Dec 2017 02:55:16 +0000 (03:55 +0100)]
ssi32: rename reset() helper method
The ssi32 decoder implements a reset() method which clears internally
accumulated data during decoding. Rename the method before all decoders
will grow a new reset() method that will be used for a different purpose.
Gerhard Sittig [Fri, 22 Dec 2017 02:54:21 +0000 (03:54 +0100)]
mrf24j40: rename reset() helper method
The mrf24j40 decoder implements a reset() method which clears internally
accumulated data during decoding. Rename the method before all decoders
will grow a new reset() method that will be used for a different purpose.
Gerhard Sittig [Fri, 22 Dec 2017 02:51:20 +0000 (03:51 +0100)]
ade77xx: rename reset() helper method
The ade77xx decoder implements a reset() method which clears internally
accumulated data during decoding. Rename the method before all decoders
will grow a new reset() method that will be used for a different purpose.
Gerhard Sittig [Fri, 22 Dec 2017 01:35:12 +0000 (02:35 +0100)]
sdcard_sd: remove unused .reset() method
The decoder's .reset() method seems to partially implement constructor's
assignments, but is not referenced anywhere. There is neither a direct
call site in the remainder of pd.py which uses the "reset" name, and
runtime computation only references "handle_*()" methods for commands
and responses.
Drop the unused .reset() method in the individual decoder before the
introduction of a common .reset() method approach for all decoders.
Gerhard Sittig [Mon, 20 Feb 2017 19:58:09 +0000 (20:58 +0100)]
am230x: rename reset() helper method
The am230x decoder implements a reset() method which clears internal
decoder state. Rename the method before all decoders will grow a new
reset() method that will be used for a different purpose.
Grant Miller [Tue, 14 Nov 2017 09:31:05 +0000 (03:31 -0600)]
ir_nec: Make timing margin relative
This replaces the fixed timing margin with a percentage based tolerance
to better allow for timing inaccuracies, especially for longer timings
like the Leader and Repeat codes.
Marcus Comstedt [Mon, 27 Nov 2017 09:54:35 +0000 (10:54 +0100)]
i2s: Fix unportable use of struct.pack
Using the format string 'I' with the default (implied) prefix '@'
results in both word size and endianness being platform dependent.
In this case standard size (32 bits) and little endianness is
required, so the prefix '<' needs to be used.
Stefan Brüns [Sat, 22 Jul 2017 17:54:59 +0000 (19:54 +0200)]
usb_request: Handle CONTROL transfer protocol stalls
According to the USB 2.0 spec, 8.5.3.4, a protocol stall condition lasts
until the next SETUP transfer. On reception of the SETUP, adjust the end
sample accordingly, and flush the previous CONTROL transfer.
Check for falling edges (i.e. changes to dominant state) between bits of
a CAN frame, and adjust subsequent bit slots' sample points accordingly.
This is a simple implementation which could get improved later. But it
improves the decoder's reliability when the input signal's rate differs
from the nominal rate.
Gerhard Sittig [Sun, 2 Jul 2017 10:23:09 +0000 (12:23 +0200)]
can: rename 'bitpos' variable
Consistently use .sample_point for the member variable that corresponds
to the 'sample_point' property. Use 'samplenum' in .get_sample_point()
to reflect that the routine returns a sample number. This eliminates the
'bitpos' identifier which was used for two different things.
Uwe Hermann [Wed, 28 Jun 2017 20:29:06 +0000 (22:29 +0200)]
Acquire/release the Python GIL where needed to avoid threading issues.
With these additions, frontends can now call libsigrokdecode API
functions from different threads without running into threading issues.
The backend releases the GIL when it is performing tasks that might take
a while and it doesn't need to run Python/C API calls during that time.
This allows frontends to run multiple PD stacks (in multiple frontend
threads) "at the same time" in a time-sharing, "interlocked" manner.
Whenever one of the decoders is inside e.g. self.wait() it releases the
GIL and thus allows other decoders to do some work in the mean time.
The user-visible effect is that for use-cases such as running 3 different
decoder stacks at the same time for an acquisition, the user will not
have to wait for PD 1 to finish decoding, then wait for PD 2 to finish
decoding, and only *then* being able to see annotations from PD 3.
Instead, all three PDs will decode some chunks of data from time to
time, thus the user is able to inspect annotations from all 3 PDs while
the acquisition and decoding is still going on.
Gerhard Sittig [Sun, 18 Jun 2017 10:24:32 +0000 (12:24 +0200)]
lpc: Improve robustness when decoding unexpected input data
The 'fields' table of state and descriptions is not fully populated,
some slots are missing. Cope with lookup misses when unexpected input
data is not found in the table. Use different error text in annotations
for described but invalid states (the previous implementation used
"reserved / invalid"), and for states that are not described in the
table (introduce the "reserved / unknown" text for conditions that are
not covered by the decoder implementation).
The previous implementation missed the emission of some warnings. When a
"reserved / invalid" description was found, the subsequent exact match
for "reserved" failed and the warning was not emitted. Weaken the test
to emit warnings for either description that has "reserved" in it,
regardless of whether the text was found in the table or is not part of
the table at all.
Gerhard Sittig [Sun, 18 Jun 2017 18:46:40 +0000 (20:46 +0200)]
guess_bitrate: Eliminate internal state of the decoder
Getting the first edge outside of the loop in .decode() greatly
simplifies the logic, any other edge then is just an update of the
previously collected data, determined by always equal code.
Telling .wait() to "skip one sample" slightly obfuscates the intent of
getting the next samples while no condition applies. Explicitly pass no
condition arguments instead, to better reflect the purpose. Coincidently
these .wait() calls will execute in slightly less expensive code paths
in the common code.
Gerhard Sittig [Sun, 5 Mar 2017 17:31:18 +0000 (18:31 +0100)]
decoder: Accept more forms of "unconditional wait()" (None, no args)
The Decoder.wait() method expects a list of dicts, or as a special form
a single dict, to specify the conditions to wait for. An empty dict or
an empty list mean "unconditional wait", requesting the very next sample.
Accept None as well as no arguments at all in Decoder.wait() calls. This
shall better reflect the intent and slightly unobfuscate PD code, as well
as avoid creation of potentially expensive Python objects at the call site.
Gerhard Sittig [Sun, 18 Jun 2017 17:12:11 +0000 (19:12 +0200)]
decoder: Unbreak execution of Decoder.wait() with empty condition
The Decoder.wait() method works as expected when non-empty conditions
are specified by the caller. For empty conditions the implementation was
incomplete, and ended up in an infinite loop because the sample number
got stuck in the current location. Code review revealed more issues like
not getting more input data chunks when needed.
Detect when empty wait() conditions were specified, and re-use existing
code paths for match handling as much as possible. This is achieved by
the manual creation of a SKIP term with the appropriate count value.
It's assumed that naive decoder implementations will run this kind of
condition-less query for every individual sample, which means that
efficiency is important.
Make sample number 0 available to condition-less calls, too. Don't skip
the first sample in the input stream.
Gerhard Sittig [Sun, 18 Jun 2017 11:50:48 +0000 (13:50 +0200)]
pwm: Fixup sample numbers for binary output
Do reference the period's start and end sample numbers when the
duty cycle is written to the binary output stream. The previous
implementation inappropriately used the period counter instead.
Gerhard Sittig [Sun, 18 Jun 2017 10:59:31 +0000 (12:59 +0200)]
pwm: Rephrase edge and period detection, eliminate internal state
With the simplicity of PWM waveforms and the convenience of the v3 API,
there is no need to maintain internal state. After the start of the
first period was determined based on the input signal's polarity, any
period is defined by just the next two edges, and the next period is
immediately to follow.
Uwe Hermann [Fri, 16 Jun 2017 14:27:08 +0000 (16:27 +0200)]
Mark all stacked decoders as being PD API version 3.
This is not really relevant for stacked PDs currently (they can be used
unmodified with either PDv2 or PDv3 low-level decoders), but it'll allow
us to drop PDv2 support completely.
Uwe Hermann [Thu, 15 Jun 2017 15:52:55 +0000 (17:52 +0200)]
session.c: Fix a compiler warning on Mac OS X.
session.c:203:22: warning: format specifies type 'unsigned long long'
but the argument has type 'guint64' (aka 'unsigned long') [-Wformat]
sess->session_id, g_variant_get_uint64(data));
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
libsigrokdecode-internal.h:103:44: note: expanded from macro 'srd_dbg'
#define srd_dbg(...) srd_log(SRD_LOG_DBG, __VA_ARGS__)
^~~~~~~~~~~
Uwe Hermann [Mon, 12 Jun 2017 01:16:21 +0000 (03:16 +0200)]
Bump libtool version (not package version) to 4:0:0.
The last release (0.4.0) had the libtool version (current:revision:age)
set to 3:0:0. Since this release removes and changes interfaces, the
new version is 4:0:0.
This changes the library filename (e.g. on Linux) from
libsigrokdecode.so.3.0.0 to libsigrokdecode.so.4.0.0, the SONAME
(+symlink) becomes libsigrokdecode.so.4.
Gerhard Sittig [Tue, 6 Jun 2017 21:12:04 +0000 (23:12 +0200)]
spi: Missing samplerate spec is not fatal
Check for the availability of a samplerate specification, but don't
abort in its absence. Lack of the samplerate only prevents the emission
of throughput annotations, but still allows decoding the clocked signal.