]> sigrok.org Git - libsigrokdecode.git/log
libsigrokdecode.git
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 ]

3 years agoir_nec: Annotate IR frame already at the end of the STOP bit
BenediktO [Mon, 27 Jul 2020 06:31:31 +0000 (08:31 +0200)]
ir_nec: Annotate IR frame already at the end of the STOP bit

Emit annotations for the current IR frame as soon as possible, at the
very end of the STOP bit. Don't defer annotation emission until the
start of the next frame is seen. This unbreaks captures where the last
IR frame would not decode before.

[ gsi: rephrased commit message, updated comment in the implementation ]

3 years agoir_nec: Add Joy-it SBC-IRC01 remote
BenediktO [Mon, 27 Jul 2020 06:30:24 +0000 (08:30 +0200)]
ir_nec: Add Joy-it SBC-IRC01 remote

The Joy-it SBC-IRC01 remote control appears as address 0x00.

3 years agosle44xx: support memory read "to end of capacity"
Gerhard Sittig [Sun, 30 Aug 2020 05:20:33 +0000 (07:20 +0200)]
sle44xx: support memory read "to end of capacity"

Assume a maximum memory capacity, currently open coded, could become a
user servicable option when needed. Automatically flush the accumulated
outgoing data when a memory read reaches address 256.

Drop the unconditional START condition check now that it became obsolete.

3 years agosle44xx: optionally use samplerate to show processing durations
Gerhard Sittig [Tue, 28 Jul 2020 15:37:11 +0000 (17:37 +0200)]
sle44xx: optionally use samplerate to show processing durations

The protocol is clocked, so strictly does not depend on the samplerate.
When the samplerate is available, the duration of internal processing
(memory erase and write) can get annotated. It's an optional feature.

The datasheet suggests that write and erase time are in the range of a
few milliseconds. Normalize to ms units and provide 10us resolution.

3 years agosle44xx: extend decoder's feature set, outgoing data, processing
Gerhard Sittig [Sat, 29 Aug 2020 11:00:04 +0000 (13:00 +0200)]
sle44xx: extend decoder's feature set, outgoing data, processing

Rephrase how the decoder's progress during data interpretation gets
tracked. Extend the set of .wait() conditions in the main loop, and
determine START/STOP conditions and BIT validity there already, which
reduces redundancy with called handlers.

Increase the decoder's coverage of the memory card's feature set and
constraints. Handle the optional CLK during RST, to tell interrupted
memory access from card reset. Interpret known command codes, to present
their meaning and arguments to users, and to tell "outgoing data" (the
card's memory content) from "internal processing" (providing clock until
the card signals completion of a write access). Get initial statistics
on internal processing (clock count, and terminal I/O level, no duration
in units of wall clock time yet).

Unfortunately there is no reliable condition to detect the end of a
memory read when it executes to the end of the memory card's capacity.
That's why START detection is more greedy than specified, to reliably
re-sync to subsequent commands and their byte sequences.

Arrange for an improved set of annotation rows with symbols (bit level),
fields (data bytes), and operations details (summary of memory access
including protection).

Rename the binary output. It carries "any bytes" which were seen, the
command bytes as well as response data bytes.

3 years agosle44xx: rephrase ss/es passing for annotation emission
Gerhard Sittig [Sat, 29 Aug 2020 10:31:31 +0000 (12:31 +0200)]
sle44xx: rephrase ss/es passing for annotation emission

Coupling the logic which interprets input signals at different levels
and the helpers which emit annotations by means of "global" variables
(public members of the decoder object) is unfortunate. It complicates
the logic, adds unnecessary dependencies, and makes maintenance rather
tedious and error prone.

Pass ss/es times to put() routines the same way as annotation classes
and annotation texts are passed. This simplifies the logic where bits
and bytes levels and additional rows are handled. The data values and
their spans all become local information that gets determined in the
same context. Which dramatically simplifies review.

3 years agosle44xx: minor developer comment and style nits
Gerhard Sittig [Tue, 18 Aug 2020 19:05:17 +0000 (21:05 +0200)]
sle44xx: minor developer comment and style nits

These are just nits, behaviour remains. The comment may be incorrect
how command and data modes are detected. Add a developer comment for
later revisit. Drop unneeded parentheses in a ternary operation, and
move an ATR related comment around.

