Gerhard Sittig [Tue, 14 Mar 2017 17:00:06 +0000 (18:00 +0100)]
uart: Convert to PD API version 3
Adjust the UART protocol decoder, to make use of the query based API.
Have edges detected and unrelated samples skipped by common code.
This implementation keeps some redundancy in place (like checking for
having reached specific sample numbers, while the backend managed that
for us). This approach reduces the diff and shall simplify review.
Only some common checks in decode() were moved to the start of the
routine, outside of the sample inspection loop.
Gerhard Sittig [Tue, 14 Mar 2017 16:10:28 +0000 (17:10 +0100)]
uart: Minor readability nit (position of start bit in calculation)
Rephrase the bit slot index calculation for UART frames such that it
becomes more apparent whether a start bit is involved or whether an
array index needs adjustment due to Python range semantics.
This shall improve readability, and reduce the probability of off-by-one
errors during maintenance.
Gerhard Sittig [Tue, 14 Mar 2017 14:35:27 +0000 (15:35 +0100)]
uart: Immediately skip reception of parity bits when not applicable
When the UART frame does not contain a parity bit, then immediately
advance to reception of stop bits after all data bits were received.
This eliminates the necessity to run the parity check routine when
parity does not apply in the first place. Without this change, some
"dummy" sample needs to get inspected for correct operation of the
state machine.
Gerhard Sittig [Sun, 5 Mar 2017 17:09:59 +0000 (18:09 +0100)]
decoder: terminate .wait() and .decode(), join threads for v3 instances
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.
Marcus Comstedt [Sun, 26 Feb 2017 12:07:03 +0000 (13:07 +0100)]
Return SRD_ERR_ARG from srd_inst_decode if samplenums are wrong
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.
Marcus Comstedt [Sun, 26 Feb 2017 11:52:12 +0000 (12:52 +0100)]
Fix refcounting bug in set_new_condition_list()
py_conditionlist is an owned reference (it gets passed to Py_DecRef()
at the end), so we need to increment the refcount when assigning it
from the borrowed reference py_conds.
Gerhard Sittig [Sun, 26 Feb 2017 08:16:36 +0000 (09:16 +0100)]
instance.c: fix a 'matched' vs 'matches' typo
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.
Uwe Hermann [Tue, 7 Feb 2017 09:40:29 +0000 (10:40 +0100)]
instance.c: Fix a compiler warning.
../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))
^~
Karl Palsson [Mon, 28 Nov 2016 17:31:55 +0000 (17:31 +0000)]
Look up instances by ID in the full stack
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.
Karl Palsson [Mon, 11 Apr 2016 15:25:42 +0000 (17:25 +0200)]
Support adding multiple instances of a decoder
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 <redacted> Signed-off-by: Karl Palsson <redacted>
Gerhard Sittig [Sun, 15 Jan 2017 10:26:19 +0000 (11:26 +0100)]
z80: Convert to PD API version 3 (brute force)
This implementation technically uses v3 API calls, but has yet to come
up with appropriate wait() conditions, to spend less time in the decoder
and have more tedious work done in the backend.
Gerhard Sittig [Sat, 12 Nov 2016 22:19:47 +0000 (23:19 +0100)]
avr_pdi: introduce decoder for Atmel Program and Debug Interface
Introduce a decoder for Atmel's proprietary programming and debugging
interface which got introduced with ATxmega chips. This implementation
supports the UART style physical (two wires PDI_CLK and PDI_DATA).
Uwe Hermann [Fri, 26 Aug 2016 13:09:17 +0000 (15:09 +0200)]
Add support for the new query-based PD v3 decoder API.
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.
Gerhard Sittig [Sun, 20 Nov 2016 15:51:47 +0000 (16:51 +0100)]
build support: sort list of installed items, factor out pretty printer
Alpha-sort the list of installed items, to support developers which scan
the list for newly added items. Factor out the logic which pretty prints
installed items while maintaining a maximum screen output line length.
Gerhard Sittig [Sun, 16 Oct 2016 16:25:29 +0000 (18:25 +0200)]
Print error messages when decoders fail load time checks
Several checks get applied when loading externally provided protocol
decoders. Print error messages when checks fail, so that developers can
better resolve issues.
The sequence of tests terminates upon the first failed check, while
decoders may suffer from several issues at the same time. This is
considered acceptable, as it reduces the commit's size and the code's
complexity. This commit only adds error messages, and does not change
logic/behaviour.
Failed API version checks result in two messages: One specific message
which reflects the decoder's version and what's supported by the loader,
and a generic message that the API version check has failed. This is
done to simplify the logic of a rarely used error code path.
This commit addresses libsigrokdecode Bug 704, and allows to identify
decoders from parallel installations of differing version.
Gerhard Sittig [Sun, 16 Oct 2016 16:25:25 +0000 (18:25 +0200)]
.gitattributes: introduce git attributes for improved Python diffs
In the absence of respective instructions, git will use a rather generic
approach to generate diffs and patches. Introduce a git attributes file
which results in improved output for Python sources (i.e. all protocol
decoders).
Gerhard Sittig [Sun, 16 Oct 2016 16:26:18 +0000 (18:26 +0200)]
uart: skip frames with invalid start bits
When the start bit is not low at its sample point, then stop trying
to interpret the remaining frame -- it's already known to be invalid,
anyway.
Wait for the next start bit instead, assuming that either the falling
edge which started the inspection of the UART frame and its start bit
was a spurious glitch or that the captured signal does not communicate
at the decoder's configured bitrate.
Gerhard Sittig [Sun, 16 Oct 2016 16:25:28 +0000 (18:25 +0200)]
uart: rework text formatting of communicated data values, plus nits
Factor out the code which generates a textual representation for the
numeric values that were communicated via UART bit patterns. Make the
width of the output text depend on the number of bits in the UART frame
(five to nine) instead of assuming bytes of exactly eight bits.
Fix other minor issues while we are here: Nine bits result in a number
range of 0 to 511 (not 512). ASCII codes 30 and 31 are non-printables.
The previous implementation skipped a significant leading digit in the
octal representation.
Gerhard Sittig [Sun, 16 Oct 2016 16:25:27 +0000 (18:25 +0200)]
uart: minor nit, rename the "databyte" variable
Given the generic nature of UART communication and the supported range
for the data width, "byte" may be a misleading name for the numeric
value that gets communicated in five to nine data bits. Rename the
"databyte" variable to "datavalue".
Chris [Mon, 12 Sep 2016 01:14:44 +0000 (18:14 -0700)]
midi: Add support for complex MIDI message formats (inter-related).
- Handle "Running Status" where status byte can be omitted
- SysEx message can be terminated by status byte, not just EOX
- Handle SysReal messages that interrupt in-progress message transmission
- Identify and print garbage / truncated data
- Add 2 new annotations: text-sysreal-verbose and text-error
Chris Dreher [Fri, 19 Aug 2016 17:26:02 +0000 (10:26 -0700)]
midi: Substantially improve decoding of MIDI messages.
* Decode note names and percussion names (ex: 'G2', 'Tambourine').
* Decode instrument names and drum_kit names (ex: 'Flute', 'GS Orchestra Kit').
* Handle Polyphonic Pressure / Aftertouch (message 0xAn).
* Handle Program Change (message 0xCn).
* Handle Channel Pressure / Aftertouch (message 0xDn).
* Handle Channel Mode (message 0xBn mm where mm is 120 through 127).
* Handle System Common messages (message 0xF1 through 0xF6), including
full time code decoding.
* SysEx decoding now decodes the 1-3 byte manufacturer field, payload
is now displayed as hex.
* 'undefined' fields now display the value (ex: 'undefined 0xf4').
* Add 'MSB' and 'LSB' to many control_functions entries.
* Fix "trapped in state X" bug with handle_channel_msg_generic(),
though this might be dead code.
* Fix bug in sysex_manufacturer_ids; 1-byte manufacturers were not
tuples due to missing comma.
* Fix bug in SysEx decoding state machine; 0xF7 now sent to handle_sysex_msg().