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

3 years agoir_irmp: introduce IRMP based decoder for infrared signals
Gerhard Sittig [Sat, 22 Feb 2020 09:19:26 +0000 (10:19 +0100)]
ir_irmp: introduce IRMP based decoder for infrared signals

Commit the decoder as it was provided by Rene Staffen. Which appears to
be a slightly modified version of one of the other IR decoders, though
the boilerplate doesn't say so.

3 years agoirmp: add 'Darwin' case for DLL filename lookup
Gerhard Sittig [Sat, 18 Jul 2020 13:46:00 +0000 (15:46 +0200)]
irmp: add 'Darwin' case for DLL filename lookup

Detect the MacOS platform by checking for 'Darwin' with the Python
platform(3) module, and use the 'lib<stem>.dylib' filename scheme.

3 years agoirmp: rework the Python language binding for the shared library
Gerhard Sittig [Sat, 22 Feb 2020 09:16:16 +0000 (10:16 +0100)]
irmp: rework the Python language binding for the shared library

Rename the Python language binding's source file and identifiers to
eliminate camel case (most of it, stick with camel case in Python class
names as is the convention). Adjust whitespace and arrange tables such
that their indentation will last during maintenance.

Re-add the license text which was missing in the original submission's
copy of another decoder. Add copyright information for this submission.

Don't "import *" from ctypes(3), use explicit references instead. Avoid
double underscores as single leading underscore is already bad enough.
Adjust the Python side to the C library's renamed API routines.

Create a result data structure layout that only has a single level of
nesting, which better represents the C library's interface. Only flags
"get unfolded" in the Python binding, to eliminate magic numbers.

Prepare to support more platforms than Linux (detected) and Windows (the
default when nothing else got detected).

3 years agoirmp: introduce Python language binding for shared library
Gerhard Sittig [Sat, 22 Feb 2020 09:01:19 +0000 (10:01 +0100)]
irmp: introduce Python language binding for shared library

Commit the IrmpPythonWrap.py file as it was provided by Rene Staffen.

3 years agoirmp: hook up IRMP to the build, create a separate shared object
Gerhard Sittig [Sat, 22 Feb 2020 08:52:39 +0000 (09:52 +0100)]
irmp: hook up IRMP to the build, create a separate shared object

Add the irmp/ subdirectory to the automake build instructions. Make the
feature optional, provide an enable/disable switch (on by default).

It's an essential implementation detail that the irmp.c file is required
to build, but is not a compile unit of its own. It's yet to be seen how
to most appropriately declare the dependencies of libirmp_la (can get
refined in future commits).

Create a separate shared object from the IRMP source, which shall result
in a stable filename for the DLL/.so lookup. Decoder library code would
not know the application's executable name, neither is anonymous symbol
lookup "in the current process" portable across supported platforms.

The configure.ac macros were modelled after the autobook DLL section.
https://www.sourceware.org/autobook/autobook/autobook_137.html
Symbol export is simple because the library gets implemented and built
here, but is not used from C language code in this project. That's why
we don't do the full dance of symbol import which would be needed on
Windows.

3 years agoirmp: workaround incomplete platform detection when under libtool
Gerhard Sittig [Sun, 23 Feb 2020 04:26:18 +0000 (05:26 +0100)]
irmp: workaround incomplete platform detection when under libtool

The upstream IRMP project builds fine with direct gcc(1) invocation.
While the same imported source fails detection and then defaults to AVR
when built under libtool in the libsigrokdecode setup.

Provide the symbols which IRMP logic expects, to reduce changes against
upstream sources. Derive these symbols from conditions that are checked
in the sigrok project in other locations, too.

3 years agoirmp: silence core logic ANALYZE output from the shared library
Gerhard Sittig [Sat, 22 Feb 2020 08:38:32 +0000 (09:38 +0100)]
irmp: silence core logic ANALYZE output from the shared library

Workaround the default verbosity level of the IRMP core logic for
PC library build configurations. Silence the ANALYZE related output.

3 years agoirmp: rework shared library (style, reliability, TODO items)
Gerhard Sittig [Sat, 22 Feb 2020 06:27:58 +0000 (07:27 +0100)]
irmp: rework shared library (style, reliability, TODO items)

Address several style nits in the previous implementation of the PC
library, but keep the core as is to simplify future upstream tracking.

Eliminate camel case identifiers, and in(?)/out prefixes for variables,
only keep s_ for global(?) variables. Fixup whitespace, reduce a little
indentation where appropriate. Separate variable declaration from later
assignments and updates to improve readability. Use C style comments.