3 years agosle44xx: don't assume RESET at the start of the capture
Gerhard Sittig [Tue, 28 Jul 2020 15:38:45 +0000 (17:38 +0200)]
sle44xx: don't assume RESET at the start of the capture

The decoder cannot know the state of the input signal before the start
of the capture. Assuming the RESET state results in incorrect output for
data bits which we don't know the context of. Start from unknown state
instead until a reliable condition is seen to synchronize to.

3 years agosle44xx: rework data bits accumulation, and byte presentation
Gerhard Sittig [Mon, 27 Jul 2020 19:58:55 +0000 (21:58 +0200)]
sle44xx: rework data bits accumulation, and byte presentation

The 'databyte' is strictly local to the routine when 8 bits were seen.
The 'bitcount' is redundant and becomes obsolete when bits[] is a Python
list. The comment and the code disagreed, the wire is said to communicate
bits in LSB first order, the implemenation kept accumulating bits in the
reverse order (the annotation part, not the data byte math). Prefer the
common helper to convert bits to bytes.

There is uncertainty about the bit width "estimation" logic. The main
loop's .wait() conditions suggest that data bit values are valid for the
period of high CLK, which provides an easier and more robust condition
for annotation boundaries. Add a comment for now. The order of bit and
byte values' annotation emission is unfortunate, too.

3 years agosle44xx: rephrase annotation text construction
Gerhard Sittig [Mon, 27 Jul 2020 19:15:20 +0000 (21:15 +0200)]
sle44xx: rephrase annotation text construction

Concentrate all text variants for zoom levels in a single spot. Remove
duplicates, and on the other hand add more verbose phrases to support
users which are not intimately familiar with the protocol. Prefer the
Python strings .format() method over the % operator for its versatility
and readability.

3 years agosle44xx: use symbolic identifiers for annotation classes
Gerhard Sittig [Mon, 27 Jul 2020 18:20:52 +0000 (20:20 +0200)]
sle44xx: use symbolic identifiers for annotation classes

Eliminate magic numbers for annotation classes, prefer symbolic names
instead to improve readability. Put the annotation classes in an order
which matches the annotation rows' order. Reduce indentation in the
'proto' table while we are here (yet keep the vertical alignment).

3 years agosle44xx: use symbolic identifiers for pins and signal transitions
Gerhard Sittig [Mon, 27 Jul 2020 18:03:47 +0000 (20:03 +0200)]
sle44xx: use symbolic identifiers for pins and signal transitions

Eliminate magic numbers for input pins and signal transition conditions.
Which dramatically improves readability and simplifies review.

3 years agosle44xx: remove incomplete Python output for now
Gerhard Sittig [Mon, 27 Jul 2020 15:57:04 +0000 (17:57 +0200)]
sle44xx: remove incomplete Python output for now

The current implementation exclusively communicated the 'RESET'
condition but nothing else. Remove the Python output from the decoder,
it's easy to re-introduce when a complete implementation materializes.
There also is no known recipient of SLE44xx Python output right now
which would expect to see even the currently implemented subset.

3 years agosle44xx: extend decoder doc string, add "memory cards" hint
Gerhard Sittig [Mon, 27 Jul 2020 15:48:40 +0000 (17:48 +0200)]
sle44xx: extend decoder doc string, add "memory cards" hint

Add a stronger hint to "memory cards", users might expect to see this
detail in the decoder's description. Rephrase how the reset line will
terminate pending memory reads.

3 years agosle44xx: fixup boilerplate, add missing required fields
Gerhard Sittig [Sat, 29 Aug 2020 08:05:24 +0000 (10:05 +0200)]
sle44xx: fixup boilerplate, add missing required fields

The decoder was created in an older setup and would not load in recent
applications. Add missing boilerplate which is mandatory. Rename 'data'
since annotation classes and rows must not have ambiguous names, and
there is no singular form of 'data' -- use 'fields' instead. This also
fixes a missing line termination at the end of the text file.

3 years agosle44xx: introduce decoder for Siemens memory cards
Federico Cerutti [Sat, 4 Jan 2020 10:48:35 +0000 (11:48 +0100)]
sle44xx: introduce decoder for Siemens memory cards

Introduce an initial implementation of the SLE44xx protocol decoder for
Siemens/Infineon SLE 4418/28/32/42 memory cards. ATR (Answer To Reset),
command and data bytes get displayed, and RESET/abort events are marked.
Extracted data bytes are made available as binary output.

