]> sigrok.org Git - libsigrokdecode.git/log
libsigrokdecode.git
6 weeks agoavr_isp: Add more parts master github/master
atoomnetmarc [Mon, 4 Mar 2024 19:36:46 +0000 (20:36 +0100)]
avr_isp: Add more parts

7 weeks agoavr_isp: fix crash if part name is not known
Simon Ruderich [Thu, 8 Feb 2024 23:21:23 +0000 (00:21 +0100)]
avr_isp: fix crash if part name is not known

Decoding an unknown part causes a KeyError exception. For example for an
ATmega328/P:

    srd: KeyError: Calling avr_isp-1 decode() failed: (149, 15)

2 months agost25r39xx_spi: Fix FIFOR/FIFOW issues with PV's Tabular Output View
bvernoux [Tue, 10 Aug 2021 18:01:18 +0000 (20:01 +0200)]
st25r39xx_spi: Fix FIFOR/FIFOW issues with PV's Tabular Output View

The issue exists because of FIFO Read/FIFO Write commands not returning the annotations short name FIFOR/FIFOW

5 months agosrd: drop deprecated PyEval_InitThreads() on Python 3.9+
Sascha Silbe [Mon, 23 Oct 2023 20:21:38 +0000 (22:21 +0200)]
srd: drop deprecated PyEval_InitThreads() on Python 3.9+

`PyEval_InitThreads()` is called implicitly during `Py_InitializeEx()`
since Python 3.7. It has been deprecated since 3.9 and dropped in
3.13.

[ gsi: touch up comment style ]

6 months agospiflash: add MX25L8006 device type
fenugrec [Wed, 26 Apr 2023 17:28:40 +0000 (13:28 -0400)]
spiflash: add MX25L8006 device type

8 months agosae_j1850_vpw: rewrite decoder to improve usability and maintenance
Gerhard Sittig [Sun, 30 Jul 2023 16:01:29 +0000 (18:01 +0200)]
sae_j1850_vpw: rewrite decoder to improve usability and maintenance

The previous implementation of the SAE J1850 (VPW) decoder dumped bytes
on one row and added another row with textual labels what those upper
row bytes would mean. That allowed manual inspection at a rather low
level of abstraction, but is not idiomatic and reduces usability of the
decoder.

Rewrite the decoder to become more idiomatic, and to prepare future
inspection of more upper layers. Concentrate all timestamp gathering in
.decode(), use PD API v3 for the IFS timeout as well, run handlers for
the lowest level symbols. Pass accumulated protocol bytes to a fields
handler, flush accumulated details when EOF is seen. Prepare validity
checks (checksum verification), and prepare to handle data bytes when
all header fields were seen and validity was checked. Emit annotations
in proper classes to improve usability, start emitting warnings. Force
re-synchronization when input stream conditions are not handled.

8 months agorgb_led_spi: adjust decoder implementation's Python style
Gerhard Sittig [Sun, 30 Jul 2023 15:03:39 +0000 (17:03 +0200)]
rgb_led_spi: adjust decoder implementation's Python style

Eliminate unneeded instance variables. Start from None when values are
unknown. Only access data after checking its availability. Invalidate
previously accumulated details after processing. Prefer .format() over
string modulo. Use list .clear() where applicable. Use symbolic names
for annotation classes.

8 months agorgb_led_ws281x: default to RGB[W] annotation text order
Gerhard Sittig [Sat, 29 Jul 2023 15:26:48 +0000 (17:26 +0200)]
rgb_led_ws281x: default to RGB[W] annotation text order

The earlier default was "RGB" (exactly three components), and users had
to manually pick "RGBW" when white was involved. Change the default to
the automatic "RGB[W]" instead which transparently presents white when
applicable, and doesn't fail when white is not involved.

8 months agorgb_led_ws281x: emit annotations for individual colour components
Gerhard Sittig [Sat, 29 Jul 2023 15:23:02 +0000 (17:23 +0200)]
rgb_led_ws281x: emit annotations for individual colour components

The previous implementation presented bits and per-LED RGB-values (in
a from similar to HTML colours). This commit introduces annotations
for individual colour components (R/G/B/W) between these two levels
of abstraction.

8 months agorgb_led_ws281x: add developer comments, link to chip datasheets
Gerhard Sittig [Sat, 29 Jul 2023 15:09:40 +0000 (17:09 +0200)]
rgb_led_ws281x: add developer comments, link to chip datasheets

Add developer comments at the top of the decoder source. Reference
datasheets, discuss vendor's numbers and what's used in the field.
Discuss variants (sets of involved colour components, alternative
timings, reset detection).

8 months agorgb_led_ws281x: support more colour component orders (wire, and text)
Gerhard Sittig [Sat, 29 Jul 2023 14:59:43 +0000 (16:59 +0200)]
rgb_led_ws281x: support more colour component orders (wire, and text)

The 'type' option was not good enough. Replace it by 'wireorder' (order
of colour components on the wire, depends on the RGB LED chip type), and
'textorder' (presentation to users in annotations).

Support many more layouts of colour components on the wire. Cover all
permutations of R, G, and B. Support a few RGB plus W layouts that are
known to be in use. Adding more is just a matter of adding more choices
in the option, the implementation transparently follows.

Support a few text orders: Reflect the very order of bits on the wire.
Automatic support for RGB with optional White, or fixed RGB or RGB-W
variants (all are users' choices, default remains "RGB" for backwards
compatibility). Support arbitrary combinations of wire order and text
order in emitted annotations.

Keep support for the weird RGWB text format, which the previous decoder
implementation used for "all" RGBW types, and which is referenced by
existing test cases. It is uncertain which chip type is supposed to
generate this specific RGBW traffic. It is as uncertain why this text
order was chosen, which neither is the human readable RGBW format nor
matches the wire order. The previous implementation was introduced in
commit 47ff9910f7e1, but neither commented nor referenced literature or
external sources nor did the commit message contain any clues.

This current implementation needs more tests and reviews, but lends
itself better to maintenance, fixes and enhancements.

8 months agorgb_led_ws281x: rework the .decode() main loop, improve robustness
Gerhard Sittig [Sat, 29 Jul 2023 14:53:07 +0000 (16:53 +0200)]
rgb_led_ws281x: rework the .decode() main loop, improve robustness

Concentrate timestamp gathering in the .decode() method, eliminate
instance members by using variables that are local to the method.
Finally use appropriate PD API v3 invocations. Use edge conditions plus
a counted 'skip' to detect the RESET pulse. Use a positive "check the
reset condition" logic, simplify the conditions which support the reset
pulse tracking, and which flush previously accumulated data when "the
bit time doesn't end" (the next edge is missing).

Improve robustness in those cases where captures use low oversampling
and similar length high and low pulses. The fixed (rather arbitrary?)
625us threshold resulted in several false last-bit values after the
API v3 conversion.

Heavily comment on this edge/pulse detection and timestamps logic,
since it's non-trivial and non-obvious. Keep all behaviour backwards
compatible before extending the feature set in future commits.

