summaryrefslogtreecommitdiff
path: root/decoders/ir_nec/pd.py
AgeCommit message (Collapse)Author
2020-08-30ir_nec: fix typo in STOP bit widthGerhard Sittig
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.
2020-08-30ir_nec: sort and comment timing specs, drop tolerance optionGerhard Sittig
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.
2020-08-30ir_nec: concentrate timing at the top of the source fileGerhard Sittig
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.
2020-08-30ir_nec: Add option for automatic polarity detectionBenediktO
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 ]
2020-08-30ir_nec: Make the tolerance configurableBenediktO
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 ]
2020-08-30ir_nec: Annotate IR frame already at the end of the STOP bitBenediktO
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 ]
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 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-01-01All PDs: Consistently use singular/plural for annotation classes/rows.Uwe Hermann
2019-11-29ir_nec: fix #1243, multiple capture frames.Philipp Marek
2019-04-02decoders: Fix incorrect 'outputs' fields.Uwe Hermann
Only add items to 'outputs' if the respective PD actually has OUTPUT_PYTHON support implemented as of right now. Various decoders might get OUTPUT_PYTHON support later, but the 'outputs' field should reflect the current status.
2019-03-15decoders: Add/update tags for each PD.Uwe Hermann
2018-02-15ir_nec: optionally accept input signals that include the carrierGerhard Sittig
Introduce optional detection of a carrier signal. Immediately "go active" when edges are seen. "Go inactive" again in the absence of edges in a specified period of time. Cope with input signals that already had the carrier removed. By default carrier detection is disabled, to remain pixel compatible to the previous implementation. When a carrier frequency is specified and thus detection is enabled, edges of already filtered input are shifted by one carrier period, and thus changes the output of the decoder. For unfiltered inputs that still contain the carrier, detection of activity is reliable and immediate, but the active phase is extended by one period of the carrier frequency (which is considered acceptable).
2017-12-22all decoders: introduce a reset() methodGerhard Sittig
Move initialization code of protocol decoders from the constructor to a new reset() helper method. The libsigrokdecode backend could run this method several times to clear the decoder's internal state, before new data from another acquisition gets fed to decode() calls.
2017-12-17ir_nec: Make timing margin relativeGrant Miller
This replaces the fixed timing margin with a percentage based tolerance to better allow for timing inaccuracies, especially for longer timings like the Leader and Repeat codes.
2017-06-05Add srd_inst_initial_pins_set_all() and support code.Uwe Hermann
This allows frontends to set the assumed initial pins (i.e., the assumed state of the pins before the first sample of a capture) to user-specified values. The assumed initial pins can be either low, or high, or "use same value as the first sample of the capture". The special self.initial_pins decoder attribute is now removed.
2017-01-07license: remove FSF postal address from boiler plate license textGerhard Sittig
Remove the FSF postal address as it might change (it did in the past). Reference the gnu.org website instead which is more stable.
2016-12-07ir_nec: Convert to PD API version 3.Uwe Hermann
2016-05-15Use consistent __init__() format across all PDs.Uwe Hermann
The previous **kwargs some PDs had is not actually ever used, so drop it.
2014-07-15All PDs: Minor whitespace and consistency fixes.Uwe Hermann
- No newlines at the end of files. - No trailing ';' characters. - Comparison with None: Use 'is None' or 'is not None'. - Comparison with True/False: Use 'if cond:' or 'if not cond:'. - Various minor whitespace fixes.
2014-07-09Various PDs: Throw SamplerateError instead of Exception.Uwe Hermann
Also, use the "if not self.samplerate" form, which catches both the case where self.samplerate is None, as well as the case where it is 0.
2014-07-09All PDs: Drop unneeded exceptions.Uwe Hermann
In all current PDs it is not necessary to raise an exception upon invalid states (of the PD's state machine), since we can guarantee that no such invalid state can ever be reached in these PDs.
2014-04-15All PDs: Bump api_version to 2.Uwe Hermann
Older libsigrokdecode versions are no longer able to use the current versions of the PDs (various changes in syntax etc).
2014-04-15All PDs: Drop some unneeded comments.Uwe Hermann
2014-04-13Rename 'probe' to 'channel' everywhere.Uwe Hermann
Variables of type 'struct srd_channel *' are consistently named 'pdch' to make them easily distinguishable from libsigrok's 'struct sr_channel *' variables that are consistently named 'ch'.
2014-03-10ir_nec: Update to recent PD API changes.Uwe Hermann
2014-03-10ir_nec: Add support for higher-level remote control annotations.Uwe Hermann
2014-03-10ir_nec: Addresses and commands are transmitted LSB-first.Uwe Hermann
2014-03-10ir_nec: Add support for more fields.Uwe Hermann
Also show the AGC field(s) and pauses, the stop bit, and the individual address / address# and command / command# fields.
2014-03-10ir_nec: Drop some unneeded options.Uwe Hermann
The timing of the protocol is not really configurable, valid data in this protocol must always adhere to the same timing parameters, making them configurable should not be needed. Also: Only check for the "interesting" edges and simplify the code a bit.
2014-03-10Rename 'ir_nec6122' PD to 'ir_nec', minor fixes and simplifications.Uwe Hermann
This IR protocol is commonly referred to as "the NEC protocol", and can be generated by various means (not only via the NEC µPD6121/µPD6122 ICs). Drop some unneeded variables and fix/simplify the code a bit.