Drop initializer values for .bss variables. Decorate the declaration as
well as implementation of routines for symbol export. Improve robustness
of name lookups in the list of known protocols.

Prefer native C language data types in the public API. Normalize data in
the wrapper so that application code need not care. Make the byte buffer
API for IR frame detection optional. The API is limited and overloaded
at the same time, and may need more consideration.

Extend comments in spots which are essential for proper operation, or
which encode non-obvious details of the build system. Control visibility
of public API identifiers on non-Windows platforms, too. Rephrase the
doxygen comments for more formal API documentation. Discuss limitations
in the current implementation. Keep a TODO list in the source code.

3 years agoirmp: introduce PC side shared library code for IRMP core logic
Gerhard Sittig [Sat, 22 Feb 2020 06:09:37 +0000 (07:09 +0100)]
irmp: introduce PC side shared library code for IRMP core logic

Introduce sources which implement a shared object (DLL) which embeds the
IRMP core logic, receives pin values from an application, and makes IR
detection from previously captured data available in PC environments as
a library, in contrast to the text oriented desktop applications and the
MCU firmware which existed before in the upstream project.

Provided by: Rene Staffen

3 years agoirmp: introduce variables for start of IR frame and current sample
Gerhard Sittig [Sat, 22 Feb 2020 05:49:03 +0000 (06:49 +0100)]
irmp: introduce variables for start of IR frame and current sample

Introduce variables in the IRMP core logic which track the current
sample number, and the position where the start of an IR frame got
detected. The variables are conditional (ANALYZE builds only).

Provided by: Rene Staffen

Local modification: Drop the initializer for the static variables.
They reside in .bss and need not occupy .data space.

3 years agoirmp: adjust config for PC library use (32bit, 20kHz, more protocols)
Gerhard Sittig [Sat, 22 Feb 2020 05:44:29 +0000 (06:44 +0100)]
irmp: adjust config for PC library use (32bit, 20kHz, more protocols)

This change enables most IR protocol variants (35 of them), as well as
32bit wide counters, and uses the highest supported samplerate of 20kHz
by default. Which shall result in most reliable detection of protocols
and an appropriate feature set for PC library use.

Provided by: Rene Staffen

3 years agoirmp: silence missing prototype compiler warning
Gerhard Sittig [Sun, 23 Feb 2020 04:49:51 +0000 (05:49 +0100)]
irmp: silence missing prototype compiler warning