8 months agorgb_led_ws281x: refactor bit/bits handling, use more common code
Gerhard Sittig [Fri, 28 Jul 2023 05:56:46 +0000 (07:56 +0200)]
rgb_led_ws281x: refactor bit/bits handling, use more common code

Pass all .decode() routine's bit handling through a common bit handler.
Accumulate the bit values as well as their ss/es timestamps. Reduce code
duplication in the bits handler. Use common support code to get the
24/32 bit wide integer from the list of bits. Prepare to handle streams
of different per-pixel length or layout.

This commit remains backwards compatible, and keeps all warts of the
previous implementation including inconsistent annotation order. Just
eliminates unnecessary instance members and hidden coupling, to keep
timestamp handling in the .decode() method.

8 months agorgb_led_ws281x: rephrase .put() calls for readability
Gerhard Sittig [Fri, 28 Jul 2023 05:40:14 +0000 (07:40 +0200)]
rgb_led_ws281x: rephrase .put() calls for readability

Separate the construction of the list of texts for different zoom levels
from the emission of annotations. Use a .putg() helpers to match other
decoder implementations. Prefer .format() calls over "modulo" operations
on strings.

8 months agorgb_led_ws281x: use symbolic names for annotation classes
Gerhard Sittig [Fri, 28 Jul 2023 05:27:37 +0000 (07:27 +0200)]
rgb_led_ws281x: use symbolic names for annotation classes

8 months agones_gamepad: adjust Python style of decoder implementation
Gerhard Sittig [Fri, 28 Jul 2023 06:08:38 +0000 (08:08 +0200)]
nes_gamepad: adjust Python style of decoder implementation

Rephrase the NES gamepad decoder to become more idiomatic Python.
Address nits to better match the sigrok project's coding style.
Eliminate hidden coupling by means of instance variables.

9 months agoi2c: rephrase state machine, eliminate text matching
Gerhard Sittig [Mon, 17 Jul 2023 18:16:15 +0000 (20:16 +0200)]
i2c: rephrase state machine, eliminate text matching

Rephrase the conditions which drive the I2C decoder's progress. Remove
self.state and its space separated string literals which were tedious to
search for, and which "lent themselves" to magic string matching. Use
other existing conditions instead, which also reduces redundancy.

Defer the "forgetting data bits" until after ACK was seen. Comment on
the motivation to keep the "protocol violating" implementation, which
misses error conditions that happen on the wire, but happens to support
heavily undersampled captures to an astonishing degree.

Also addresses minor style nits: Prefer to think of "dominant ACK" and
"recessive NAK". Rephrase a byte shift for the first address byte. Emit
the first warning annotation for the row which was declared before but
was not used so far.

9 months agoi2c: concentrate sample number and value getting in main loop
Gerhard Sittig [Mon, 17 Jul 2023 18:01:07 +0000 (20:01 +0200)]
i2c: concentrate sample number and value getting in main loop

It's unfortunate how the symbol / bit value handlers of the I2C decoder
keep redundantly accessing the .samplenum property. Ideally they should
just get an ss, es, value tuple, while the determination of these params
should be kept in the .decode() main loop.

Prepare the internal implementation to that approach, but enforce an
absolutely backwards compatible behaviour for now. This was verified by
the test suite. The data bit handler still keeps updating previous bits'
end positions when another bit is seen. Which assumes back to back bits
which strictly speaking does not match the protocol's definition. The
unfortunate application of the second last bit time's width to the last
bit time and the ACK slot is kept as well. And the code path needed to
be kept within the bit handler, because the second last bit's width only
becomes available when the last bit _was_ handled. Which means that the
main loop cannot provide a useful es value which matches the previous
implementation's behaviour.

9 months agoi2c: also shift first address byte for 10bit slave addresses
Gerhard Sittig [Mon, 17 Jul 2023 16:51:02 +0000 (18:51 +0200)]
i2c: also shift first address byte for 10bit slave addresses

The first address byte in an I2C transfer always carries the R/W bit.
Always shift this byte regardless of 7/10 bit addresses, and always emit
separate annotations for the address value part and the R/W bit part.

9 months agoi2c: unobfuscate ss/es passing for put, document BITS order
Gerhard Sittig [Mon, 17 Jul 2023 16:50:21 +0000 (18:50 +0200)]
i2c: unobfuscate ss/es passing for put, document BITS order

Eliminate how the I2C decoder's put methods take data as arguments and
hiddenly take ss/es from instance variables. This improves readability
during review. Rename .putx() to .putg() to match other decoders (emits
graphical annotations, in contrast to Python and binary).

Document the surprising BITS pdata order, stacked decoders get LSB first
sequences. To keep awareness during maintenance. Keep an explicit copy
of the LSB bits to simplify the implementation of the data byte handler
(sample numbers remain available at indices in their reception order).

9 months agoi2c: improve reliability of bitrate estimation (throughput, meta)
Gerhard Sittig [Mon, 17 Jul 2023 16:37:37 +0000 (18:37 +0200)]
i2c: improve reliability of bitrate estimation (throughput, meta)

The I2C decoder used to track the bitrate of the observed traffic
(number of address and data bits in a transfer). It's uncertain where
this output went (is meta still supported, are applications using it?),
and it appears to not be covered in tests. Improve the logic still.

Adjust the location of the emitted annotation. It used to start at the
most recently observed data byte, which looks suspicious. Output was
attempted when STOP was seen, even if the start was not observed. The
calculation dropped data before a repeated start. The implementation
kept data around after it became obsolete.

Break a long formula across several text lines. Use the fact that Python
division yields floating point results.

Add a comment in the ACK/NAK bit handler. It references data which was
gathered when accumulating data bits. Could be acceptable but must be
remained aware of.

9 months agoi2c: unify emission of annotations, always use proto{} table
Gerhard Sittig [Mon, 17 Jul 2023 16:23:03 +0000 (18:23 +0200)]
i2c: unify emission of annotations, always use proto{} table

Slightly unobfuscate how the I2C decoder invokes put methods. Present
the annotation class and the list of texts for different zoom levels
for readability. Also keep the data value presentation in that table
so that it holds all texts which users will see during decoder use.
Eliminate how the data bits used to bypass that table in the past.

This commit does not address the unfortunate self.ss/es coupling of
decoding code paths and annotation emitting helpers, which complicates
review of the decoder's implemented logic.

9 months agoi2c: more idiomatic use of Python list, reduces redundancy, comments
Gerhard Sittig [Fri, 14 Jul 2023 15:43:08 +0000 (17:43 +0200)]
i2c: more idiomatic use of Python list, reduces redundancy, comments

Collect all bits of a byte time in a Python list (as was done before).
Eliminate the bit counter and the value accumulator, use the list's
length during accumulation and common conversion support after the
accumulation instead.