3 years agoavr_isp: Extend decoder, add locks, eeprom, program memory commands.
Helge Kruse [Sun, 2 Aug 2020 16:26:55 +0000 (18:26 +0200)]
avr_isp: Extend decoder, add locks, eeprom, program memory commands.

[ gsi: list all classes, break long lines, EEPROM address calculation ]

3 years agoavr_isp: move "unknown command" to warning, drop empty 'bits' row
Gerhard Sittig [Sun, 2 Aug 2020 18:14:13 +0000 (20:14 +0200)]
avr_isp: move "unknown command" to warning, drop empty 'bits' row

Use the warnings annotation class for the "Unknown command" message, the
PE class (programming enabled) is unexpected and most probably a typo.

Drop the empty 'bits' annotation row which has been unused since commit
3b0013416fcfb.

3 years agoavr_isp: Use symbolic names for annotation classes.
Helge Kruse [Sun, 2 Aug 2020 16:24:55 +0000 (18:24 +0200)]
avr_isp: Use symbolic names for annotation classes.

[ gsi: explicit list of all classes in row declaration ]

3 years agosdq: prefer Python's .format() method for string formatting
Gerhard Sittig [Wed, 12 Aug 2020 18:08:35 +0000 (20:08 +0200)]
sdq: prefer Python's .format() method for string formatting

Prefer the .format() method over the % operator. Also vertically align
the non-trivial text alternatives for different zoom levels to simplify
comparison and adjustment during maintenance.

3 years agosdq: use symbolic names for pins and annotation classes
Gerhard Sittig [Wed, 12 Aug 2020 18:03:06 +0000 (20:03 +0200)]
sdq: use symbolic names for pins and annotation classes

Eliminate magic numbers which are too hard to read and too easy to get
wrong during maintenance. Prefer symbolic identifiers instead for pins
and annotation classes.

3 years agosdq: provide more information in the decoder's boilerplate
Gerhard Sittig [Wed, 12 Aug 2020 16:48:27 +0000 (18:48 +0200)]
sdq: provide more information in the decoder's boilerplate

Extend the __init__.py module's doc string. Provide more details to the
user beyond the vendor's name, to increase the decoder's usability.

3 years agosdq: simplify decode routine, no state machine required
Gerhard Sittig [Wed, 12 Aug 2020 16:47:37 +0000 (18:47 +0200)]
sdq: simplify decode routine, no state machine required

Move the initial synchronization to the input data out of the main loop,
and handle the BREAK symbol when it was seen. Turns out that no state
machine is required to decode the SDQ protocol.

[ best viewed as a whitespace ignoring diff ]

3 years agosdq: only use samplerate and options values after validity check
Gerhard Sittig [Wed, 12 Aug 2020 16:47:01 +0000 (18:47 +0200)]
sdq: only use samplerate and options values after validity check

Move the calculation which involves the samplerate as well as user
provided options out of the meta packet reception and to the top of the
decode() method. Especially only use the samplerate after it was tested
for availability.

3 years agosdq: use common bits to number conversion
Gerhard Sittig [Wed, 12 Aug 2020 16:46:28 +0000 (18:46 +0200)]
sdq: use common bits to number conversion

3 years agosdq: Add the SDQ protocol decoder
Philip Ã…kesson [Sun, 9 Aug 2020 14:44:46 +0000 (16:44 +0200)]
sdq: Add the SDQ protocol decoder

[ gsi: minor whitespace adjustment ]

3 years agost7735: Fix handling of unknown commands
gregor-anich-uibk [Sat, 8 Aug 2020 11:57:26 +0000 (13:57 +0200)]
st7735: Fix handling of unknown commands

Command lookup for unknown codes resulted in an exception instead of the
'else' clause which was ineffective. Make the check non-fatal.

[ gsi: rephrased commit message ]

3 years agoconfigure.ac: Add support for Python 3.9.
Dan Horák [Tue, 4 Aug 2020 07:19:44 +0000 (09:19 +0200)]
configure.ac: Add support for Python 3.9.

3 years agolpc: improve performance, use proper .wait() condition
BenediktO [Wed, 25 Mar 2020 13:05:13 +0000 (14:05 +0100)]
lpc: improve performance, use proper .wait() condition

Use a proper .wait() condition to have edges detected in common code,
and avoid the many transitions between C and Python. This dramatically
increases performance of the LPC protocol decoder.

