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.
Gerhard Sittig [Tue, 6 Jun 2017 20:55:52 +0000 (22:55 +0200)]
spi: Improve use of PD API version 3
Eliminate more instances where Python code tracked signal changes instead
of having common library code do the work. Reduce the number of boundary
crossings between library and decoder code (Python vs C), by inspecting
fewer input edges. Yet cope with the CS signal's being optional. Emit
identical annotations to the previous implementation for CS changes,
including the initial change "from None to 0/1". Sort the checks for
optional input signals at the top of decode() into a more natural order.
Improve and update comments.
This commit results in a more appropriate use of the PD v3 API in the
SPI protocol decoder.
Gerhard Sittig [Tue, 6 Jun 2017 19:13:27 +0000 (21:13 +0200)]
gpib: Convert to PD API version 3
Have edges detected in common library code. Cope with optional initial
low level (without an edge) at the start of sample data. Handle the
optionally enforced processing at a specified sample number.
Gerhard Sittig [Tue, 6 Jun 2017 18:05:05 +0000 (20:05 +0200)]
spi: Convert to PD API version 3
Have edges detected in common library code. Move the test for presence
of optional channels out of the decode loop. Do inspect the very first
sample for pixel compatibility with the previous implementation.
Uwe Hermann [Thu, 11 May 2017 21:20:58 +0000 (23:20 +0200)]
Add srd_inst_initial_pins_set_all() and support code.
This allows frontends to set the assumed initial pins (i.e., the assumed
state of the pins before the first sample of a capture) to user-specified
values.
The assumed initial pins can be either low, or high, or "use same value
as the first sample of the capture".
The special self.initial_pins decoder attribute is now removed.
Gerhard Sittig [Sun, 14 May 2017 17:08:37 +0000 (19:08 +0200)]
can: Skip stuff bit inspection where not applicable
Bit stuffing does not apply to the last fields of a frame, specifically
the CRC delimiter, the ACK, and the end-of-frame fields. Adjust the
respective bit handling logic.
Gerhard Sittig [Sun, 14 May 2017 17:36:17 +0000 (19:36 +0200)]
can: Convert to PD API version 3
Don't inspect each individual sample in the Python based PD. Instead use
the backend's query API to detect the start of a frame and to advance to
the sample point position.
Wolfram Sang [Fri, 12 May 2017 11:58:28 +0000 (13:58 +0200)]
sdcard_sd: reference latest command when displaying response
Replace the hardcoded value with the last cmd used. I'd think the whole
ACMD handling could be simplified if we make further use of this new
variable. But for now, let's keep it simple and make it work.
Karl Palsson [Fri, 20 Jan 2017 16:24:29 +0000 (16:24 +0000)]
timing: add edge-edge mode and delta calculation
Instead of only measuring the timing from any edge to any edge, provide
a mode to measure the times from falling->falling and rising->rising
edges. This works better to monitor timing of an IRQ pin for instance,
that drives one direction under hardware, and is only cleared by
software reading a value.
Include time delta measurements as an optional annotation to help track
jitter in measurements.
Uwe Hermann [Fri, 5 May 2017 18:18:54 +0000 (20:18 +0200)]
microwire: Use namedtuple for the Python output.
This has two advantages:
- The Python output is always deterministic, which was not the case for
the dict-based version since dict items have no guaranteed order in
Python. This caused issues with the sigrok-test use-case.