Also comment on the non-trivial start/end sample number update logic.
The decoder implementation likes to claim data validity outside of the
high SCL phase, which does not agree with the strict I2C protocol idea.
Increases usability though (data visibility at zoom levels). This and
backwards compatibility makes us keep the logic, as long as we remain
aware of its implications.

Comment on the rather unexpected LSB first emission of annotations and
stacked layer data passing, while the I2C protocol itself is MSB first.

9 months agoeeprom24xx: avoid access to caller's data after validity ends
Gerhard Sittig [Fri, 14 Jul 2023 06:12:13 +0000 (08:12 +0200)]
eeprom24xx: avoid access to caller's data after validity ends

The at24 EEPROM decoder's previous implementation happened to access
caller's data even after the .decode() method invocation ended, and
their content has changed or the data was not valid any longer.

Get deep copies for those details which broke the test suite. Prepare
"generous" deep copies for other data which currently doesn't trigger
exceptions, but might be waiting for an accident to happen. Careful
inspection of the complex implementation and relaxing the current greed
of this commit remains for future commits. Comment heavily for awareness.

It is assumed that the 'databyte' name is misleading. And that much of
this upper layer decoder's complexity would be obsoleted by the lower
layer decoder's providing more useful packets (bytes and their ACK state,
read/write phases of transfers, complete transfers up to STOP, etc).
This commit does not address those readability or layering concerns.

9 months agoi2cfilter: rephrase decoder implementation for maintainability
Gerhard Sittig [Fri, 14 Jul 2023 05:40:03 +0000 (07:40 +0200)]
i2cfilter: rephrase decoder implementation for maintainability