[ gsi: rephrased and reflowed the commit message ]

3 years agost25r39xx_spi: Minor style and description changes
Soeren Apel [Sun, 19 Jul 2020 20:57:49 +0000 (22:57 +0200)]
st25r39xx_spi: Minor style and description changes

3 years agost25r39xx_spi: Add st25r39xx PD using spi
bvernoux [Tue, 14 Jul 2020 21:02:35 +0000 (23:02 +0200)]
st25r39xx_spi: Add st25r39xx PD using spi

This NFC interface chip is used in the HydraNFC Shield v2.

See also dumps used to validate it on https://github.com/sigrokproject/sigrok-dumps/pull/21

3 years agolfast/sipi: Fix typo
Soeren Apel [Thu, 30 Jul 2020 19:42:41 +0000 (21:42 +0200)]
lfast/sipi: Fix typo

3 years agosipi: Initial version of the SIPI protocol to form a Zipwire stack
Soeren Apel [Wed, 29 Jul 2020 21:45:45 +0000 (23:45 +0200)]
sipi: Initial version of the SIPI protocol to form a Zipwire stack

3 years agolfast: More bug fixes and enhancements
Soeren Apel [Wed, 29 Jul 2020 21:44:56 +0000 (23:44 +0200)]
lfast: More bug fixes and enhancements

3 years agolfast: Enhance LFAST PD
Soeren Apel [Tue, 28 Jul 2020 10:57:58 +0000 (12:57 +0200)]
lfast: Enhance LFAST PD

3 years agolfast: Initial version of the NXP LFAST / IFX HSCT PD
Soeren Apel [Mon, 27 Jul 2020 15:01:53 +0000 (17:01 +0200)]
lfast: Initial version of the NXP LFAST / IFX HSCT PD

3 years agoir_sirc: use common bitpack() variant with array access
Gerhard Sittig [Thu, 23 Jul 2020 15:27:17 +0000 (17:27 +0200)]
ir_sirc: use common bitpack() variant with array access

This eliminates array copies and indexed access to bit values in the
calling decoder. Prefer common helpers instead.

3 years agocan: use common MSB first variant of bitpack()
Gerhard Sittig [Thu, 23 Jul 2020 15:26:06 +0000 (17:26 +0200)]
can: use common MSB first variant of bitpack()

This eliminates array copies and bit order reversal in the calling
decoder. Prefer common helpers instead.

3 years agocommon: add LSB/MSB first bitpack variant with optional index
Gerhard Sittig [Thu, 23 Jul 2020 15:23:24 +0000 (17:23 +0200)]
common: add LSB/MSB first bitpack variant with optional index

The CAN decoder collects bits in MSB first order. The SIRC decoder keeps
lists of tuples with bits and their ss/es. Introduce common logic for
LSB and MSB first arguments, and optional array index access, to reduce
redundancy at callers'.

3 years agocan: avoid assignment to .id field during frame inspection
Gerhard Sittig [Wed, 22 Jul 2020 20:05:54 +0000 (22:05 +0200)]
can: avoid assignment to .id field during frame inspection

The CAN frame's ID field gets stored in an .id member, which is
unfortunate. Use .ident instead. The 'id' identifier is a Python
language word, though it's used for PD boilerplate as well. Assume
that the boilerplate is worth keeping, and harder to adjust (more
dependencies), so adjust this PD's implementation to resolve the
ambiguity.

3 years agocan: use common helper for bits to number conversion
Gerhard Sittig [Wed, 22 Jul 2020 20:02:23 +0000 (22:02 +0200)]
can: use common helper for bits to number conversion

Eliminate repeated local string manipulation for the purpose of
number conversion from bits input. Prefer the common helper instead
(is an MSB first variant desirable to simplify call sites more?).

3 years agocan: amend recently added Python output feature
Gerhard Sittig [Wed, 22 Jul 2020 19:56:17 +0000 (21:56 +0200)]
can: amend recently added Python output feature

Adjust nits in the previous commit which added Python output to the CAN
decoder. Rename the routine to .putpy() for consistency with other PDs.
Avoid the 'bytes' identifier as it ships with Python as a data type.
Rephrase the construction of the tuple for Python output, to become more
explicit and help reviewers. Partially "undo" the rtr rename, to reduce
diffs to the previous version (see diff HEAD~2 to see the essence). Fix
up a three space indentation issue (which was there before the addition
of Python output).