The sigrok project enforces warnings when public routines of compile
units lack prototypes. Add a prototype for the irmp.c:print_spectrum()
routine to silence a compiler warning. An alternative would have been to
mark the routine as static (it's exclusively used within the same file).

3 years agoirmp: address unbalanced preprocessor condition (PIC workaround)
Gerhard Sittig [Sat, 22 Feb 2020 05:38:19 +0000 (06:38 +0100)]
irmp: address unbalanced preprocessor condition (PIC workaround)

The #else inside a multi line comment in combination with the excess yet
commented #endif threw off my editor's syntax highlighting and parentheses
matching. Use "#if 0" instead to disable the empty side of ANALYZE macros
which some PIC compilers are said to not support. No change in behaviour.

3 years agoirmp: silence signedness compiler warning in IR command comparison
Gerhard Sittig [Sat, 22 Feb 2020 05:32:40 +0000 (06:32 +0100)]
irmp: silence signedness compiler warning in IR command comparison

Assume that IR command codes can get represented by a C language 'int'
data type. The other value in the comparison is another 'int' anyway.

3 years agoirmp: silence printf(3) format warnings (simple approach)
Gerhard Sittig [Sat, 22 Feb 2020 05:29:16 +0000 (06:29 +0100)]
irmp: silence printf(3) format warnings (simple approach)

Pick low hanging fruit. Stick with the previous implementation's format
specifiers, assume that they work on all platforms which IRMP supports.
Cast arguments to mere integers where necessary instead, again assume
that their range fits as they did in the previous implementation. This
silences several of these compiler warnings:

  irmp.c:3332:25: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long unsigned int’ [-Wformat=]
                           ANALYZE_PRINTF ("protocol = NIKON, start bit timings: pulse: %3d - %3d, pause: %3d - %3d\n",
                           ^

3 years agoirmp: introduce sigrok specific README file
Gerhard Sittig [Fri, 28 Feb 2020 14:35:59 +0000 (15:35 +0100)]
irmp: introduce sigrok specific README file

Introduce a separate README-sigrok.txt file, to leave the upstream
project's README.txt file as is. Mention that libsigrokdecode only
contains a subset of the full IRMP project source code.

3 years agoirmp: introduce (part of) upstream IRMP sources
Gerhard Sittig [Sat, 22 Feb 2020 06:20:05 +0000 (06:20 +0000)]
irmp: introduce (part of) upstream IRMP sources

Introduce source files and documentation from the GPL'ed IRMP project.
Commit those files which represent the IRMP core logic (detection of
IR frames), and reference the project's homepage for the remainder.
These files correspond to

  svn://mikrocontroller.net/irmp r191

3 years agoconfigure: add AC_C_CONST to configure.ac
Gerhard Sittig [Sat, 22 Feb 2020 05:09:35 +0000 (06:09 +0100)]
configure: add AC_C_CONST to configure.ac

This is inspired by the autobook sections on Windows DLL builds.
https://www.sourceware.org/autobook/autobook/autobook_137.html

The AC_C_CONST macro improves support for the C language 'const'
decoration in case the compiler does not understand it.

3 years agopjon: comment nits, typo fix
Gerhard Sittig [Fri, 17 Jul 2020 07:16:32 +0000 (09:16 +0200)]
pjon: comment nits, typo fix

3 years agopjdl: support PAD bit adjacent to last HIGH DATA bit (no LOW)
Gerhard Sittig [Fri, 17 Jul 2020 07:17:02 +0000 (09:17 +0200)]
pjdl: support PAD bit adjacent to last HIGH DATA bit (no LOW)

The PJDL decoder's previous implementation was incomplete. It assumed
that PAD bits always start with a rising edge. Which made the decoder
miss the next byte when a previous byte's MSB is set, and the last DATA
bit and the next PAD bit kept the signal HIGH between them (no LOW phase
was seen between these symbols).

Keep the check for the LOW level after the byte's last DATA bit within
the bit times' tolerance. But accept when the level remains HIGH, and
check for the HIGH bit's width starting from the end of the last DATA
bit. Also start the PAD bit's annotation from that "virtual" edge.

This patch is based on a fix that was
Submitted-By: Julio Aguirre <redacted>
3 years agopjon: unbreak CRC32 check, adjust data length
Gerhard Sittig [Fri, 17 Jul 2020 07:12:17 +0000 (09:12 +0200)]
pjon: unbreak CRC32 check, adjust data length

The previous implementation unconditionally assumed a CRC width of
one byte when it calculated the checksum for received frame data.
Do reflect on the CRC8/CRC32 choice instead.

This patch is based on a fix that was
Submitted-By: Julio Aguirre <redacted>
3 years agoeeprom24xx: Add ST M24C32
Thomas Hebb [Mon, 13 Jul 2020 13:56:40 +0000 (15:56 +0200)]
eeprom24xx: Add ST M24C32

3 years agoxy2-100: Add status signal
Soeren Apel [Thu, 9 Jul 2020 22:47:09 +0000 (00:47 +0200)]
xy2-100: Add status signal

3 years agoxy2-100: Rewrite PD for XY2-100E compatibility and features
Soeren Apel [Fri, 10 Jul 2020 18:47:17 +0000 (20:47 +0200)]
xy2-100: Rewrite PD for XY2-100E compatibility and features

3 years agoxy2-100: Initial implementation
Uli Huber [Fri, 10 Jul 2020 18:39:56 +0000 (20:39 +0200)]
xy2-100: Initial implementation

3 years agotiming: user selected scale and sample count for terse display
Gerhard Sittig [Fri, 3 Jul 2020 11:55:04 +0000 (13:55 +0200)]
timing: user selected scale and sample count for terse display

Optionally let users pick the scale for terse timing annotation text.
Which potentially makes numbers show up earlier (at zoom levels of a
further distance). And drops the unit to present mere numbers, which
could speed up navigation during inspection. Keep providing automatic
scaling which then includes the unit text, as it did before.

Extend the automatic scaling to include picoseconds. Which avoids the
fallback to unit-less floating point with uncertain decimals when the
samplerate was 1GHz or higher.

Optionally present distances in terms of sample counts. This supports
decoder development, and can help users spot and judge glitches.

All "terse" presentation so far exclusively affects the 'time' row. It
remains an option for later to migrate averages and deltas as well. For
now it's assumed that high(er) precision and fine grained details are
more important for these rows.

3 years agotiming: break long options lines, rename samples identifier
Gerhard Sittig [Fri, 3 Jul 2020 10:58:40 +0000 (12:58 +0200)]
timing: break long options lines, rename samples identifier

Break text lines in the options declarations which have become rather
long. Rename 'samples' in the main loop to just 'sa', which better
matches the other 'ss', 'es', 't', etc identifers. Separate the code
for unconditional 'time' classes from optional averaging and deltas.

3 years agotiming: only queue when averaging, rephrase put calls
Gerhard Sittig [Fri, 3 Jul 2020 10:33:28 +0000 (12:33 +0200)]
timing: only queue when averaging, rephrase put calls

Reduce the amount of work which the timing decoder needs to do. Only
keep the deque() filled when averaging is active. Rephrase .put() calls
to reduce text line lengths (and for consistency with a pending change).
Move another options lookup for deltas out of the main loop.

3 years agotiming: optional terse format for timing annoations
Gerhard Sittig [Fri, 3 Jul 2020 10:12:40 +0000 (12:12 +0200)]
timing: optional terse format for timing annoations

In some situations (inspecting a dense run of pulses in a burst of data
communication) it takes a lot of zooming before the 'timing' decoder's
'time' annotations start revealing numbers. Which limits the number of
pulses which can fit in the visible trace area.

This is a stab at improving the usability of the timing decoder for
similar "crowded pulses" scenarios. Try to come up with an annotation
text that is shorter yet communicates the very details which the user
needs in this situation. Drop the frequency, avoid umlauts in the unit
text, don't use decimal places (use all integers within a scale). Even
offer to drop the unit text, assuming that a dense run of pulses results
in all times sharing their scale.

Make the terse presentation optional and off by default, and use a
separate annotation class for maximum backwards compatibility.

3 years agotiming: use ss/es for consistency
Gerhard Sittig [Fri, 3 Jul 2020 09:22:03 +0000 (11:22 +0200)]
timing: use ss/es for consistency

Consistently use ss and es identifiers for annotation emission to match
other decoders, as well as counting distances between sample points to
increase readability. This also dramatically reduces text line length.

3 years agotiming: reduce "state", most action is local to .decode()
Gerhard Sittig [Fri, 3 Jul 2020 09:14:31 +0000 (11:14 +0200)]
timing: reduce "state", most action is local to .decode()

Reduce the number of self members, use local variables instead for data
which is strictly kept within a method and need not remain across calls.
Move options dictionary lookups out of the main loop, as the previous
implementation already did with 'edge'.

3 years agotiming: eliminate magic numbers, remove unused variables
Gerhard Sittig [Fri, 3 Jul 2020 08:54:34 +0000 (10:54 +0200)]
timing: eliminate magic numbers, remove unused variables

Use symbolic identifiers for pin numbers and annotation classes. Remove
unused variables.

3 years agopjon: fixup PD category for PJDL and PJON
Gerhard Sittig [Tue, 7 Jul 2020 16:24:06 +0000 (18:24 +0200)]
pjon: fixup PD category for PJDL and PJON

3 years agosae_j1850_vpw: drop the part which duplicates the timing decoder
Gerhard Sittig [Sat, 2 May 2020 13:08:41 +0000 (15:08 +0200)]
sae_j1850_vpw: drop the part which duplicates the timing decoder

The SAE J1850 Variable Pulse Width decoder used to track and annotate
the width of pulses between edges, which duplicates existing features
of the 'timing' decoder. Remove this part from J1850, users can always
connect the input signal to multiple decoders as needed..

Also sort annotation rows while we are here. Top to bottom represents
raw wire bits to highest interpretation layer, as in other decoders.

3 years agosae_j1850_vpw: eliminate magic numbers for annotation class references
Gerhard Sittig [Sat, 2 May 2020 11:16:02 +0000 (13:16 +0200)]
sae_j1850_vpw: eliminate magic numbers for annotation class references

Use symbolic identifiers for annotation classes, to improve readability
and maintainability.

3 years agosae_j1850_vpw: update for API v3, adjust to recent requirements
Gerhard Sittig [Sat, 2 May 2020 13:49:05 +0000 (15:49 +0200)]
sae_j1850_vpw: update for API v3, adjust to recent requirements

IRC user pman92 reported that this decoder exists, and started migration
to the v3 API. This commit completes the migration, and adds missing
decoder infrastructure which has become mandatory recently.

Adjust the boilerplate: Drop FSF postal address. No Python output, add
category tag, unambiguous annotation class and row names. Add reset()
method. Use common code for edge detection.

This commit also addresses minor style nits. Pass the most recent
pulse's edges as ss and es to the data bit handling routine. Adjust
whitespace to unbreak editor navigation and to improve readability.

Use a more verbose name for the decoder, "vpw" appears a little short
and collision happy, and is not found when users search for "j1850".

[ Indentation changed, see whitespace ignoring diff for the essence. ]

Reported-By: pman92 <redacted>
3 years agovpw: introduce SAE J1850 (VPW) decoder
Anthony Symons [Sun, 5 Jun 2016 18:13:00 +0000 (18:13 +0000)]
vpw: introduce SAE J1850 (VPW) decoder

Introduce a protocol decoder for the GM VPW 1x and 4x Vehicle Bus
(SAE J1850, or VPW for variable pulse width).

3 years agopjon: show "communication relations", and nits
Gerhard Sittig [Thu, 2 Jul 2020 19:15:00 +0000 (21:15 +0200)]
pjon: show "communication relations", and nits

Do track the RX and TX information, including their bus IDs. Present bus
numbers as dotted quads. Emit another summary annotation for completed
frames which presents receiver, transmitter, payload, and ACK details at
even higher zoom levels. Rename the last remaining "init CRC" instance
for consistency.

3 years agopjdl: prepare for "stretched" timings
Gerhard Sittig [Thu, 2 Jul 2020 17:12:37 +0000 (19:12 +0200)]
pjdl: prepare for "stretched" timings

Since the spec is vague on the subject, and real world captures were
found to occassionally run on odd clocks, internally prepare to inspect
traffic and interpret its content although the input data is invalid in
the strictest sense. Keep this hack internal, don't suggest to users
that invalid traffic would be perfectly acceptable.

3 years agopjon: use underscore in input/output names for stacked decoders
Gerhard Sittig [Thu, 2 Jul 2020 17:11:31 +0000 (19:11 +0200)]
pjon: use underscore in input/output names for stacked decoders

Rename 'pjon-link' to 'pjon_link' for consistency with other decoders.

3 years agopjon: introduce decoder for PJON frame inspection
Gerhard Sittig [Sat, 20 Jun 2020 07:31:18 +0000 (09:31 +0200)]
pjon: introduce decoder for PJON frame inspection

Introduce a protocol decoder which accepts 'pjon-link' Python input and
interprets PJON frames. The implementation is assumed to be operational
but most of the protocol's flexibility (optionally present and variable
width fields) has not yet been tested due to lack of example captures.
During development of the PJON decoder only the PJDL link layer decoder
was available, other link layers were not tested.

3 years agopjdl: introduce decoder for PJON single wire serial link layer
Gerhard Sittig [Mon, 15 Jun 2020 11:37:18 +0000 (13:37 +0200)]
pjdl: introduce decoder for PJON single wire serial link layer

Introduce a protocol decoder which generates 'pjon-link' output from
'logic' input by interpreting the PJDL single wire serial communication
link layer of the PJON protocol stack. This decoder extracts frame
markers, data bytes, as well as their pad/sync decoration. Inspection of
data values, or checks for frame validity remain the responsibility of a
stacked decoder which is shared among several link layer types.

This implementation "violates" the PJDL spec in those places where the
spec is incomplete or vague, and real world traffic would not decode at
all when the strict letter of the spec is applied instead of its spirit.
When in doubt, the decoder implementation errs to the usability side.

Carrier sense detection is incomplete in this version. Data extraction
works for all currently available captures. Recovery from synchronization
loss after glitches is acceptable. Glitch filtering is missing (the spec
is silent on this subject).

3 years agojtag: Use list.append instead of insert
Konrad Beckmann [Mon, 22 Jun 2020 01:55:07 +0000 (03:55 +0200)]
jtag: Use list.append instead of insert

Improve processing time by appending bits
instead of inserting them to the lists.

3 years agonrf905: Drop non-existent OUTPUT_PYTHON output.
Uwe Hermann [Tue, 26 May 2020 20:24:24 +0000 (22:24 +0200)]
nrf905: Drop non-existent OUTPUT_PYTHON output.

3 years agonrf905: More readable annotation byte values.
Uwe Hermann [Tue, 26 May 2020 20:06:03 +0000 (22:06 +0200)]
nrf905: More readable annotation byte values.

Drop the 0x prefix for each byte in annotations (for improved readability).

Also, use 02X instead of 02x (printf-style formats).