The previous implementation suffered from a severe issue (it kept
referencing caller's data beyond its validity) and from style issues
(redundant details, conditions scattered across distant locations).

Rephrase (actually rework) the decoder implementation to improve
readability as well as maintainability. Extend the TODO list while
the existing logic better lends itself to future extensions. Reword
comments while we are here. Some earlier constraints no longer apply
or were unfortunately phrased.

9 months agoi2c: add support for 10bit slave addresses
Gerhard Sittig [Fri, 14 Jul 2023 15:28:32 +0000 (17:28 +0200)]
i2c: add support for 10bit slave addresses

Slave addresses can be of 7bit or 10bit type, which occupies one or two
bytes at the start of the frame. Detect when a 10bit address is seen,
and classify the following byte as yet another address byte (which the
previous implementation incorrectly classified as data byte).

This commit only accumulates the address value and adjusts the class of
annotations. It does not introduce new annotation classes or rows, to
not change the decoder in incompatible ways.

9 months agoi2c: rename variables and adjust data types for readability
Gerhard Sittig [Fri, 14 Jul 2023 15:18:30 +0000 (17:18 +0200)]
i2c: rename variables and adjust data types for readability

Use longer names for variables and adjust their data types to improve
readability of the "is write?", "is repeated start?" conditions. Use a
boolean when the condition is known, and preset to None when the state
is yet uncertain. Rename .bits[] to .data_bits[] to reflect that they
exclusively hold the byte's bits and not the ACK/NAK bit.

12 months agoconfigure: break long list of python-embed packages
Gerhard Sittig [Thu, 13 Apr 2023 18:37:17 +0000 (20:37 +0200)]
configure: break long list of python-embed packages

12 months agoconfigure: Add python 3.11 and 3.12 support
Frank Stettner [Wed, 12 Apr 2023 08:07:10 +0000 (10:07 +0200)]
configure: Add python 3.11 and 3.12 support

15 months agoadf435x: add support for register field content warnings
Gerhard Sittig [Fri, 30 Dec 2022 16:36:46 +0000 (17:36 +0100)]
adf435x: add support for register field content warnings

Add support for register field content checkers, and emit warning
annotations when they yield non-empty results. Implement a checker for
the INT field of register R0. Reduce the allowed values' lower limit
from 32 (previous implementation) to 23 (ADF4350 datasheet, figure 24).

15 months agoadf435x: shuffle register description table
Gerhard Sittig [Fri, 30 Dec 2022 16:13:19 +0000 (17:13 +0100)]
adf435x: shuffle register description table

Move table columns, put the bit field position to the front before the
name to get a less fragile visual appearance. All fields have a position
and a name (of variable length), some of them have a "parser" (actually
a formatter for their content).

Address Python style while we are here: Prefer tuples over lists for
immutable data. Add trailing commas to reduce future diff sizes.

Add a TODO comment about optional content checkers. The current decoder
implementation lets invalid register data pass unnoticed.

[ see a word diff for the commit's essence ]

15 months agoadf435x: rephrase table lookups for display texts
Gerhard Sittig [Fri, 30 Dec 2022 14:28:07 +0000 (15:28 +0100)]
adf435x: rephrase table lookups for display texts

Try a different presentation of exising information in the register
fields' display text construction (extra parsers for known fields).
Attempt a source code format which hopefully better lends itself to
index range verification during review.

Make the number of available expansion texts stand out more visually,
so that readers can compare their count to the register field's width.
Address those register fields with four or more expansion values, keep
the simple single bit cases as they are. Add a comment for awareness.

15 months agoadf435x: use .format() for Python string formatting
Gerhard Sittig [Fri, 30 Dec 2022 13:30:55 +0000 (14:30 +0100)]
adf435x: use .format() for Python string formatting

Rephrase the old style '%' operator string formatting, prefer .format()
calls instead. It is assumed that routine call argument lists are more
readable than optional/conditional tuples are, and not running format
specifiers and literal text into each other helps readability as well,
as do the .format() routine's optionally named references to parameters.

Avoid text formatting which involves concatenation, always work from one
single format instruction instead.

15 months agoadf435x: factor out inspection of 32bit words
Gerhard Sittig [Fri, 30 Dec 2022 10:57:04 +0000 (11:57 +0100)]
adf435x: factor out inspection of 32bit words

Move the inspection of a completed 32bit word into the .decode_word()
routine. This simplifies checks for fatal constraints, as well as
optional inspection of deeper detail levels when extra parsers are
available.

Rename variables in the code path which accumulate bits. Add comments
to helper routines and to essential steps in complex interpretation
code paths. Eliminate the unused return value of the .decode_field()
method. Results in a lean and readable .decode() body.

15 months agoadf435x: rework emission of annotations
Gerhard Sittig [Fri, 30 Dec 2022 08:55:30 +0000 (09:55 +0100)]
adf435x: rework emission of annotations

Separate data processing from text formatting in the code paths which
emit annotations. Introduce a local .putg() helper. This unobfuscates
the decoder's operation, and also happens to shorten text lines. Raises
awareness for zoom levels and alternative text during maintenance.

This commit incompatibly rephrases the "Wrong number of bits" message.

15 months agoadf435x: Python list idioms in bits sequence accumulation
Gerhard Sittig [Fri, 30 Dec 2022 13:10:04 +0000 (14:10 +0100)]
adf435x: Python list idioms in bits sequence accumulation

Use .extend() and .clear() for the Python list during accumulation of a
32bit word's bits sequence. This shall improve readability. Performance
is less of an issue since this decoder's data amount remains small
(32bit entities per SPI transfer).

Comment on the unexpected(?) SPI decoder's BITS ordering when passing
details up to stacked decoders. Raise and keep awareness for this
non-obvious implementation detail during decoder maintenance.

This implementation accumulates bits in the MSB order as they are sent
in SPI frames. Yet keeps the LSB bit order when a completely accumulated
32bit word gets inspected, to reduce the diff size. Bit field extraction
and annotation emission code paths assume a specific timestamp ordering.
The separation of transport and inspection also simplifies maintenance,
should a future SPI decoder provide BITS in their received order.

15 months agoadf435x: use common bits to number conversion helper
Gerhard Sittig [Fri, 30 Dec 2022 13:09:03 +0000 (14:09 +0100)]
adf435x: use common bits to number conversion helper

Use common support code to convert bit fields to integer numbers. Also
unobfuscate the decode_bits() method and its returned values' layout.
Improves readability and factors out common expressions.

15 months agoadf435x: Move decoder logic to SPI transfers
Vesa-Pekka Palmu [Mon, 26 Dec 2022 17:18:36 +0000 (19:18 +0200)]
adf435x: Move decoder logic to SPI transfers

The previous implementation of the ADF435x decoder assumed knowledge of
internal details which are the SPI transport layer's responsibility. And
encoded an inappropriate chip select polarity in the process (falling
CS edge). The datasheet specifies that previously clocked in data bits
get latched on rising LE edges.

Not all setups were affected, that's why the issue went unnoticed before.

Use the lower layer's TRANSFER annotation to process the completion of
an ADF435x register access, after BITS annotations made the location of
individual bits available. The LE (CS) signal's polarity remains a detail
of the SPI decoding layer, and must be configured there. The SPI decoder's
default matches the ADF435x chip's expectation.

This fixes bug #1814.

Reported-by: Martin Homuth-Rosemann <redacted>
15 months agoadf435x: Add warning on frame size mismatch
Vesa-Pekka Palmu [Mon, 26 Dec 2022 17:05:18 +0000 (19:05 +0200)]
adf435x: Add warning on frame size mismatch

Check the bit count of SPI transfers. Only start inspecting ADF435x
register content when the accumulation of the expected 32bit word has
completed. Emit a warning annotation for unexpected transfer sizes.

15 months agoadf435x: Clean up SPI data input
Vesa-Pekka Palmu [Mon, 26 Dec 2022 17:00:56 +0000 (19:00 +0200)]
adf435x: Clean up SPI data input

Avoid generic variable names. Only unpack parameters which are provided
by the lower layer decoder after the stacked decoder checked their type
and is aware of their meaning.

16 months agoutil: silence printf format compiler warnings (Python ssize_t)
Gerhard Sittig [Thu, 24 Nov 2022 12:10:04 +0000 (13:10 +0100)]
util: silence printf format compiler warnings (Python ssize_t)

On some platforms PY_FORMAT_SIZE_T seems to be ineffective, resulting in
compiler warnings about printf format data type mismatches (observed in
MXE builds).

Silence the warnings. Prefer the ssize_t data type instead which we know
the printf format of, reliably.

16 months agotype_decoder: silence print format warnings, greppable messages
Gerhard Sittig [Fri, 28 Sep 2018 18:23:36 +0000 (20:23 +0200)]
type_decoder: silence print format warnings, greppable messages

Silence printf(3) format warnings. Python's data types should be
considered opaque, size (and signedness) are usually unknown, as is
the relation to standard C language print format specs.

Unbreak long messages which were spread across several source code
text lines. This complies to Linux style guides. Being able to find
diagnostics messages that were reported by users in sources is more
important than sticking to an arbitrary text line length.

16 months agonit: break a long line in different ways, unobfuscate parameter grouping
Gerhard Sittig [Mon, 10 Oct 2016 16:25:37 +0000 (18:25 +0200)]
nit: break a long line in different ways, unobfuscate parameter grouping

Break a rather long line for a Python method call at a different
location, to better reflect the parameter groups which organize for the
method to get called, and those which pass parameters to that called
method. This commit also splits the actual action and its check for
successful execution into separate C language statements.

18 months agoparallel: flush accumulated data when input data is exhausted
Gerhard Sittig [Mon, 3 Oct 2022 16:29:46 +0000 (18:29 +0200)]
parallel: flush accumulated data when input data is exhausted

The "parallel" decoder buffers the currently seen data pattern, and
defers annotation emission until the end position is known. Which is
why the last data pattern would not show up in the decoder's output.
See bug #292 and its duplicates for examples and concerns.

Catch the EOFError exception, and flush previously accumulated data.

It is yet to get determined whether a warning annotation is due. Most
probably not for "parallel" which merely visualizes data line states.
But other decoders which have the concept of frames shall NOT follow
this "parallel" decoder's naive approach, and claim that a frame had
completed although its end condition was never seen. Add a developer
TODO comment to raise awareness.

18 months agotype_decoder: update .samplenum before ending .wait() with EOFError
Gerhard Sittig [Mon, 3 Oct 2022 16:23:34 +0000 (18:23 +0200)]
type_decoder: update .samplenum before ending .wait() with EOFError

When the protocol decoder's input data is exhausted, then the .wait()
method will raise the EOFError exception. Python decoders can catch this
exception and handle the condition. For proper annotation emission it is
essential that the self.samplenum value corresponds to the last position
in the input stream. Update it before returning from the .wait() call.

19 months agosrd: add support for SIGROKDECODE_PATH environment variable
Gerhard Sittig [Sun, 21 Aug 2022 11:54:58 +0000 (13:54 +0200)]
srd: add support for SIGROKDECODE_PATH environment variable

The optional SIGROKDECODE_DIR environment variable accepts a single
directory specification. The SIGROKDECODE_PATH variable accepts a list
of directories to search protocol decoders. The list separator is
platform dependent (colon or semicolon). Empty items are explicitly
ignored. Both variables get evaluated. Behaviour remains backwards
compatible, just gets extended for improved usability.

19 months agosrd: add TODO comment on the SIGROKDECODE_DIR env var's motivation
Gerhard Sittig [Sun, 21 Aug 2022 11:52:19 +0000 (13:52 +0200)]
srd: add TODO comment on the SIGROKDECODE_DIR env var's motivation

A comment in the srd.c implementation suggests that the environment
variable SIGROKDECODE_DIR would serve debugging purposes and would
override other incarnations of available decoders. I disagree with
either of these interpretations. Add a TODO comment, the phrase may
need an update or rework.

23 months agouart: don't re-calculate in-frame bit position, just count the bits
Gerhard Sittig [Fri, 22 Apr 2022 20:45:06 +0000 (22:45 +0200)]
uart: don't re-calculate in-frame bit position, just count the bits

The .get_wait_cond() routine kept re-calculating the current bit index
in the currently inspected UART frame. Just count the bits instead as
they are seen/taken. This eliminates redundant complex logic which had
hard to track down issues in past revisions. Increases robustness, and
improves maintainability.

23 months agouart: handle two stop bits configuration
Gerhard Sittig [Sat, 23 Apr 2022 17:20:42 +0000 (19:20 +0200)]
uart: handle two stop bits configuration

Sample and process multiple STOP bits as specified, add 2.0 to the list
of supported configurations. This implementation works as expected with
integer numbers of STOP bits (0, 1, 2). For half-bits the sample point
as well as the annotation position will be incorrect (as a result of an
internal implementation detail of the existing decoder which is not easy
to address).

This commit reduces the diff size, and remains backwards bug-compatible.
Fixing the bit boundaries in annotations including support for half-bits
is more involved, and remains for a later commit.

23 months agouart: handle zero stop bits configuration
Gerhard Sittig [Wed, 13 Apr 2022 19:10:00 +0000 (21:10 +0200)]
uart: handle zero stop bits configuration

Use common code to advance internal state during UART frame inspection.
This reduces redundancy, and improves robustness. Data bits collectors
need not worry about the optional presence of subsequent fields (parity,
stop bits, both can be absent).

Improve the separation of implementation details of the lower layer UART
frame decoding from upper layer protocol handling. Concentrate the post
processing of UART frames, BREAK and IDLE conditions in the source, and
keep the ss/es determination at the caller which detected the condition
by arbitrary means.

This unbreaks the decoder's operation when 0 stop bits are configured.
The implementation still assumes that the line goes idle between frames
even when zero stop bits are configured. Strictly speaking this decoder
now copes with traffic that uses "less than half a stop bit".

23 months agosbus_futaba: add decoder for SBUS hobby remote control by Futaba
Gerhard Sittig [Wed, 20 Apr 2022 05:58:28 +0000 (07:58 +0200)]
sbus_futaba: add decoder for SBUS hobby remote control by Futaba

This is the SBUS remote control by Futaba, the 25 bytes on top of UART.
Not the computer peripheral bus. Hence the suffix in the decoder name.

The implementation was tested with synthetic data. Example captures with
real world data have yet to become available. This implementation shows
the message framing, the proportional and digital channels' values, and
the flags. Several warnings for short and long and invalid messages are
implemented, as are user adjustable channel value range limits.

The boilerplate may need adjustment. All naming was made up by me based
on what information was available (vendor doc was missing).

2 years agolibsigrokdecode.h: declare Windows dllexport for SRD_API routines
Gerhard Sittig [Mon, 14 Feb 2022 19:35:05 +0000 (20:35 +0100)]
libsigrokdecode.h: declare Windows dllexport for SRD_API routines

Add the __declspec(dllexport) decoration to SRD_API routines on Windows
when building the library body (this is new). Stick with the default
visibility on all other platforms (as previously implemented).

This is similar to what Kyle Johnson submitted in PR 66, but phrased
differently. Avoid the non-portable indentation before the hash in
preprocessor instructions. Use positive logic for readability (put
the Windows branch next to the check for the Windows platform).

Reported-By: Kyle Johnson <redacted>
2 years agodecoder: rename iteration variables to improve readability
Gerhard Sittig [Sun, 1 Nov 2020 13:48:14 +0000 (14:48 +0100)]
decoder: rename iteration variables to improve readability

Use longer variable names for the iteration over channels, options,
annotation classes and rows, and binary classes when a decoder gets
loaded. This improves readability, especially in nested loops with
complex test conditions and diagnostics messages.

Although the Python variables were checked for their availability and
expected data type, and we should only see non-negative index values,
the iteration variable's data type remains unchanged in this commit
(sticks with signed size types).

2 years agodecoder: check annotation rows' references to annotation classes
Gerhard Sittig [Sun, 1 Nov 2020 11:33:47 +0000 (12:33 +0100)]
decoder: check annotation rows' references to annotation classes

Check the annotation class indices when iterating annotation rows.
Refuse to load decoders with inconsistent declarations, emit error
messages to raise developers' awareness of implementation bugs.

This fixes bug #1601.

2 years agodecoder: don't break error messages, factor out Python variable name
Gerhard Sittig [Sun, 1 Nov 2020 11:16:07 +0000 (12:16 +0100)]
decoder: don't break error messages, factor out Python variable name

Don't break long error messages in source code, so that developers can
grep for user reported strings during maintenance. This commit does not
change behaviour.

Concentrate repeated references to the 'annotation_rows' Python variable
name in a single spot at the top of the helper routine.

2 years agoir_irmp: sigrok PD, make use of IRMP decoder core locking
Gerhard Sittig [Sun, 26 Dec 2021 06:38:05 +0000 (08:38 +0200)]
ir_irmp: sigrok PD, make use of IRMP decoder core locking

Rephrase how the external IRMP library gets loaded, to provide better
diagnostics to users. All decoder instances are equal after the recent
introduction of locking support.

Move the "reset state" call for the IRMP decoder core to the .decode()
method's main loop, where the context manager holds the instance lock.
This allows "parallel" execution of multiple IRMP decoders in the same
sigrok application, assuming that the context manager scope will be
left at some point in time.

This fixes bug #1581 when applications communicate EOF to decoders.

Move some Python object members to local variables. They exclusively
are used within the .decode() method.

Update the copyright for the non-trivial changes.

2 years agoir_irmp: Python binding, support instance locking and context manager
Gerhard Sittig [Sun, 26 Dec 2021 07:31:02 +0000 (08:31 +0100)]
ir_irmp: Python binding, support instance locking and context manager

Extend the ctypes wrapper for the IRMP decoder core. Add routines for
the instance state creation and lock management. Implement metamethods
for Python context managers which lock the instance to protect the C
library's internal state from changing unexpectedly. Add my copyright
for the non-trivial changes.

This commit eliminates the limitation to a single IRMP decoder core for
the sigrok process to use. Multiple Python callers can synchronize their
library use, and see a consistent library state across the scope of the
context manager. It's essential though that callers leave the context
to not block other callers for extended periods of time.

2 years agoir_irmp: wrapper lib, add locking and Python threading support
Gerhard Sittig [Sun, 26 Dec 2021 07:23:27 +0000 (08:23 +0100)]
ir_irmp: wrapper lib, add locking and Python threading support

The IRMP core library is not thread safe (known limitation, heritage of
the AVR firmware origin). Add a mutex so that calling applications can
lock IR decoder core instances. Allow Python threading while waiting for
the locks, we can safely assume that this IRMP wrapper is used in the
sigrok context which does require Python for decoders. Add my copyright
for the non-trivial changes.

This implementation uses glib for locking to improve portability, which
already is a dependency of the libsigrokdecode component. This version
uses belt and suspenders by implementing a constructor as well as adding
auto init calls to each of the public API code paths. The client ID is
not an essential requirement, but useful during application maintenance.

2 years agoir_irmp: wrapper lib, silence warnings in "Windows or Unix" condition
Gerhard Sittig [Sun, 26 Dec 2021 07:21:02 +0000 (08:21 +0100)]
ir_irmp: wrapper lib, silence warnings in "Windows or Unix" condition

Platform detection in the external IRMP library works best when either
the WIN32 or the unix identifiers are provided, which the sigrokdecode
build environment derives from other identifiers which are more reliably
available.

It turns out that other external dependencies like glib or Python may
provide some of these identifiers, too. Which results in the compiler
warning about symbols' redefinition. Only define derived identifiers
when they haven't been provided yet.

This amends commit ab88bae1c7b9.

2 years agosession: introduce the public "send EOF" API routine
Gerhard Sittig [Sun, 26 Dec 2021 06:42:27 +0000 (07:42 +0100)]
session: introduce the public "send EOF" API routine

Introduce the public srd_session_send_eof() routine which is backed by
the internal srd_inst_send_eof() helper. Applications can tell decoders
when the input stream of sample data is exhausted, so that decoders can
optionally "flush" their previously accumulated information when
desired. Previous implementations just kept decoders in blocking .wait()
calls and somehow terminated them at arbitrary times afterwards.

When EOF is sent to the decoder session, then calls to the .wait()
method which typically are done from .decode() or its descendents will
end with an EOFError Python exception. Termination of .decode() with the
EOFError exception is non-fatal for backwards compatibility and to keep
the convenience for current decoder implementations. Decoders can either
catch the exception, or use context managers, or do nothing.

This API extension is motivated by research for bug #1581 and provides
the infrastructure to address bug #292. Decoders need to remain careful,
and should not claim that protocol activities would have completed when
their end condition was not even seen in the capture. Marking incomplete
activities with warnings is the most appropriate reaction.

2 years agotype_decoder: eliminate explicit string length spec for literals
Gerhard Sittig [Sat, 25 Dec 2021 18:53:11 +0000 (19:53 +0100)]
type_decoder: eliminate explicit string length spec for literals

Rephrase the 'names[]' array declaration in output_type_name() to avoid
the necessity of guessing what the maximum length of the literals might
be during future maintenance. Developers need not care when the compiler
can handle this detail.

2 years agotype_decoder: use ALL_ZERO for sentinels in method/member tables
Gerhard Sittig [Sat, 25 Dec 2021 18:52:30 +0000 (19:52 +0100)]
type_decoder: use ALL_ZERO for sentinels in method/member tables

Avoid the full listing of all-zero struct members in sentinel items of
object methods and class properties tables. Use the ALL_ZERO phrase
instead which better reflects what's intended, and reliably silences
warnings should structs' lengths differ across Python versions.

2 years agotype_decoder: update and extend Decoder base class doc strings
Gerhard Sittig [Sat, 25 Dec 2021 18:48:11 +0000 (19:48 +0100)]
type_decoder: update and extend Decoder base class doc strings

Some doc strings have become outdated, update them. Some doc strings
were terse, extend them. Ideally protocol decoder authors would be able
to use the builtin documentation to answer questions on data types and
arguments order. This implementation isn't there yet, needs more work.

2 years agotype_decoder: move Python doc strings to method implementations
Gerhard Sittig [Sat, 25 Dec 2021 18:43:48 +0000 (19:43 +0100)]
type_decoder: move Python doc strings to method implementations

Move Python doc strings to the location where methods and classes get
implemented. This improves awareness during maintenance, and allows for
longer text phrases without obfuscating the registration code path.

This commit does not alter the content of existing doc strings, only
moves their location. And keeps related items together when long decls
span multiple text lines (function name and arguments list, args and
kw args), to improve/keep readability.

2 years agointernal: introduce ALL_ZERO declaration, modelled after libsigrok
Gerhard Sittig [Sat, 25 Dec 2021 18:50:43 +0000 (19:50 +0100)]
internal: introduce ALL_ZERO declaration, modelled after libsigrok

Declare ALL_ZERO in the common libsigrokdecode-internal.h header file.
The implementation and the comment on its motivation were taken from the
libsigrok implementation, slightly rephrased for improved readability.

2 years agoconfigure.ac: Use python3-embed.pc as a fallback
Evangelos Foutras [Thu, 3 Dec 2020 17:17:00 +0000 (19:17 +0200)]
configure.ac: Use python3-embed.pc as a fallback

This provides some future-proofing against newer Python versions.

2 years agoconfigure: Add python 3.10 support
Soeren Apel [Mon, 20 Dec 2021 18:36:39 +0000 (19:36 +0100)]
configure: Add python 3.10 support

2 years agoparallel: Add binary output
Soeren Apel [Fri, 17 Dec 2021 21:50:00 +0000 (22:50 +0100)]
parallel: Add binary output

2 years agorc_encode: Add support for EV1527, RT1527, FP1527 and HS1527
Soeren Apel [Thu, 29 Jul 2021 21:33:32 +0000 (23:33 +0200)]
rc_encode: Add support for EV1527, RT1527, FP1527 and HS1527

2 years agoieee488: add support for parallel poll (PP)
Gerhard Sittig [Sat, 20 Mar 2021 14:43:13 +0000 (15:43 +0100)]
ieee488: add support for parallel poll (PP)

The concurrent assertion of ATN and EOI is a PP (parallel poll) query.
The host asserts the control signals, and configured devices may assert
the DIO lines in response.

Because DAV is not involved, and because the input capture may not have
DIO at the start of the PP phase, and may neither have DIO any more at
its end, the check for parallel poll is more complex. Unconditionally
inspecting each sample of the capture is inefficient. Keep manipulating
the main loop's wait conditions instead, to stick with edge navigation
as long as possible, and only switch to inspection of individual samples
when strictly needed.

It's also important to gracefully handle low oversampling. Existing test
cases suffered from PP glitches when ATN asserted in the same location
where EOI deasserted. Be extra conservative about the presence of the
PP phase, expect at least two samples (a difference between its start
and end position) before emitting the annotation.

2 years agoieee488: shorten an option description for consistency across dialogs
Gerhard Sittig [Thu, 18 Mar 2021 19:05:02 +0000 (20:05 +0100)]
ieee488: shorten an option description for consistency across dialogs

The description text of the Commodore peripherals option spanned a
rather wide space. Trim the text for consistency with other options.

2 years agoieee488: support optional parity for ATN commands (for HP gear)
Gerhard Sittig [Thu, 18 Mar 2021 18:14:54 +0000 (19:14 +0100)]
ieee488: support optional parity for ATN commands (for HP gear)

HP gear is said to sometimes send commands (ATN asserted) with a parity.
Introduce an option to check and strip the MSB before interpretation.

Reported-By: Anders Gustafsson <redacted>
2 years agodoc: update IRC reference to Libera.Chat
Gerhard Sittig [Wed, 16 Jun 2021 18:52:10 +0000 (20:52 +0200)]
doc: update IRC reference to Libera.Chat

3 years agodecoder: increment Python object reference for .has_channel() result
Gerhard Sittig [Sun, 7 Mar 2021 06:03:18 +0000 (07:03 +0100)]
decoder: increment Python object reference for .has_channel() result

This fixes bug #1671.

Reported-By: Ivan Wick
3 years agoUse uint8_t instead of unsigned char for raw byte data
Soeren Apel [Fri, 26 Jun 2020 18:18:35 +0000 (20:18 +0200)]
Use uint8_t instead of unsigned char for raw byte data

3 years agoImplement basic flushing
Soeren Apel [Sun, 21 Jun 2020 10:10:59 +0000 (12:10 +0200)]
Implement basic flushing

3 years agoRename logic_class to logic_group and output as group-wise RLE
Soeren Apel [Fri, 26 Jun 2020 18:16:15 +0000 (20:16 +0200)]
Rename logic_class to logic_group and output as group-wise RLE

3 years agopca9571/tca6408a: Rework logic output
Soeren Apel [Thu, 26 Mar 2020 15:02:36 +0000 (16:02 +0100)]
pca9571/tca6408a: Rework logic output

For now, libsigrokdecode clients expect to receive a 1:1 number of
input samples to logic output samples, along with a logic output
samplerate equal to the PD's input sample rate

3 years agoRemove samplerate from srd_decoder_logic_output_channel
Soeren Apel [Sun, 1 Mar 2020 15:50:46 +0000 (16:50 +0100)]
Remove samplerate from srd_decoder_logic_output_channel

This means that the samplerate for logic output channels is
implicitly determined by the input channel samplerate.

The motivation for this is that hard-coding a samplerate isn't
possible - but at the same time, it's also not possible to
determine the samplerate at the time the logic output channels
are initialized, as the samplerate can be set at runtime.

From my point of view, we would need one of two mechanisms to
make this work:

1) Allow creation of logic outputs at runtime via some
registration callback
or
2) Allow changing a logic output's samplerate after it has been
created, again requiring some kind of callback

