summaryrefslogtreecommitdiff
path: root/instance.c
AgeCommit message (Collapse)Author
2019-04-02srd_inst_stack(): Warn upon potentially incorrect stacking.Uwe Hermann
Currently there must be at least one match of inputs/outputs for decoders that are stacked. If not, we emit an informational warning (but this is not a hard error for the time being).
2018-10-16instance.c: Avoid 4 unneeded forward declarations.Uwe Hermann
2018-10-13Various log message improvements.Uwe Hermann
2018-10-13instance.c: Make oldpins_array_*() static.Uwe Hermann
2018-08-30Make srd_inst_decode() return the actual decoder state, not SRD_OKSoeren Apel
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-18sample_matches(): Force inlining for performance reasons.Uwe Hermann
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-05-18Random whitespace/cosmetic/consistency fixes.Uwe Hermann
2018-05-16srd_inst_channel_set_all(): Fix a compiler warning (-Wshadow).Uwe Hermann
instance.c:266:11: warning: declaration of ‘l’ shadows a previous local [-Wshadow] GSList *l = g_slist_nth(di->decoder->channels, i); ^ instance.c:206:9: note: shadowed declaration is here GList *l; ^
2018-05-16instance.c: Fix a scan-build warning.Uwe Hermann
instance.c:278:25: warning: The left operand of '!=' is a garbage value if (new_channelmap[i] != -1) ~~~~~~~~~~~~~~~~~ ^
2018-05-16instance.c: Fix a memory leak reported by scan-build.Uwe Hermann
instance.c:280:10: warning: Potential leak of memory pointed to by 'new_channelmap' pdch = g_slist_nth(di->decoder->channels, i)->data; ^~~~~~~~~~~
2018-04-23instance: return SRD_ERR_TERM_REQ when execution shall terminateGerhard Sittig
The previous implementation internally noticed the "want terminate" request, and skipped decoder execution to faster get to the end of the input stream. But an OK return code was provided in that code path, and more input data was sent by applications (sometimes for many seconds or few minutes). Do return a new SRD_ERR_TERM_REQ error code, such that applications can tell failed execution from requested termination.
2018-04-23instance: drop an unneeded "want wait() to terminate" reset assignmentGerhard Sittig
It's uncertain why srd_inst_decode() which internally gets called by the public srd_session_send() routine used to clear the want_wait_terminate flag. This should be cleared upon decoder instance creation and state reset, gets raised upon termination request, but shall not get cleared in other spots, especially not upon the availability of new input data while the stream shall be considered in the "about to terminate, skip all subsequent execution" state.
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.
2018-03-31instance: make sure oldpins array is available after resetGerhard Sittig
Introduce an oldpins_array_seed() helper routine, to make sure that each call site which checks previous pin state will find valid data. This was not always the case after decoder reset, which released the old pin data while applications would not call srd_inst_new() again. Preset newly allocated arrays with the default initial pin state, allow optional application calls to specify differing initial values (when specified by users), and keep the current state after first data was processed.
2017-11-11instance.c: Removed redundant variableJoel Holdsworth
2017-09-06Clarify and improve channel map debug output.Uwe Hermann
2017-06-30Acquire/release the Python GIL where needed to avoid threading issues.Uwe Hermann
With these additions, frontends can now call libsigrokdecode API functions from different threads without running into threading issues. The backend releases the GIL when it is performing tasks that might take a while and it doesn't need to run Python/C API calls during that time. This allows frontends to run multiple PD stacks (in multiple frontend threads) "at the same time" in a time-sharing, "interlocked" manner. Whenever one of the decoders is inside e.g. self.wait() it releases the GIL and thus allows other decoders to do some work in the mean time. The user-visible effect is that for use-cases such as running 3 different decoder stacks at the same time for an acquisition, the user will not have to wait for PD 1 to finish decoding, then wait for PD 2 to finish decoding, and only *then* being able to see annotations from PD 3. Instead, all three PDs will decode some chunks of data from time to time, thus the user is able to inspect annotations from all 3 PDs while the acquisition and decoding is still going on.
2017-06-16Drop support for PD API version 2.Uwe Hermann
All decoders must be of PD API version 3 now.
2017-06-16instance.c: Drop a few unneeded checks.Uwe Hermann
2017-06-12Various Doxygen fixes.Uwe Hermann
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-03-12decoder: terminate .wait() and .decode(), join threads for v3 instancesGerhard Sittig
Add support to terminate blocking .wait() and .decode() method calls of v3 decoder instances. This terminates the decoder thread's main routine and allows to release associated resources. Cope with requested as well as unexpected termination of decode() calls. Add debug messages to thread related code paths. Make sure to unblock the main thread which feeds the decoder thread. This unbreaks situations where decoders e.g. throw "need samplerate to decode" exceptions. Drain Python errors which might remain from the most recent .decode() execution, to not affect other code paths. This avoids an issue where the creation of a new decoder instance fails in the presence of errors from a previous run. This fixes bug #902.
2017-02-27instance.c: Add a debug message for thread creation.Uwe Hermann
2017-02-26srd_inst_decode(): Slightly more verbose error message.Uwe Hermann
2017-02-26Fix examples to show abs_end_samplenum as exclusiveMarcus Comstedt
2017-02-26Return SRD_ERR_ARG from srd_inst_decode if samplenums are wrongMarcus Comstedt
This validates the requirements that * abs_start_samplenum continues where the previous decode ended * abs_end_samplenum is not lower than abs_start_samplenum Failure to meet these requirements will make v3 decoders crash.
2017-02-26instance.c: fix a 'matched' vs 'matches' typoGerhard Sittig
The Decoder_wait() routine will populate the .matched attribute before returning to the caller. The srd_inst_start() routine used to setup a .matches attribute which is unexpected. Make both routines consistently assign to 'matched' as that is what Python decoder implementations are referencing.
2017-02-21Clarify that {start,end,cur}_samplenum are absolute numbers.Uwe Hermann
2017-02-20instance.c: Fix a compiler warning.Uwe Hermann
../instance.c: In function ‘srd_inst_find_by_id’: ../instance.c:485:3: warning: suggest parentheses around assignment used as truth value [-Wparentheses] if (di = srd_inst_find_by_id_stack(inst_id, tmp)) ^~
2017-02-20Look up instances by ID in the full stackKarl Palsson
srd_inst_find_by_id() previously only searched for instance IDs at the bottom of any stacked decoders. Make it properly search all stacks, just like srd_inst_find_by_obj() and more usefully when trying to generate unique instance IDs. No external API change, only the explicit behaviour of the API. This fixes parts of bug #868. Signed-off-by: Karl Palsson <karlp@etactica.com>
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>
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-12-06valgrind: free channelsKarl Palsson
Signed-off-by: Karl Palsson <karlp@etactica.com>
2016-08-25srd_inst_decode(): Return SRD_ERR_ARG if unitsize is 0.Uwe Hermann
2016-08-25srd_inst_decode(): Make the code API version dependent.Uwe Hermann
2016-08-25srd_inst_decode(): Improve comments and log messages.Uwe Hermann
Also, drop @since tag (as the function is not public).
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-13Build: Include <config.h> first in all source filesDaniel Elstner
Since Autoconf places some important feature flags only into the configuration header, it is necessary to include it globally to guarantee a consistent build.
2015-09-10instance.c: Don't use 'di' before NULL-checking it.Uwe Hermann
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.
2015-07-23Slightly more verbose logging in srd_inst_decode().Uwe Hermann
2015-04-01Use g_malloc*() consistently, simplify error handling.Uwe Hermann
Use g_malloc*() for small allocations and assume they always succeed. Simplify error handling in a few places accordingly. Document the rules in the README file.
2014-10-15instance.c: Fix whitespace.Uwe Hermann
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-04Mark some variables more consistently as SRD_PRIV.Uwe Hermann
2014-05-04Update a few Doxygen @since tags.Uwe Hermann
2014-04-15instance.c: s/probe/channel/.Uwe Hermann