3 years agocan: enable Python output from decoder
Kari Hautio [Tue, 24 Mar 2020 06:56:01 +0000 (08:56 +0200)]
can: enable Python output from decoder

3 years agoir_nec: improve robustness, present more data on invalid input
Gerhard Sittig [Sun, 26 Jul 2020 06:45:32 +0000 (08:45 +0200)]
ir_nec: improve robustness, present more data on invalid input

Don't terminate IR frame inspection when successfully decoded fields
fail the validity check. Reset internal state on long periods of idle
level instead (beware of the late detection of the STOP condition).

Unconditionally annotate received fields, and optionally amend them with
a warning annotation. It's unexpected to not see the address field value
at all just because the number was not acceptable for the potentially
incorrect protocol selection.

Rename a variable in the decode() routine. The 'b' identifier suggested
a bit value, but it was used for the pulse width.

3 years agoir_nec: Add button texts for an unknown LED panel remote
Sebastian Rittau [Sat, 25 Jul 2020 17:18:59 +0000 (19:18 +0200)]
ir_nec: Add button texts for an unknown LED panel remote

The remote is unmarked and belongs to a 60x60cm LED panel. There is
a total of 8 buttons. It's probably some generic remote control.

Bought here: https://www.lumizil.de/led-deckenleuchte-panel-60x60cm

3 years agoir_nec: add support for extended NEC protocol (16bit address)
Gerhard Sittig [Sat, 25 Jul 2020 15:56:54 +0000 (17:56 +0200)]
ir_nec: add support for extended NEC protocol (16bit address)

Add support for the extended NEC protocol, where the address field spans
16 bits and the complement is not sent. Commands still span 8 bits and
are sent in normal and in inverted form. The user needs to select the
extended protocol (off by default for compatibility), the input data
does not allow automatic detection of the protocol variant. It's also
not appropriate to assume the extended format when the address field
happens to fail the validity check.

The unfortunate mix of data value checks and annotation emission in
combination with "global" state makes this implementation more redundant
than I would like. A later cleanup is desirable.

This resolves bug #1583.

3 years agoir_nec: use common helper for bit accumulation
Gerhard Sittig [Sat, 25 Jul 2020 15:55:26 +0000 (17:55 +0200)]
ir_nec: use common helper for bit accumulation

The input signal's polarity ('active' variable) is strictly local to the
decode() method. The 'count' becomes obsolete when 'data' is kept in a
Python list. Conversion of bit patterns to numbers is provided by common
helpers. Alpha-sort Python imports while we are here.

This commit also renames a few variables in the normal/inverted check
for valid input data. Which can help the introduction of support for the
extended protocol, by decoupling what gets checked and what gets shown.

3 years agoir_nec: rephrase button lookup and addr/cmd validity checks
Gerhard Sittig [Sat, 25 Jul 2020 15:53:27 +0000 (17:53 +0200)]
ir_nec: rephrase button lookup and addr/cmd validity checks

Eliminate redundancy in the check for database entries of button events.

Tighten the check for valid address and command bit patterns. The former
implementation did something unexpected, wanted the AND of the first and
second 8bit patterns to become zero. But the second 8bit item has not yet
become available when the test runs after the reception of the first 8bit
item. So the test happened to "pass" unexpectedly in intermediate steps,
and failed to catch invalid input data when all fields became available.

Unfortunately the check for valid data and the emission of annotations
was combined in the implementation. So it's essential to keep running
the "check" routine to get the annotations, and update internal ss/es
state. But only emit warnings when the check fails after all involved
data became available. Check for strict XOR as per the protocol spec.

3 years agoir_nec: only use the samplerate after receiving the value
Gerhard Sittig [Sat, 25 Jul 2020 15:51:07 +0000 (17:51 +0200)]
ir_nec: only use the samplerate after receiving the value

The metadata() method unconditionally referenced the samplerate even
though the value is only available conditionally. Move the references to
a location after the samplerate presence check.

3 years agoir_nec: rephrase annotation logic, symbolic names, format() call
Gerhard Sittig [Sat, 25 Jul 2020 15:48:07 +0000 (17:48 +0200)]
ir_nec: rephrase annotation logic, symbolic names, format() call