To me, both currently are overkill because making the assumption
that samplerate_in = samplerate_out not only makes this problem
go away as it can easily be handled on the client side where
samplerate_in is already known, it also makes handling of the
logic data in the PDs easier.

3 years agopca9571: Add initial OUTPUT_LOGIC support.
Uwe Hermann [Fri, 5 Jul 2019 06:12:23 +0000 (08:12 +0200)]
pca9571: Add initial OUTPUT_LOGIC support.

3 years agotca6408a: Add initial OUTPUT_LOGIC support.
Uwe Hermann [Wed, 26 Jun 2019 19:34:37 +0000 (21:34 +0200)]
tca6408a: Add initial OUTPUT_LOGIC support.

3 years agoAdd initial OUTPUT_LOGIC support.
Uwe Hermann [Wed, 26 Jun 2019 19:25:37 +0000 (21:25 +0200)]
Add initial OUTPUT_LOGIC support.

Protocol decoders can now declare an arbitrary number of logic output
channels with a fixed assumed samplerate each.

3 years agoseven_segment: cosmetics in decode(), reduce redundancy
Gerhard Sittig [Wed, 13 Jan 2021 19:12:07 +0000 (20:12 +0100)]
seven_segment: cosmetics in decode(), reduce redundancy

"Un-clutter" the decode() routine. Group related instructions to improve
readability. Drop redundant statements where common code can handle all
cases. Also fixes an unconditional access to the optional decimal point
input signal (which had caused a runtime error, and ceased decoding).

