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.
Wolfram Sang [Wed, 26 Apr 2017 15:17:31 +0000 (17:17 +0200)]
sdcard_sd: always show CMD argument in hex
This is especially useful with the default handler, so you can better
understand the transfer if you are already familiar with CMD numbers and
their arguments. It makes it also easier to compare with the debug
output of the e.g. Linux Kernel.
Uwe Hermann [Fri, 31 Mar 2017 17:18:19 +0000 (19:18 +0200)]
Don't show a harmless/confusing warning on stdout.
Some Python versions will lead to the following message on stdout currently:
srd: Attribute Error: Failed to load decoder common: no 'Decoder' \
attribute in imported module: 'module' object has no attribute 'Decoder'
This is a harmless (though confusing for users) warning, since "common"
is not an actual PD and it shouldn't be loaded as PD (it just has to
be present).
Gerhard Sittig [Tue, 14 Mar 2017 18:01:04 +0000 (19:01 +0100)]
uart: Use consistent order of steps when processing samples
Slightly rearrange some of the methods which are involved in UART frame
inspection. Use a consistent sequence of steps: Grab the signal's
current value, accumulate and process the information, emit respective
annotations, and advance to the next stage in the UART frame inspection.
Gerhard Sittig [Tue, 14 Mar 2017 18:15:31 +0000 (19:15 +0100)]
uart: Remove redundant "reached bit" checks
After the decode() method got adjusted to call wait() with custom made
conditions and to check .matched[] before inspecting samples, the check
whether a bit time's sample point was reached has become obsolete.
Gerhard Sittig [Tue, 14 Mar 2017 17:46:32 +0000 (18:46 +0100)]
uart: Improve robustness of query API result processing
Since either of the UART signals (RX, TX) is optional, and in the
absence of Decoder.wait() conditions that "will never match", we cannot
construct a constant layout. Instead we need to explicitly keep track of
which item in the list of wait conditions corresponds to which signal.
Once the index in the list of wait conditions is known, inspection of
samples can depend on the Decoder.matched[] attribute. Before this
change, redundant reached_bit() checks kept us from processing samples
that should not have been inspected. Tests pass before and after this
very commit.
Gerhard Sittig [Tue, 14 Mar 2017 17:15:51 +0000 (18:15 +0100)]
uart: Reduce redundancy in sample inspection (state machine)
Factor out the logic which inspects samples that were provided by the
PD version 3 query API, and dispatches their processing depending on
the progress of UART frame inspection. "Unroll" a loop over the RX and
TX signals.
This commit replaces some complicated variable assignments by easier to
verify invocations.
Gerhard Sittig [Tue, 14 Mar 2017 17:00:06 +0000 (18:00 +0100)]
uart: Convert to PD API version 3
Adjust the UART protocol decoder, to make use of the query based API.
Have edges detected and unrelated samples skipped by common code.
This implementation keeps some redundancy in place (like checking for
having reached specific sample numbers, while the backend managed that
for us). This approach reduces the diff and shall simplify review.
Only some common checks in decode() were moved to the start of the
routine, outside of the sample inspection loop.
Gerhard Sittig [Tue, 14 Mar 2017 16:10:28 +0000 (17:10 +0100)]
uart: Minor readability nit (position of start bit in calculation)
Rephrase the bit slot index calculation for UART frames such that it
becomes more apparent whether a start bit is involved or whether an
array index needs adjustment due to Python range semantics.
This shall improve readability, and reduce the probability of off-by-one
errors during maintenance.
Gerhard Sittig [Tue, 14 Mar 2017 14:35:27 +0000 (15:35 +0100)]
uart: Immediately skip reception of parity bits when not applicable
When the UART frame does not contain a parity bit, then immediately
advance to reception of stop bits after all data bits were received.
This eliminates the necessity to run the parity check routine when
parity does not apply in the first place. Without this change, some
"dummy" sample needs to get inspected for correct operation of the
state machine.
Gerhard Sittig [Sun, 5 Mar 2017 17:09:59 +0000 (18:09 +0100)]
decoder: terminate .wait() and .decode(), join threads for v3 instances
Add support to terminate blocking .wait() and .decode() method calls of
v3 decoder instances. This terminates the decoder thread's main routine
and allows to release associated resources. Cope with requested as well
as unexpected termination of decode() calls. Add debug messages to
thread related code paths.
Make sure to unblock the main thread which feeds the decoder thread.
This unbreaks situations where decoders e.g. throw "need samplerate to
decode" exceptions.
Drain Python errors which might remain from the most recent .decode()
execution, to not affect other code paths. This avoids an issue where
the creation of a new decoder instance fails in the presence of errors
from a previous run.
Marcus Comstedt [Sun, 26 Feb 2017 12:07:03 +0000 (13:07 +0100)]
Return SRD_ERR_ARG from srd_inst_decode if samplenums are wrong
This validates the requirements that
* abs_start_samplenum continues where the previous decode ended
* abs_end_samplenum is not lower than abs_start_samplenum
Failure to meet these requirements will make v3 decoders crash.
Marcus Comstedt [Sun, 26 Feb 2017 11:52:12 +0000 (12:52 +0100)]
Fix refcounting bug in set_new_condition_list()
py_conditionlist is an owned reference (it gets passed to Py_DecRef()
at the end), so we need to increment the refcount when assigning it
from the borrowed reference py_conds.