Uwe Hermann [Mon, 30 Dec 2019 11:20:45 +0000 (12:20 +0100)]
uart: Use human-readable names for annotation classes.
Using human-readable names for annotation classes (instead of numeric
indices) improves readability and maintainability of the decoder, and can
also prevent bugs due to incorrect indices.
Gerhard Sittig [Tue, 17 Dec 2019 10:48:23 +0000 (11:48 +0100)]
uart: sample position nits, fix typo, float calculation awareness
This commit amends bd50ceb314e4. Fix a typo in a comment. Rephrase the
bit width percentage calculation such that readers remain aware of the
necessity for floating point math in sample position calculations. This
commit does not change behaviour, Python 3 always yields float results
for divisions. It's about raising awareness.
Gerhard Sittig [Wed, 4 Dec 2019 20:21:03 +0000 (21:21 +0100)]
uart: allow arbitrary sample positions for UART bit values (1-99%)
The previous implementation of the UART decoder used to sample bit values
strictly at the center position within a bit time. This commit introduces
support to sample bit values at arbitrary positions in the range of 1-99%
of the bit time. This allows to work around glitches in existing captures
as well as using the decoder for UART like protocols which don't sample
bit values at the center position (like EIB aka KNX).
This implementation is incomplete (on purpose). Although this version
improves the ability to extract data from captures, it also introduces
inaccuracies in the annotation positions for non-default values of the
sample point position. Addressing this issue is left for later, assuming
that it'll be a byproduct of another commit series that is being worked
on (general annotation position adjustment and stop bits support).
Gerhard Sittig [Thu, 12 Dec 2019 09:39:57 +0000 (10:39 +0100)]
signature: increase compatibility across Python versions
Underscores in number literals are a recent Python feature which only
was introduced in version 3.6. The sigrok project claims compatibility
with previous Python versions, but the signature decoder fails to load
with this error:
$ pulseview
srd: SyntaxError: Failed to load decoder signature: import by name failed: invalid syntax (pd.py, line 138)
srd: Traceback (most recent call last):
File "/home/user/share/libsigrokdecode/decoders/signature/__init__.py", line 25, in <module>
from .pd import Decoder
File "/home/user/share/libsigrokdecode/decoders/signature/pd.py", line 138
incoming = (bin(shiftreg & 0b0000_0010_1001_0001).count('1') + data) & 1
^
SyntaxError: invalid syntax
Use the more compact hex presentation for a magic binary pattern. This
obsoletes the necessity to separate groups of bits for readability.
Dave Craig [Wed, 2 Jan 2019 13:36:11 +0000 (13:36 +0000)]
Add HDCP traffic decoder to stack on i2c
This decoder annotates i2c traffic to indicate the type of HDCP
message contained. It includes HDCP2.2 and HDCP1.4. Useful for
analysing HDCP negotiation failures.
Gerhard Sittig [Sat, 7 Dec 2019 07:58:34 +0000 (08:58 +0100)]
ieee488: flush upper layer payload data when IFC asserts
Also flush previously accumulated payload data when the IFC signal
asserts (interface clear, a controller requests ownership of the bus).
This is in line with EOI (end of message) and ATN (start of a command,
including change of "connected" peers or direction of communication).
Gerhard Sittig [Sat, 7 Dec 2019 07:51:16 +0000 (08:51 +0100)]
ieee488: introduce 'delim' option for improved text output
When a capture contains output from a talking device, but neither
contains EOI (end of transmission) nor ATN (new commands, including
changes in the set of communicating peers or communication direction),
then lower layer data bytes would be shown but accumulated runs of upper
layer payload data would not. The hp53131a-ton.sr capture demonstrates
this behaviour.
Add transparent support for the typical case of communicating SCPI over
GPIB. Do emit upper layer payload data annotations when termination
sequences for text lines were seen. Allow users to disable this feature
when it's not appropriate for binary content.
It's an internal implementation detail that accumulated data gets flushed.
Communicate the user visible option as "payload data separation", which
should most appropriately reflect the resulting behaviour. The specific
implementation of this feature can also support different kinds of payload
chunk separation.
Gerhard Sittig [Thu, 3 Oct 2019 02:38:01 +0000 (04:38 +0200)]
ieee488: introduce unified IEEE-488 decoder (supports GPIB and IEC)
Introduce an 'ieee488' protocol decoder which handles both the 16 lines
parallel GPIB variant as well as the serial IEC bus variant. Which kind
of supersedes the 'gpib' and 'iec' decoders.
This implementation increases maintainability because only the extraction
of raw bytes from the parallel or serial bus is separate, and all GPIB
related command/address/data interpretation is shared. This decoder extends
the feature set of the previous versions: Visual annotations are more fine
grained (more classes, additional rows, various text lengths to maintain
usability during zoom). There is binary output for communicated data,
as well as Python output for stacked decoders. Consecutive runs of
talker data gets accumulated, and is made available in binary form as well
as text (with escapes for non-printables). The terse single-letter format
(character codes '0' to 'O' for addresses) is kept for compatibility for
those users who are accustomed to it. The implemented logic also copes
with captures of low samplerate, where edges happen to fall onto the same
sample number which at higher samplerates shall be perceived as distant
and should get processed in their respective order of appearance.
This implementation tracks the most recent configuration of "peers" (the
set of talkers and listeners). A future implementation might support the
isolation of a single conversation out of a busy chat on the bus.
Some optional support for Commodore peripherals is included (currently
limited to disk channels), while it's recommended to move this logic to
a stacked decoder if it grows more complex.
Gerhard Sittig [Fri, 29 Nov 2019 20:15:48 +0000 (21:15 +0100)]
uart: support 'ignore' parity type, remove unsupported 'check_parity' option
The previous UART decoder implementation announced a 'check_parity'
option which took no effect (support code was missing). Remove it. Add
another 'ignore' parity choice instead, which consumes the parity bit's
position yet always passes the check.
Gerhard Sittig [Thu, 10 Oct 2019 07:01:01 +0000 (09:01 +0200)]
can: more robust sample point position for low sample rates
Do more of the calculation with floating point, only trim precision and
enforce integers at the end of the determination of the next sample
point. This shall increase robustness at low capture sample rates.
Gerhard Sittig [Sat, 20 Oct 2018 18:48:46 +0000 (20:48 +0200)]
uart: communicate periods of idle frames to stacked decoders
Detect periods of a frame's length with idle level, and communicate
these time spans to stacked decoders by means of PYTHON output. Do *not*
display these idle frames in regular annotations, for backwards compat.
Gerhard Sittig [Sun, 24 Nov 2019 18:45:01 +0000 (19:45 +0100)]
gpib: drop obscure "total number of samples" option
The gpib decoder tried to "flush" input data at a user specified sample
number when the input data lacked the respective edge which triggers the
processing during regular operation.
This is rather obscure a feature, not seen in any other decoder, perhaps
a workaround for bug #292, rather unaccessible to users (units of sample
numbers not times nor automatic detection of the EOF condition), highly
confusing according to user reports, and not covered by existing tests.
The mere presence of this option caused severe issues in application
code (see bug #1444). While there is no apparent fix that won't affect
other decoders. So let's drop this questionable feature. Valid and
complete captures should contain all relevent edges and thus decode
properly.
A recent commit tightened the check for acceptable 'skip' sample counts.
This broke the onewire_link and usb_signalling decoders' test sequences,
which no longer pass with a minimum count of one. Relax the condition
and accept a count of zero. This breaks gpib again for low total sample
count option values, but this needs to get addressed differently.
Gerhard Sittig [Sun, 24 Nov 2019 08:52:42 +0000 (09:52 +0100)]
decoder: internal 'always false' term, handle invalid skip and channel
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 is a protocol decoder for the 'ASCII' protocol used by
Amulet Technologies LCDs.
Currently some commands are not implemented yet. I also lack capture data
from a display that will use replies other than ACK and NACK.
Reads are untested as I have no suitable captures.
The PD copes with bus errors (there is an actual bug in the device I'm
reverse engineering) and most of the commands are implemented.
The unimplemented commands should generally consume the correct
number of bytes from the bus, the exception to this are the drawing
commands, because there are actually at least two revisions of them
with different payloads, that are really hard to detect in greedy
algorithm.
Uwe Hermann [Sat, 23 Nov 2019 16:45:23 +0000 (17:45 +0100)]
Fix three -fsanitize=undefined issues.
instance.c:62:2: runtime error: null pointer passed as argument 1, which is declared to never be null
instance.c:858:45: runtime error: shift exponent -1 is negative
instance.c:836:45: runtime error: shift exponent -1 is negative
Uwe Hermann [Sat, 23 Nov 2019 15:42:44 +0000 (16:42 +0100)]
Avoid using Py_IncRef/Py_DecRef for consistency.
We currently use a mix of Py_IncRef/Py_DecRef and Py_XINCREF/Py_XDECREF
or Py_INCREF/Py_DECREF in the code-base. Only use the latter variants
for the time being (for consistency).
Direct leak of 317 byte(s) in 6 object(s) allocated from:
#0 0x7f08e4809538 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
#1 0x7f08e3f37622 in PyUnicode_New ../Objects/unicodeobject.c:1365
Direct leak of 28 byte(s) in 1 object(s) allocated from:
#0 0x7f08e4809538 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
#1 0x7f08e3f7e1a5 in _PyLong_New ../Objects/longobject.c:275
Direct leak of 24 byte(s) in 1 object(s) allocated from:
#0 0x7f08e4809538 in __interceptor_malloc ../../../../src/libsanitizer/asan/asan_malloc_linux.cc:144
#1 0x7f08e3f91521 in PyFloat_FromDouble ../Objects/floatobject.c:122
SUMMARY: AddressSanitizer: 369 byte(s) leaked in 8 allocation(s).
session
Uwe Hermann [Tue, 12 Nov 2019 21:20:45 +0000 (22:20 +0100)]
uart: Add [rx|tx]_packet_len options.
Similar to the recently added [rx|tx]_packet_delimiter options, these
emit summary annotations ("packets") when a certain number of data values
have been decoded.
This is a convenience feature which can be useful when a user wants to
view data which doesn't have a specified delimiter value (as last data
value in the "packet"), but rather fixed-length "packets".
This is just an (intentionally very simple) helper/convenience improvement
and is NOT meant to replace "proper" stacked decoders for UART-based protocols.
Uwe Hermann [Tue, 12 Nov 2019 21:03:21 +0000 (22:03 +0100)]
uart: Add [rx|tx]_packet_delimiter options.
This is a convenience feature that emits summary annotations ("packets")
that comprise all data values that were decoded until a specified delimiter
value is seen (as last data value of the "packet").
Example use-cases include ASCII data where it can be convenient to
"packetize" whenever a 10/0x0A value (newline) is seen, or some
protocols which have a fixed "marker" value (e.g. 0x55) as last
value in the "packet".
The annotations are affected by the selected 'format' option, i.e. the
user can get summaries in ASCII or hex or other formats.
This is just an (intentionally very simple) helper/convenience improvement
and is NOT meant to replace "proper" stacked decoders for UART-based protocols.
Uwe Hermann [Tue, 5 Nov 2019 21:34:44 +0000 (22:34 +0100)]
spiflash: Add "EEPROM" to descriptions.
There are various different names that these types of memories are being
referred to in the wild: SPI flash, flash chip, flash, flash EEPROM,
SPI EEPROM, serial flash, serial memory, flash memory, and various others.
In order to make UI decoder selection more useful to the user, we add
the "EEPROM" string to some of the decoder metadata fields, so the
decoder will (for example) show up in PulseView's list of decoders when
the user types "eeprom" to narrow down the listed decoders.
Andrew Gregory [Wed, 5 Dec 2018 15:31:34 +0000 (23:31 +0800)]
modbus: Make C->S and S->C configurable, add framegap option.
Change client->server and server->client to be separately configurable,
allowing decoding at both the server (where client->server is RX and
server->client is TX) and client (where client->server is TX and
server->client is RX) ends of the link. It also allows monitoring of the
bus on a single channel (where client->server and server->client are both
RX (or TX)).
When I tried to decode a bus capture, I found that when the transmitter was
turned off it generated a false start bit, which in turn resulted in a false
trailing byte from the UART decoder. This narrowed the inter-frame gap to
the point where the Modbus decoder failed to recognise a new frame. The
result was only the first frame of the capture decoded - all the rest of the
frames failed to decode. I had to reduce the frame gap to allow subsequent
frames to decode, and so made it a configurable option that defaults to the
existing gap.
Lastly, I fixed a call to puti() that incorrectly included the annotation
prefix.
Stefan Brüns [Mon, 17 Jun 2019 18:01:58 +0000 (20:01 +0200)]
usb_request: Allow configuration of BULK IN transfer display
From a protocol level, a BULK IN transfer starts when the host starts
polling the respective endpoint. For analysis, it is sometimes useful
to show when the devices starts to answer the requests.
As both are useful for different use cases (the old, default one emphasizes
the host behavior, the new one shows the endpoint/device behavior), make
the display configurable.
Stefan Brüns [Mon, 17 Jun 2019 17:51:29 +0000 (19:51 +0200)]
usb_request: Fix some decoding errors
Append OUT data only if it has been ACKed. OUT transfers (BULK OUT or
CONTROL transfer DATA stage) are typically NACKed to create backpressure.
Always keep IN and OUT transfers separate. On the physical layer, the
endpoint number only uses 4 bits, and IN and OUT use separate tokens.
In case the transfer is an IN transfer, set the high bit as used in the
endpoint descriptors (i.e. 0x81 is IN enpoint 1, 0x01 is OUT endpoint 1).