3 years agoseven_segment: document segment layout for awareness during maintenance
Gerhard Sittig [Wed, 13 Jan 2021 18:51:52 +0000 (19:51 +0100)]
seven_segment: document segment layout for awareness during maintenance

Add a comment to the table which maps LED segment combinations to their
textual presentation. Mention the table's sort order for awareness, and
provide column captions as well as a segment layout illustration to
simplify maintenance.

The LED segment layout comment was
Submitted-by: Ben Gardiner <redacted>
3 years agoseven_segment: expand to a full alphabet
Ben Gardiner [Sun, 22 Nov 2020 20:43:01 +0000 (20:43 +0000)]
seven_segment: expand to a full alphabet

Expand the list of characters that will be recognized by the seven
segment decoder to include many display character 'encodings.'
Including some punctuation characters and tricky letters like W and V.

Signed-off-by: Ben Gardiner <redacted>
[ gsi: sort by ASCII codes (keep ignoring letter case) ]

3 years agoseven_segment: add option to display unknown characters
Ben Gardiner [Sun, 22 Nov 2020 20:40:44 +0000 (20:40 +0000)]
seven_segment: add option to display unknown characters

option show_unknown=yes will display unknown 7-segment characters as
an octothorpe ('#').

Signed-off-by: Ben Gardiner <redacted>
3 years agoparallel: increase number of data lines to 16
Gerhard Sittig [Sat, 7 Nov 2020 14:44:37 +0000 (15:44 +0100)]
parallel: increase number of data lines to 16