Eliminate magic numbers, use symbolic names for annotation classes and
pin numbers. Also vertically align text variants for zoom levels in the
more complex cases, to simplify maintenance. Prefer .format() calls to
improve readability in the more complex invocations.

3 years agoir_sirc: minor Python and other nits
Gerhard Sittig [Wed, 22 Jul 2020 18:41:33 +0000 (20:41 +0200)]
ir_sirc: minor Python and other nits

The .wait() wrapper always receives Python lists. There is only a single
IR pin (and its value isn't even used anywhere because appropriate edge
conditions get constructed). There is a delicate ss/es detail in the
.decode() routine concerning the IR frame's annotation's start. Don't
"continue" in the loop body's last statement, just "pass" and continue.

3 years agoir_sirc: symbolic names for IR pulse widths, more line trimming
Gerhard Sittig [Wed, 22 Jul 2020 18:16:15 +0000 (20:16 +0200)]
ir_sirc: symbolic names for IR pulse widths, more line trimming

Concentrate the magic numbers for IR pulse widths at the top of the
source file. Drop more unused variables. Rename others to shorten more
text lines.

3 years agoir_sirc: use symbolic identifiers for annotation classes
Gerhard Sittig [Wed, 22 Jul 2020 18:06:46 +0000 (20:06 +0200)]
ir_sirc: use symbolic identifiers for annotation classes

3 years agoir_sirc: reduce smarts to improve maintenance (.wait() API change)
Gerhard Sittig [Wed, 22 Jul 2020 17:55:07 +0000 (19:55 +0200)]
ir_sirc: reduce smarts to improve maintenance (.wait() API change)

Eliminate redundancy in time to snum conversions and vice versa. Don't
locally overload .wait() with unexpected semantics and neither change
its parameters nor return values. Give reviewers and maintainers a
chance to see what's happening when they inspect call sites. The
'signals' identifier is unusual for pin states, use the more common
'pins' instead for consistency with other decoders. Reflect when return
values are not used, so that readers need to juggle fewer details in
their head.

3 years agoir_sirc: use ss/es for consistency with other decoders
Gerhard Sittig [Wed, 22 Jul 2020 17:46:02 +0000 (19:46 +0200)]
ir_sirc: use ss/es for consistency with other decoders

3 years agoir_sirc: .put() nits, common helpers, whitespace
Gerhard Sittig [Wed, 22 Jul 2020 17:38:44 +0000 (19:38 +0200)]
ir_sirc: .put() nits, common helpers, whitespace

Wrap the .put() routine which eliminates redundancy and shortens a few
code lines. Vertically align text variants for different zoom levels.
Prefer common helpers for bit accumulation which eliminates a local copy
of that feature. Address minor whitespace nits, alpha-sort imports.

3 years agoir_sirc: fixup decoder boilerplate
Gerhard Sittig [Mon, 20 Jul 2020 20:21:30 +0000 (22:21 +0200)]
ir_sirc: fixup decoder boilerplate

The SIRC decoder was written to an older API, and failed to load in a
recent environment (tag missing, ambiguous annotation names). Unbreak
the decoder's boilerplate, and address other nits while we are here:
There is no Python output. Use the same declaration syntax as in other
decoders for improved maintenance (greppability). Call reset() from
__init__() to avoid surprises when a future version does have vars. Do
provide a doc string in the module initialization, to keep the URL for
the protocol description at hand.

3 years agoir_sirc: introduce decoder for Sony IR remote control protocol
Tom Flanagan [Sat, 4 Apr 2020 23:10:10 +0000 (16:10 -0700)]
ir_sirc: introduce decoder for Sony IR remote control protocol

3 years agospdif: Simplify samplerate check.
Uwe Hermann [Mon, 20 Jul 2020 21:17:39 +0000 (23:17 +0200)]
spdif: Simplify samplerate check.

3 years agospdif: Drop unneeded braces.
Uwe Hermann [Mon, 20 Jul 2020 21:16:46 +0000 (23:16 +0200)]
spdif: Drop unneeded braces.

3 years agospdif: Fix various issues.
Arno Morbach [Mon, 13 Jan 2020 13:30:16 +0000 (14:30 +0100)]
spdif: Fix various issues.

Bug #897 and my own experience caused me to improve the SPDIF decoder.
The following issues were addressed and resolved:

1. The Error: "srd: ValueError: Protocol decoder instance spdif-1:
     invalid literal for int() with base 2: '121111012112021111012120'"
   This error can happen if the sample rate is marginal. The correct function
   of the decoder depends on the position of the data stream. The pulse width
   calculation was wrong and the pulse width detection sometimes thought the
   same pulse classes to be different.
   The new decoder explicitly checks for short pulses and reports an error
   with a corresponding message.

2. Bitrates were calculated wrong: The shown results were not usable at all.
   The new decoder uses the first ten frames to calculate the bit rates and
   uses the correct measurement units.
   Possible issue: The bit rate calculation assumes an ongoing data stream.
   It uses the time between the first and 10th frame.
   They need to be sent without interruption. But this should be no problem
   because SPDIF is meant to be a continuous stream.

3. A missing samplerate, e.g. when used in sigrok-cli with binary input, lead
   to an error message on the original decoder.
   The new decoder just skips the output of the bitrate if the samplerate is
   missing. A missing samplerate no longer raises an error but only a message
   in the data output.

4. The user was not informed about the integral steps of the decoder.
   The new decoder shows the results of the synchronisation process at the
   beginning. This can help to understand the behaviour of the decoder.

This fixes bug #897.

3 years agonumbers_and_state: introduce decoder (based on vector slicer)
Gerhard Sittig [Sun, 19 Jul 2020 17:41:18 +0000 (19:41 +0200)]
numbers_and_state: introduce decoder (based on vector slicer)

The idea was taken from the vector slicer as suggested in github PR 17.
The code was rewritten to avoid cluttering the decoder set with lots of
tiny implementations. Create a single decoder which does all of the bit
accumulation as well as number format interpretation and also includes
number to text formatting with user selectable presentations. Optional
clock is supported, to avoid too many annotations in glitchy setups. The
IEEE 754 format was added as another interpretation. The enum code path
accepts data files in either the Python or JSON format (the latter feels
backwards to me). Putting enums on separate rows helps visualize state
transitions. Users can disable GUI traces or select CLI rows to silence
the output if it feels noisy.

The most appropriate (useful, and usable) number of supported channels
is yet to get determined. This version accepts up to 16 inputs.

3 years agoirmp: silence "illegal character encoding" compiler warning
Gerhard Sittig [Sun, 19 Jul 2020 06:44:00 +0000 (08:44 +0200)]
irmp: silence "illegal character encoding" compiler warning

Replace non-ASCII characters in the FDC keyboard map with their
respective number values, since the character presentation is
non-portable and results in compiler warnings.

A similar change was done in IRMP version 3.2.0 (SVN r192 as of
2020-06-22) which the sigrok project has not caught up with yet.

3 years agorgb_led_ws281x: Support RGBW
Stefan [Thu, 4 Jun 2020 09:11:32 +0000 (11:11 +0200)]
rgb_led_ws281x: Support RGBW

Support of the now common RGBW type LED strips (uses 4 bytes instead of 3).

Added an option to select RGB or RGBW

3 years agocaliper: rephrase measurement annotation text construction
Gerhard Sittig [Sat, 18 Jul 2020 18:30:43 +0000 (20:30 +0200)]
caliper: rephrase measurement annotation text construction

Unclutter the construction of the annotation text for measurements.
Prefer one code block over multiple scatterred lines. Only do string
formatting when an annotation gets emitted. Prefer .format() for its
better control over generated text. Fixup remaining Python idioms in
the unit conversion block while we are here.

3 years agocaliper: use common code for packet timeout
Gerhard Sittig [Sat, 18 Jul 2020 18:05:42 +0000 (20:05 +0200)]
caliper: use common code for packet timeout

The previous implementation unconditionally waited for up to 1ms, and
optionally handled the user configured timeout period. Use common code
instead to handle the full span of the timeout period. Which somewhat
unclutters the .decode() routine's body by eliminating an unnecessary
step in the sequence. This change also reduces indentation, and prefers
Python's .format() over the old syntax.

3 years agocaliper: use common code for bit accumulation
Gerhard Sittig [Sat, 18 Jul 2020 17:45:22 +0000 (19:45 +0200)]
caliper: use common code for bit accumulation

There is only one annotation, rename ss/es for consistency with other
decoders. Move a conversion constant to the top of the source file, and
rename some identifiers to increase readability of math expressions.
There is no point in constructing numbers in MSB first order and then
reversing their bit order. Prefer Python lists for accumulated bits, and
common code for number conversion. Use one code block for the extraction
and conversion of received data instead of a set of scattered lines.
This shall increase readability of the data extraction, and eliminates
redundancy in the implementation.

