summaryrefslogtreecommitdiff
path: root/libsigrokdecode-internal.h
AgeCommit message (Collapse)Author
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-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-02-13Implement basic flushingSoeren Apel
2019-11-24decoder: internal 'always false' term, handle invalid skip and channelGerhard Sittig
Introduce an "always false" type for .wait() terms. Map invalid counts of skip conditions (zero or negative numbers) as well as invalid channel references for level/edge conditions to this type which never matches. Keep this "always false" term type an internal detail of the common support code. This is most robust and least intrusive at the same time, it keeps the existing API, and simplifies the implementation of Python decoders for rare edge cases (optional input signals or optional features, handling of initial samples at the very start of a capture). This commit passes sample counts internally in a signed data type. This is essential for proper operation, and the loss of one bit out of 64 shall not be considered a severe limitation. This fixes bug #1444.
2018-10-13log: Use human-readable output type name everywhere.Uwe Hermann
2018-05-18srd_*inst_find_by_obj(): Move functions, make them static.Uwe Hermann
These functions are only used in type_decoder.c. Move them there and make them static.
2018-05-18Simplify code by dropping session_is_valid().Uwe Hermann
A simple NULL check is sufficient here, max_session_id is being properly handled by srd_init(), srd_exit(), srd_session_new(). This might also have a small performance benefit.
2018-03-31session: add "terminate and reset" support for protocol stacksGerhard Sittig
Implement routines which terminate currently pending decoder operations and reset internal state (on the C and Python sides) for instances as well as sessions. This allows to re-use previously created stacks for new input data.
2017-05-31struct srd_decoder: Add list of input/output decoder IDs.Uwe Hermann
2017-02-21Clarify that {start,end,cur}_samplenum are absolute numbers.Uwe Hermann
2017-02-20Support adding multiple instances of a decoderKarl Palsson
srd_inst_new() used the decoder ID as the instance ID, preventing the use of multiple instances of the same decoder in the same session. Simply append a numerical suffix to later instances to allow more. Required changes to cleanup to reliably free all memory. Valgrind checked. This fixes parts of bug #868. Based on original work by: Soeren Apel <soeren@apelpie.net> Signed-off-by: Karl Palsson <karlp@etactica.com>
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-07Add support for the new query-based PD v3 decoder API.Uwe Hermann
For the time being, both APIs (2 and 3) will remain supported until all decoders have been converted to API version 3. Then, support for API version 2 will be dropped. Decoders using PD v3 API can benefit from both readability improvements as well as performance improvements. Up to 10x speedup has been measured in some situations (depends a lot on the decoder, the amount of data, the amount of edges in the signals, the amount of oversampling etc. etc.). This is only the first set of (basic) performance improvements for libsigrokdecode, there are various additional opportunities for further changes to improve performance. This changeset has been tested to survive a run of all the test-cases in the sigrok-test repo without issues (for the converted PDs), however it is not very well-tested yet, so there might be regressions that need to be addressed.
2016-08-25Factor out srd_decoder_apiver().Uwe Hermann
2015-10-06exception: Decorate catch function with format attributeDaniel Elstner
2015-10-06util: Factor out Python module loadDaniel Elstner
Create a utility function for loading a Python module by its name in UTF-8.
2015-10-06decoder: Refactor loading code and plug leaksDaniel Elstner
2015-10-06Python: Restrict code to stable ABI subsetDaniel Elstner
Limit usage of the Python C API to the stable ABI subset as defined by PEP 384. This removes some type definitions and functions which libsigrokdecode made use of. Convert all affected code to suitable API alternatives. Also fix a few leaks that became apparent while working on the code. The most visible change is that PyTypeObject is now an opaque type. Thus, the custom Decoder and srd_logic types are now created on the heap via an alternative API. Unfortunately, since tp_name is now inaccessible, type names had to be removed from the log output. Stack traces after Python exceptions are now formatted by calling into Python, since the trace object C API is no longer available.
2015-09-13log: Enable varargs format warningsDaniel Elstner
Decorate srd_log() with the GCC format printf attribute so that the compiler can check the format string and arguments for consistency. Also remove the srd_err(), sr_warn(), etc. functions and replace them with macro wrappers around srd_log().
2015-08-20Pass unitsize per sample chunk.Uwe Hermann
Don't pass unitsize to srd_inst_channel_set_all(), have that only set the channel map. Instead, srd_session_send() now has a parameter for the unitsize which is passed with every new chunk to be decoded. This is in preparation to fix issues with devices or files which have a unitsize != 1 and where the "guessed" unitsize based on the number of channels is not correct. This also allows for (potential) future changes where every chunk can indeed have a different unitsize. This fixes (parts of) bug #352.
2014-08-14Whitespace and consistency fixes.Uwe Hermann
2014-07-08Remove dependency on Python.h from public API headerMarcus Comstedt
This prevents Python.h from being included into client code, where it can mess things up by e.g. redefining _POSIX_C_SOURCE.
2014-05-03Move srd_check_init() to decoder.c and make it static.Uwe Hermann
The function srd_check_init() is only used in decoder.c.
2014-01-30Fix warnings exposed by -Wmissing-prototypes.Uwe Hermann
2013-12-11Easier access to sequences of strings, not just lists.Bert Vermeulen
2013-11-18Check library initialization before handling decodersBert Vermeulen
2013-11-18Clean up prototypesBert Vermeulen
2013-11-16Move session-specific functionality into session.cBert Vermeulen
2013-11-15Prune dead codeBert Vermeulen
2013-10-30Pass metadata to PDs only at runtime, not at decoder startBert Vermeulen
The SRD_CONF_NUM_PROBES metadata key was removed. It wasn't actually used for anything, since this is trivially available via the configured (or default) probe list. The SRD_CONF_UNITSIZE key was removed. The unit size is instead derived from the probe list: the number of probes packed into the least amount of space possible defines the unit size. PD changes: * The start() method no longer takes a 'metadata' parameter. * Metadata now comes in only via the metadata() method, which takes a key and value. The only key defined so far is SRD_CONF_SAMPLERATE, which is exported into the module namespace. API changes: * srd_session_send() now takes an end_samplenum parameter, and had its options rearranged. * srd_session_config_set() is now srd_session_metadata_set(). This keeps "config" options for a future feature to allow PDs or frontends to configure each other's options on the fly, up and down the stack.
2013-10-14Move all decoder instances and callbacks into a session structBert Vermeulen
The struct srd_session also holds configuration parameters formerly passed to srd_session_start(). The new call srd_session_new() takes a pointer where a newly allocated pointer to struct srd_session will be stored. This pointer must be passed as the first argument to all functions that require it. The SRD_CONF_NUM_PROBES, SRD_CONF_UNITSIZE and SRD_CONF_SAMPLERATE keys must be configured with srd_config_set() before srd_session_start() is called. A new call srd_session_destroy() is also available. This cleans up all resources the session holds. This is also called from srd_exit() for all sessions.
2013-09-01Use frontend-registered callback with correct parametersBert Vermeulen
2013-05-03libsigrokdecode-internal.h: Cosmetics.Uwe Hermann
2013-05-03Main header is <libsigrokdecode/libsigrokdecode.h> now.Uwe Hermann
This matches the convention used in libsigrok. Potential other headers might end up in libsigrokdecode/, but only libsigrokdecode.h is meant to be #included by frontends directly.