summaryrefslogtreecommitdiff
path: root/decoders/ir_irmp
AgeCommit message (Collapse)Author
2021-12-26ir_irmp: sigrok PD, make use of IRMP decoder core lockingGerhard Sittig
Rephrase how the external IRMP library gets loaded, to provide better diagnostics to users. All decoder instances are equal after the recent introduction of locking support. Move the "reset state" call for the IRMP decoder core to the .decode() method's main loop, where the context manager holds the instance lock. This allows "parallel" execution of multiple IRMP decoders in the same sigrok application, assuming that the context manager scope will be left at some point in time. This fixes bug #1581 when applications communicate EOF to decoders. Move some Python object members to local variables. They exclusively are used within the .decode() method. Update the copyright for the non-trivial changes.
2021-12-26ir_irmp: Python binding, support instance locking and context managerGerhard Sittig
Extend the ctypes wrapper for the IRMP decoder core. Add routines for the instance state creation and lock management. Implement metamethods for Python context managers which lock the instance to protect the C library's internal state from changing unexpectedly. Add my copyright for the non-trivial changes. This commit eliminates the limitation to a single IRMP decoder core for the sigrok process to use. Multiple Python callers can synchronize their library use, and see a consistent library state across the scope of the context manager. It's essential though that callers leave the context to not block other callers for extended periods of time.
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.