3 years agocaliper: refactor and unobfuscate timeout handling
Gerhard Sittig [Sat, 18 Jul 2020 17:02:18 +0000 (19:02 +0200)]
caliper: refactor and unobfuscate timeout handling

Move math expressions with always identical values out of the loop, and
improve readability of the packet timeout condition in the process.

3 years agocaliper: slight refactoring of common pieces
Gerhard Sittig [Sat, 18 Jul 2020 16:40:50 +0000 (18:40 +0200)]
caliper: slight refactoring of common pieces

Merge .reset_data() into .reset() since no other location called it.
Move self.options[] lookup out of the loop, drop state from self when
it's strictly local to .decode(). Use a common annotation emission
routine, and vertically align text variants for zoom levels. This
further reduces the lengths of a few text lines.

3 years agocaliper: fixup boilerplate (and some coding style and whitespace)
Gerhard Sittig [Sat, 18 Jul 2020 16:14:19 +0000 (18:14 +0200)]
caliper: fixup boilerplate (and some coding style and whitespace)

The caliper decoder was written against an older version of the library
and failed to load in recent environments. Fixup the decoder boilerplate
(eliminate ambiguous annotation class/row names, drop the IC tag) and
address other style nits while we are here (rephrase user visible text,
break a few long lines, adjust some of the indentation and whitespace
issues, drop dead code). Remaining issues get addressed later.

3 years agocaliper: introduce decoder for cheap generic calipers
Tomas Mudrunka [Sat, 30 May 2020 17:21:23 +0000 (19:21 +0200)]
caliper: introduce decoder for cheap generic calipers

3 years agoir_irmp: enforce "one instance" limitation for IRMP library
Gerhard Sittig [Sat, 18 Jul 2020 11:15:41 +0000 (13:15 +0200)]
ir_irmp: enforce "one instance" limitation for IRMP library

The IRMP core library is not prepared for threading or interleaved use
by multiple call sites for different data streams, internal state is
kept in global vars (MCU project heritage). Adjust the Python wrapper,
create one usable instance, and several more which fail to execute.
Fail late such that users see error messages.

The approach isn't pretty, but avoids segfaults when re-loaded sessions
assign multiple decoder instances, and raises user's awareness of the
"one instance" limitation by established means: "decoder error" bar, and
log messages, with a description to point out the cause.

This commit implements a dirty modification of a singleton. It's a pity
that Python appears to lack reliable destruction, hence the whole class
remains blocked even if the instance is released. Move all library use
into pd.py:decode() in the hope that Python's 'with' could help in a
future implementation. Prepare to either present a generic message that
is generated by pd.py, or pass on a text that originates in the Python
wrapper for the C library.

3 years agoir_irmp: add support for button "release" flag
Gerhard Sittig [Fri, 17 Jul 2020 21:04:34 +0000 (23:04 +0200)]
ir_irmp: add support for button "release" flag

Recent upstream IRMP core versions introduced a "release" flag in
addition to the "repeat" flag. Prepare the decoder to present these
flags when libraries should pass them in results.

The flags' being orthogonal slightly complicates the logic which
constructs annotation texts. Do provide text variants for all previously
supported zoom levels, yet try to keep the implementation as simple as
possible: Match list lengths for simplified folding. Always print the
flags field even if none of the flags is active (kind of was done before
this change as well, just not visible). This approach easily accepts
more flags as needed in future versions.

3 years agoir_irmp: touch up the IRMP based decoder implementation (Python side)
Gerhard Sittig [Sat, 22 Feb 2020 09:28:54 +0000 (10:28 +0100)]
ir_irmp: touch up the IRMP based decoder implementation (Python side)

Address Python and sigrok project coding style nits in the IRMP based
decoder for infrared signals. Re-add the attribution which was lost in a
previous copy and forgotten in the recent submission. Eliminate camel
case identifiers and adjust to the simplified Python binding API. Drop
remaining diagnostics from development and dead code (unused carrier
detection). Reword the boilerplate text to match other decoders. Avoid
Python f-strings since they are not portable. Prefer slightly less
cryptic variable names in the construction of annotation texts. Defer
the creation of the library instance until actual decoder use. Start
inspecting the input data at the very first samples in the input stream.