The 'parallel' decoder supported 32 channels when it was introduced.
Commit a3b4f1684a8f lowered the channel count to 8 which is quite a
small number. Increase the number of supported channels to 16 again.
This should result in increased usability while keeping an acceptable
UI dialog size for the decoder properties.

3 years agoparallel: update builtin documentation
Gerhard Sittig [Sat, 7 Nov 2020 15:07:10 +0000 (16:07 +0100)]
parallel: update builtin documentation

Update the decoder's doc string to catch up with recent extensions.
Rephrase how clock and data lines interact. Sparse assignment of data
lines is supported (has been for a while). Discuss the optional reset
signal and its enable/select use.

3 years agoparallel: adjust Python output to match its documentation
Gerhard Sittig [Sat, 7 Nov 2020 12:49:06 +0000 (13:49 +0100)]
parallel: adjust Python output to match its documentation

The parallel decoder documented the layout of the Python output but used
to emit something different (mere data values). Add the bit width of
data items and the bus cycle count for demultiplexed words, to match the
documented layout.

No harm was done, there are no in-tree decoders which stack on top of
the parallel decoder.

3 years agoparallel: rephrase word accumulation after reset introduction
Gerhard Sittig [Sat, 7 Nov 2020 12:49:06 +0000 (13:49 +0100)]
parallel: rephrase word accumulation after reset introduction

Straighten the accumulation of words from bit chunks that are spread
across several bus cycles (multiplexed transmission). Simplify the PD's
instance variables, keep more state in local vars and explicitly pass
related information to API calls. This also unobfuscates the emission
of annotations and simplifies future maintenance.

Split the accumulation of word data and the emission of its annotation
such that reset related activity can flush accumulated data. Introduce a
warning when word data gets emitted which does not match the configured
word width (early de-assertion of select/enable, or unexpected reset).
Presenting this data and amending it with a warning is considered more
desirable than not seeing the data at all. This does not affect previous
use cases since support for the reset signal was only introduced lately.

