summaryrefslogtreecommitdiff
path: root/decoders
AgeCommit message (Collapse)Author
2020-07-26can: enable Python output from decoderKari Hautio
2020-07-26ir_nec: improve robustness, present more data on invalid inputGerhard Sittig
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.
2020-07-25ir_nec: Add button texts for an unknown LED panel remoteSebastian Rittau
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
2020-07-25ir_nec: add support for extended NEC protocol (16bit address)Gerhard Sittig
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.
2020-07-25ir_nec: use common helper for bit accumulationGerhard Sittig
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.
2020-07-25ir_nec: rephrase button lookup and addr/cmd validity checksGerhard Sittig
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.
2020-07-25ir_nec: only use the samplerate after receiving the valueGerhard Sittig
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.
2020-07-25ir_nec: rephrase annotation logic, symbolic names, format() callGerhard Sittig
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.
2020-07-22ir_sirc: minor Python and other nitsGerhard Sittig
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.
2020-07-22ir_sirc: symbolic names for IR pulse widths, more line trimmingGerhard Sittig
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.
2020-07-22ir_sirc: use symbolic identifiers for annotation classesGerhard Sittig
2020-07-22ir_sirc: reduce smarts to improve maintenance (.wait() API change)Gerhard Sittig
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.
2020-07-22ir_sirc: use ss/es for consistency with other decodersGerhard Sittig
2020-07-22ir_sirc: .put() nits, common helpers, whitespaceGerhard Sittig
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.
2020-07-22ir_sirc: fixup decoder boilerplateGerhard Sittig
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.
2020-07-22ir_sirc: introduce decoder for Sony IR remote control protocolTom Flanagan
2020-07-20spdif: Simplify samplerate check.Uwe Hermann
2020-07-20spdif: Drop unneeded braces.Uwe Hermann
2020-07-20spdif: Fix various issues.Arno Morbach
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.
2020-07-20numbers_and_state: introduce decoder (based on vector slicer)Gerhard Sittig
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.
2020-07-18rgb_led_ws281x: Support RGBWStefan
Support of the now common RGBW type LED strips (uses 4 bytes instead of 3). Added an option to select RGB or RGBW
2020-07-18caliper: rephrase measurement annotation text constructionGerhard Sittig
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.
2020-07-18caliper: use common code for packet timeoutGerhard Sittig
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.
2020-07-18caliper: use common code for bit accumulationGerhard Sittig
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.
2020-07-18caliper: refactor and unobfuscate timeout handlingGerhard Sittig
Move math expressions with always identical values out of the loop, and improve readability of the packet timeout condition in the process.
2020-07-18caliper: slight refactoring of common piecesGerhard Sittig
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.
2020-07-18caliper: fixup boilerplate (and some coding style and whitespace)Gerhard Sittig
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.
2020-07-18caliper: introduce decoder for cheap generic calipersTomas Mudrunka
2020-07-18ir_irmp: enforce "one instance" limitation for IRMP libraryGerhard Sittig
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.
2020-07-18ir_irmp: add support for button "release" flagGerhard Sittig
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.
2020-07-18ir_irmp: touch up the IRMP based decoder implementation (Python side)Gerhard Sittig
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.
2020-07-18ir_irmp: introduce IRMP based decoder for infrared signalsGerhard Sittig
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.
2020-07-18irmp: add 'Darwin' case for DLL filename lookupGerhard Sittig
Detect the MacOS platform by checking for 'Darwin' with the Python platform(3) module, and use the 'lib<stem>.dylib' filename scheme.
2020-07-18irmp: rework the Python language binding for the shared libraryGerhard Sittig
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).
2020-07-18irmp: introduce Python language binding for shared libraryGerhard Sittig
Commit the IrmpPythonWrap.py file as it was provided by Rene Staffen.
2020-07-17pjon: comment nits, typo fixGerhard Sittig
2020-07-17pjdl: support PAD bit adjacent to last HIGH DATA bit (no LOW)Gerhard Sittig
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 <jcallano@gmail.com>
2020-07-17pjon: unbreak CRC32 check, adjust data lengthGerhard Sittig
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 <jcallano@gmail.com>
2020-07-13eeprom24xx: Add ST M24C32Thomas Hebb
2020-07-10xy2-100: Add status signalSoeren Apel
2020-07-10xy2-100: Rewrite PD for XY2-100E compatibility and featuresSoeren Apel
2020-07-10xy2-100: Initial implementationUli Huber
2020-07-07timing: user selected scale and sample count for terse displayGerhard Sittig
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.
2020-07-07timing: break long options lines, rename samples identifierGerhard Sittig
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.
2020-07-07timing: only queue when averaging, rephrase put callsGerhard Sittig
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.
2020-07-07timing: optional terse format for timing annoationsGerhard Sittig
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.
2020-07-07timing: use ss/es for consistencyGerhard Sittig
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.
2020-07-07timing: reduce "state", most action is local to .decode()Gerhard Sittig
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'.
2020-07-07timing: eliminate magic numbers, remove unused variablesGerhard Sittig
Use symbolic identifiers for pin numbers and annotation classes. Remove unused variables.
2020-07-07pjon: fixup PD category for PJDL and PJONGerhard Sittig