summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-04-13configure: break long list of python-embed packagesGerhard Sittig
2023-04-12configure: Add python 3.11 and 3.12 supportFrank Stettner
2023-01-09adf435x: add support for register field content warningsGerhard Sittig
Add support for register field content checkers, and emit warning annotations when they yield non-empty results. Implement a checker for the INT field of register R0. Reduce the allowed values' lower limit from 32 (previous implementation) to 23 (ADF4350 datasheet, figure 24).
2023-01-09adf435x: shuffle register description tableGerhard Sittig
Move table columns, put the bit field position to the front before the name to get a less fragile visual appearance. All fields have a position and a name (of variable length), some of them have a "parser" (actually a formatter for their content). Address Python style while we are here: Prefer tuples over lists for immutable data. Add trailing commas to reduce future diff sizes. Add a TODO comment about optional content checkers. The current decoder implementation lets invalid register data pass unnoticed. [ see a word diff for the commit's essence ]
2023-01-09adf435x: rephrase table lookups for display textsGerhard Sittig
Try a different presentation of exising information in the register fields' display text construction (extra parsers for known fields). Attempt a source code format which hopefully better lends itself to index range verification during review. Make the number of available expansion texts stand out more visually, so that readers can compare their count to the register field's width. Address those register fields with four or more expansion values, keep the simple single bit cases as they are. Add a comment for awareness.
2023-01-09adf435x: use .format() for Python string formattingGerhard Sittig
Rephrase the old style '%' operator string formatting, prefer .format() calls instead. It is assumed that routine call argument lists are more readable than optional/conditional tuples are, and not running format specifiers and literal text into each other helps readability as well, as do the .format() routine's optionally named references to parameters. Avoid text formatting which involves concatenation, always work from one single format instruction instead.
2023-01-09adf435x: factor out inspection of 32bit wordsGerhard Sittig
Move the inspection of a completed 32bit word into the .decode_word() routine. This simplifies checks for fatal constraints, as well as optional inspection of deeper detail levels when extra parsers are available. Rename variables in the code path which accumulate bits. Add comments to helper routines and to essential steps in complex interpretation code paths. Eliminate the unused return value of the .decode_field() method. Results in a lean and readable .decode() body.
2023-01-09adf435x: rework emission of annotationsGerhard Sittig
Separate data processing from text formatting in the code paths which emit annotations. Introduce a local .putg() helper. This unobfuscates the decoder's operation, and also happens to shorten text lines. Raises awareness for zoom levels and alternative text during maintenance. This commit incompatibly rephrases the "Wrong number of bits" message.
2023-01-09adf435x: Python list idioms in bits sequence accumulationGerhard Sittig
Use .extend() and .clear() for the Python list during accumulation of a 32bit word's bits sequence. This shall improve readability. Performance is less of an issue since this decoder's data amount remains small (32bit entities per SPI transfer). Comment on the unexpected(?) SPI decoder's BITS ordering when passing details up to stacked decoders. Raise and keep awareness for this non-obvious implementation detail during decoder maintenance. This implementation accumulates bits in the MSB order as they are sent in SPI frames. Yet keeps the LSB bit order when a completely accumulated 32bit word gets inspected, to reduce the diff size. Bit field extraction and annotation emission code paths assume a specific timestamp ordering. The separation of transport and inspection also simplifies maintenance, should a future SPI decoder provide BITS in their received order.
2023-01-09adf435x: use common bits to number conversion helperGerhard Sittig
Use common support code to convert bit fields to integer numbers. Also unobfuscate the decode_bits() method and its returned values' layout. Improves readability and factors out common expressions.
2023-01-09adf435x: Move decoder logic to SPI transfersVesa-Pekka Palmu
The previous implementation of the ADF435x decoder assumed knowledge of internal details which are the SPI transport layer's responsibility. And encoded an inappropriate chip select polarity in the process (falling CS edge). The datasheet specifies that previously clocked in data bits get latched on rising LE edges. Not all setups were affected, that's why the issue went unnoticed before. Use the lower layer's TRANSFER annotation to process the completion of an ADF435x register access, after BITS annotations made the location of individual bits available. The LE (CS) signal's polarity remains a detail of the SPI decoding layer, and must be configured there. The SPI decoder's default matches the ADF435x chip's expectation. This fixes bug #1814. Reported-by: Martin Homuth-Rosemann <homuth-rosemann@gmx.net>
2023-01-09adf435x: Add warning on frame size mismatchVesa-Pekka Palmu
Check the bit count of SPI transfers. Only start inspecting ADF435x register content when the accumulation of the expected 32bit word has completed. Emit a warning annotation for unexpected transfer sizes.
2023-01-09adf435x: Clean up SPI data inputVesa-Pekka Palmu
Avoid generic variable names. Only unpack parameters which are provided by the lower layer decoder after the stacked decoder checked their type and is aware of their meaning.
2022-11-24util: silence printf format compiler warnings (Python ssize_t)Gerhard Sittig
On some platforms PY_FORMAT_SIZE_T seems to be ineffective, resulting in compiler warnings about printf format data type mismatches (observed in MXE builds). Silence the warnings. Prefer the ssize_t data type instead which we know the printf format of, reliably.
2022-11-24type_decoder: silence print format warnings, greppable messagesGerhard Sittig
Silence printf(3) format warnings. Python's data types should be considered opaque, size (and signedness) are usually unknown, as is the relation to standard C language print format specs. Unbreak long messages which were spread across several source code text lines. This complies to Linux style guides. Being able to find diagnostics messages that were reported by users in sources is more important than sticking to an arbitrary text line length.
2022-11-24nit: break a long line in different ways, unobfuscate parameter groupingGerhard Sittig
Break a rather long line for a Python method call at a different location, to better reflect the parameter groups which organize for the method to get called, and those which pass parameters to that called method. This commit also splits the actual action and its check for successful execution into separate C language statements.
2022-10-03parallel: flush accumulated data when input data is exhaustedGerhard Sittig
The "parallel" decoder buffers the currently seen data pattern, and defers annotation emission until the end position is known. Which is why the last data pattern would not show up in the decoder's output. See bug #292 and its duplicates for examples and concerns. Catch the EOFError exception, and flush previously accumulated data. It is yet to get determined whether a warning annotation is due. Most probably not for "parallel" which merely visualizes data line states. But other decoders which have the concept of frames shall NOT follow this "parallel" decoder's naive approach, and claim that a frame had completed although its end condition was never seen. Add a developer TODO comment to raise awareness.
2022-10-03type_decoder: update .samplenum before ending .wait() with EOFErrorGerhard Sittig
When the protocol decoder's input data is exhausted, then the .wait() method will raise the EOFError exception. Python decoders can catch this exception and handle the condition. For proper annotation emission it is essential that the self.samplenum value corresponds to the last position in the input stream. Update it before returning from the .wait() call.
2022-08-21srd: add support for SIGROKDECODE_PATH environment variableGerhard Sittig
The optional SIGROKDECODE_DIR environment variable accepts a single directory specification. The SIGROKDECODE_PATH variable accepts a list of directories to search protocol decoders. The list separator is platform dependent (colon or semicolon). Empty items are explicitly ignored. Both variables get evaluated. Behaviour remains backwards compatible, just gets extended for improved usability.
2022-08-21srd: add TODO comment on the SIGROKDECODE_DIR env var's motivationGerhard Sittig
A comment in the srd.c implementation suggests that the environment variable SIGROKDECODE_DIR would serve debugging purposes and would override other incarnations of available decoders. I disagree with either of these interpretations. Add a TODO comment, the phrase may need an update or rework.
2022-04-23uart: don't re-calculate in-frame bit position, just count the bitsGerhard Sittig
The .get_wait_cond() routine kept re-calculating the current bit index in the currently inspected UART frame. Just count the bits instead as they are seen/taken. This eliminates redundant complex logic which had hard to track down issues in past revisions. Increases robustness, and improves maintainability.
2022-04-23uart: handle two stop bits configurationGerhard Sittig
Sample and process multiple STOP bits as specified, add 2.0 to the list of supported configurations. This implementation works as expected with integer numbers of STOP bits (0, 1, 2). For half-bits the sample point as well as the annotation position will be incorrect (as a result of an internal implementation detail of the existing decoder which is not easy to address). This commit reduces the diff size, and remains backwards bug-compatible. Fixing the bit boundaries in annotations including support for half-bits is more involved, and remains for a later commit.
2022-04-23uart: handle zero stop bits configurationGerhard Sittig
Use common code to advance internal state during UART frame inspection. This reduces redundancy, and improves robustness. Data bits collectors need not worry about the optional presence of subsequent fields (parity, stop bits, both can be absent). Improve the separation of implementation details of the lower layer UART frame decoding from upper layer protocol handling. Concentrate the post processing of UART frames, BREAK and IDLE conditions in the source, and keep the ss/es determination at the caller which detected the condition by arbitrary means. This unbreaks the decoder's operation when 0 stop bits are configured. The implementation still assumes that the line goes idle between frames even when zero stop bits are configured. Strictly speaking this decoder now copes with traffic that uses "less than half a stop bit".
2022-04-23sbus_futaba: add decoder for SBUS hobby remote control by FutabaGerhard Sittig
This is the SBUS remote control by Futaba, the 25 bytes on top of UART. Not the computer peripheral bus. Hence the suffix in the decoder name. The implementation was tested with synthetic data. Example captures with real world data have yet to become available. This implementation shows the message framing, the proportional and digital channels' values, and the flags. Several warnings for short and long and invalid messages are implemented, as are user adjustable channel value range limits. The boilerplate may need adjustment. All naming was made up by me based on what information was available (vendor doc was missing).
2022-02-24libsigrokdecode.h: declare Windows dllexport for SRD_API routinesGerhard Sittig
Add the __declspec(dllexport) decoration to SRD_API routines on Windows when building the library body (this is new). Stick with the default visibility on all other platforms (as previously implemented). This is similar to what Kyle Johnson submitted in PR 66, but phrased differently. Avoid the non-portable indentation before the hash in preprocessor instructions. Use positive logic for readability (put the Windows branch next to the check for the Windows platform). Reported-By: Kyle Johnson <KyleJ61782@gmail.com>
2022-01-09decoder: rename iteration variables to improve readabilityGerhard Sittig
Use longer variable names for the iteration over channels, options, annotation classes and rows, and binary classes when a decoder gets loaded. This improves readability, especially in nested loops with complex test conditions and diagnostics messages. Although the Python variables were checked for their availability and expected data type, and we should only see non-negative index values, the iteration variable's data type remains unchanged in this commit (sticks with signed size types).
2022-01-09decoder: check annotation rows' references to annotation classesGerhard Sittig
Check the annotation class indices when iterating annotation rows. Refuse to load decoders with inconsistent declarations, emit error messages to raise developers' awareness of implementation bugs. This fixes bug #1601.
2022-01-09decoder: don't break error messages, factor out Python variable nameGerhard Sittig
Don't break long error messages in source code, so that developers can grep for user reported strings during maintenance. This commit does not change behaviour. Concentrate repeated references to the 'annotation_rows' Python variable name in a single spot at the top of the helper routine.
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.
2021-12-26ir_irmp: wrapper lib, add locking and Python threading supportGerhard Sittig
The IRMP core library is not thread safe (known limitation, heritage of the AVR firmware origin). Add a mutex so that calling applications can lock IR decoder core instances. Allow Python threading while waiting for the locks, we can safely assume that this IRMP wrapper is used in the sigrok context which does require Python for decoders. Add my copyright for the non-trivial changes. This implementation uses glib for locking to improve portability, which already is a dependency of the libsigrokdecode component. This version uses belt and suspenders by implementing a constructor as well as adding auto init calls to each of the public API code paths. The client ID is not an essential requirement, but useful during application maintenance.
2021-12-26ir_irmp: wrapper lib, silence warnings in "Windows or Unix" conditionGerhard Sittig
Platform detection in the external IRMP library works best when either the WIN32 or the unix identifiers are provided, which the sigrokdecode build environment derives from other identifiers which are more reliably available. It turns out that other external dependencies like glib or Python may provide some of these identifiers, too. Which results in the compiler warning about symbols' redefinition. Only define derived identifiers when they haven't been provided yet. This amends commit ab88bae1c7b9.
2021-12-26session: introduce the public "send EOF" API routineGerhard Sittig
Introduce the public srd_session_send_eof() routine which is backed by the internal srd_inst_send_eof() helper. Applications can tell decoders when the input stream of sample data is exhausted, so that decoders can optionally "flush" their previously accumulated information when desired. Previous implementations just kept decoders in blocking .wait() calls and somehow terminated them at arbitrary times afterwards. When EOF is sent to the decoder session, then calls to the .wait() method which typically are done from .decode() or its descendents will end with an EOFError Python exception. Termination of .decode() with the EOFError exception is non-fatal for backwards compatibility and to keep the convenience for current decoder implementations. Decoders can either catch the exception, or use context managers, or do nothing. This API extension is motivated by research for bug #1581 and provides the infrastructure to address bug #292. Decoders need to remain careful, and should not claim that protocol activities would have completed when their end condition was not even seen in the capture. Marking incomplete activities with warnings is the most appropriate reaction.
2021-12-26type_decoder: eliminate explicit string length spec for literalsGerhard Sittig
Rephrase the 'names[]' array declaration in output_type_name() to avoid the necessity of guessing what the maximum length of the literals might be during future maintenance. Developers need not care when the compiler can handle this detail.
2021-12-26type_decoder: use ALL_ZERO for sentinels in method/member tablesGerhard Sittig
Avoid the full listing of all-zero struct members in sentinel items of object methods and class properties tables. Use the ALL_ZERO phrase instead which better reflects what's intended, and reliably silences warnings should structs' lengths differ across Python versions.
2021-12-26type_decoder: update and extend Decoder base class doc stringsGerhard Sittig
Some doc strings have become outdated, update them. Some doc strings were terse, extend them. Ideally protocol decoder authors would be able to use the builtin documentation to answer questions on data types and arguments order. This implementation isn't there yet, needs more work.
2021-12-26type_decoder: move Python doc strings to method implementationsGerhard Sittig
Move Python doc strings to the location where methods and classes get implemented. This improves awareness during maintenance, and allows for longer text phrases without obfuscating the registration code path. This commit does not alter the content of existing doc strings, only moves their location. And keeps related items together when long decls span multiple text lines (function name and arguments list, args and kw args), to improve/keep readability.
2021-12-26internal: introduce ALL_ZERO declaration, modelled after libsigrokGerhard Sittig
Declare ALL_ZERO in the common libsigrokdecode-internal.h header file. The implementation and the comment on its motivation were taken from the libsigrok implementation, slightly rephrased for improved readability.
2021-12-21configure.ac: Use python3-embed.pc as a fallbackEvangelos Foutras
This provides some future-proofing against newer Python versions.
2021-12-20configure: Add python 3.10 supportSoeren Apel
2021-12-17parallel: Add binary outputSoeren Apel
2021-07-29rc_encode: Add support for EV1527, RT1527, FP1527 and HS1527Soeren Apel
2021-06-21ieee488: add support for parallel poll (PP)Gerhard Sittig
The concurrent assertion of ATN and EOI is a PP (parallel poll) query. The host asserts the control signals, and configured devices may assert the DIO lines in response. Because DAV is not involved, and because the input capture may not have DIO at the start of the PP phase, and may neither have DIO any more at its end, the check for parallel poll is more complex. Unconditionally inspecting each sample of the capture is inefficient. Keep manipulating the main loop's wait conditions instead, to stick with edge navigation as long as possible, and only switch to inspection of individual samples when strictly needed. It's also important to gracefully handle low oversampling. Existing test cases suffered from PP glitches when ATN asserted in the same location where EOI deasserted. Be extra conservative about the presence of the PP phase, expect at least two samples (a difference between its start and end position) before emitting the annotation.
2021-06-21ieee488: shorten an option description for consistency across dialogsGerhard Sittig
The description text of the Commodore peripherals option spanned a rather wide space. Trim the text for consistency with other options.
2021-06-21ieee488: support optional parity for ATN commands (for HP gear)Gerhard Sittig
HP gear is said to sometimes send commands (ATN asserted) with a parity. Introduce an option to check and strip the MSB before interpretation. Reported-By: Anders Gustafsson <Anders.Gustafsson@pedago.fi>
2021-06-16doc: update IRC reference to Libera.ChatGerhard Sittig
2021-03-07decoder: increment Python object reference for .has_channel() resultGerhard Sittig
This fixes bug #1671. Reported-By: Ivan Wick
2021-02-13Use uint8_t instead of unsigned char for raw byte dataSoeren Apel
2021-02-13Implement basic flushingSoeren Apel
2021-02-13Rename logic_class to logic_group and output as group-wise RLESoeren Apel