Also emit annotations in a more logical order. It's unexpected to see
the resulting word before its last item is seen. Graphical presentation
may not care but automated processing of the decoder output will. This
is the previous order of annotation emission which is surprising and got
fixed in this commit:

  3768240-4118229 parallel: item: "3"
  3768240-4468218 parallel: word: "33"
  4118229-4468218 parallel: item: "3"
  4468218-4818202 parallel: item: "3"
  4468218-5268189 parallel: word: "32"
  4818202-5268189 parallel: item: "2"
  5268189-5368185 parallel: item: "2"
  5268189-5568180 parallel: word: "28"
  5368185-5568180 parallel: item: "8"
  5568180-5668176 parallel: item: "0"
  5568180-5868171 parallel: word: "08"
  5668176-5868171 parallel: item: "8"
  5868171-5968166 parallel: item: "0"
  5868171-6168162 parallel: word: "01"
  5968166-6168162 parallel: item: "1"
  6168162-6268157 parallel: item: "0"
  6168162-6468152 parallel: word: "0c"
  6268157-6468152 parallel: item: "c"

This adjusted emission order won't pass the current test implementation,
but manual inspection of the output reveals that all the expected data
is present and matches previously extracted information:

  parallel/hd44780_word_demux/annotation ..................................... Output mismatch
  Testcase: parallel/hd44780_word_demux/annotation
  Test output mismatch:
  + 4118229-4468218 parallel: item: "3"
  - 4118229-4468218 parallel: item: "3"
  + 4818202-5268189 parallel: item: "2"
  - 4818202-5268189 parallel: item: "2"
  + 5368185-5568180 parallel: item: "8"
  - 5368185-5568180 parallel: item: "8"
  + 5668176-5868171 parallel: item: "8"
  - 5668176-5868171 parallel: item: "8"
  + 5968166-6168162 parallel: item: "1"
  - 5968166-6168162 parallel: item: "1"
  + 6268157-6468152 parallel: item: "c"
  - 6268157-6468152 parallel: item: "c"

3 years agoparallel: add support for optional reset/enable/select signal
Gerhard Sittig [Sat, 7 Nov 2020 13:38:05 +0000 (14:38 +0100)]
parallel: add support for optional reset/enable/select signal

Add an optional 'reset' signal of user configurable polarity. When the
signal is asserted, the data lines are not interpreted. Assertion will
flush previously accumulated data bits and words. Deassertion can help
synchronize to input streams when the capture started in the middle of
a word. Despite the "reset" name this signal can also be thought of as
"enable" or "select", and increases the versatility and usefulness of
the parallel decoder beyond strictly parallel memory busses.

Construct the list of .wait() conditions and track the positions of
individual terms in that list. This is necessary because "always false"
conditions are not available, thus pin/channel indices and .matched[]
indices don't correspond for sparse input signal assignments.

Accept when previously gathered information became void again, and
re-use existing initialization code for reset related activity.

3 years agoparallel: add option to sample data on either clock edge
Gerhard Sittig [Sat, 7 Nov 2020 13:47:21 +0000 (14:47 +0100)]
parallel: add option to sample data on either clock edge

Add 'either' as another choice in addition to rising and falling clock
edge. This is useful since parallel busses exist which communicate at
double data rate (DDR).

Unobfuscate the mapping between displayed option text and .wait()
condition codes while we are here.

3 years agoparallel: rephrase handling of data lines, symbolic upper bound
Gerhard Sittig [Sat, 7 Nov 2020 12:46:56 +0000 (13:46 +0100)]
parallel: rephrase handling of data lines, symbolic upper bound

Strictly speaking this decoder considers all input signals as optional.
The previous version accepted clock alone. Though reading values from
zero data bits is of limited. Tighten the check for connected inputs.

Inline the declaration of all channels in the decoder boiler plate, the
helper routine was only used in a single spot. Change the order of the
data lines stripe details and the .wait() conditions, improve locality
of assignment and use of related variables.

Don't assume that "all channels but clock" are data lines. Use a
symbolic upper bound for the data lines partition, to prepare the
introduction of a reset/enable signal.

3 years agoparallel: symbolic names for pins and annotation classes
Gerhard Sittig [Sat, 7 Nov 2020 12:44:32 +0000 (13:44 +0100)]
parallel: symbolic names for pins and annotation classes

Concentrate tunables at the top of the source code. Eliminate magic
numbers by replacing them with symbolic identifiers.

3 years agoirmp: Fix a build issue with xtensa cross toolchains.
Uwe Hermann [Mon, 31 Aug 2020 19:53:18 +0000 (21:53 +0200)]
irmp: Fix a build issue with xtensa cross toolchains.

3 years agoir_nec: fix typo in STOP bit width
Gerhard Sittig [Sat, 1 Aug 2020 07:35:40 +0000 (09:35 +0200)]
ir_nec: fix typo in STOP bit width

The 0.652ms STOP bit width must have been a typo (though consistent in
the previous implementation), it's not half of the 1.125ms ZERO symbol.

Notice that this is an incompatible change to the decoder implementation.
It affects the annotations for STOP bits and overall REMOTE button codes.

3 years agoir_nec: sort and comment timing specs, drop tolerance option
Gerhard Sittig [Sat, 1 Aug 2020 07:29:39 +0000 (09:29 +0200)]
ir_nec: sort and comment timing specs, drop tolerance option

Extend comments on the IR NEC timing details. Sort the symbols by their
width to reflect their relation (ONE to ZERO to STOP is each half of
their predecessor's width).

Increase the open coded tolerance percentage, and remove the option for
the value. Make sure leader and repeat codes still can be told from each
other.

3 years agoir_nec: concentrate timing at the top of the source file
Gerhard Sittig [Sat, 1 Aug 2020 07:17:37 +0000 (09:17 +0200)]
ir_nec: concentrate timing at the top of the source file

Move IR NEC protocol timing details to the top of the source file, for
raised awareness and easier adjustment. Specs are "unit-less" (only have
comments), but are scaled for improved readability. Values are copies of
the previous implementation.

3 years agoir_nec: Add option for automatic polarity detection
BenediktO [Mon, 27 Jul 2020 06:32:30 +0000 (08:32 +0200)]
ir_nec: Add option for automatic polarity detection

Provide an option to have the decoder automatically detect the IR signal's
polarity. Stick with active-low by default for backwards compatibility,
because this auto-detect implementation assumes that the capture starts
with an idle phase.

[ gsi: rephrased message and implementation, auto-detect off by default ]

3 years agoir_nec: Make the tolerance configurable
BenediktO [Mon, 27 Jul 2020 06:32:52 +0000 (08:32 +0200)]
ir_nec: Make the tolerance configurable

Provide an option to adjust the IR NEC decoder's tolerance. Which makes
signals accessible that are generated by cheap remotes which would not
decode at all with the previous implementation and its fixed limit.

[ gsi: rephrased commit message and implementation ]