diff options
author | Uwe Hermann <uwe@hermann-uwe.de> | 2014-01-20 17:43:01 +0100 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2014-01-23 20:02:38 +0100 |
commit | 0bb7bcf316b528acbe0ef82f4c1e310e756074bc (patch) | |
tree | e76ca94d34e44c6b8c0cb864cfc28da26b8619df /decoders/uart | |
parent | e54f222c4edf55a379e5b3ad892cf671ace83e48 (diff) | |
download | libsigrokdecode-0bb7bcf316b528acbe0ef82f4c1e310e756074bc.tar.gz libsigrokdecode-0bb7bcf316b528acbe0ef82f4c1e310e756074bc.zip |
uart: Add binaryout/dump support, drop obsolete 'uart_dump' PD.
The functionality of the preliminary 'uart_dump' PD is now available
in the proper 'uart' PD, via the OUTPUT_BINARY mechanism that frontends
can use to dump decoded data (in various formats) to a file, or pipe it
into other applications, and so on.
Old sigrok-cli example usage:
$ sigrok-cli -i foo.sr -P uart:rx=0:tx=1,uart_dump:filename=bootlog.txt
New sigrok-cli example usage:
$ sigrok-cli -i foo.sr -P uart:rx=0:tx=1 -B uart=rxtx > bootlog.txt
New sigrok-cli example usage (piping into other applications):
$ sigrok-cli -i foo.sr -P uart:rx=0:tx=1 -B uart=rxtx | grep "whatever"
Diffstat (limited to 'decoders/uart')
-rw-r--r-- | decoders/uart/pd.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/decoders/uart/pd.py b/decoders/uart/pd.py index d71fc23..c3d1b62 100644 --- a/decoders/uart/pd.py +++ b/decoders/uart/pd.py @@ -1,7 +1,7 @@ ## ## This file is part of the libsigrokdecode project. ## -## Copyright (C) 2011-2013 Uwe Hermann <uwe@hermann-uwe.de> +## Copyright (C) 2011-2014 Uwe Hermann <uwe@hermann-uwe.de> ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -104,6 +104,11 @@ class Decoder(srd.Decoder): ['Stop bits', 'UART stop bits'], ['Warnings', 'Warnings'], ] + binary = ( + ('rx', 'RX dump'), + ('tx', 'TX dump'), + ('rxtx', 'RX/TX dump'), + ) def putx(self, rxtx, data): s, halfbit = self.startsample[rxtx], int(self.bit_width / 2) @@ -117,6 +122,10 @@ class Decoder(srd.Decoder): s, halfbit = self.samplenum, int(self.bit_width / 2) self.put(s - halfbit, s + halfbit, self.out_proto, data) + def putbin(self, rxtx, data): + s, halfbit = self.startsample[rxtx], int(self.bit_width / 2) + self.put(s - halfbit, self.samplenum + halfbit, self.out_bin, data) + def __init__(self, **kwargs): self.samplerate = None self.samplenum = 0 @@ -133,6 +142,7 @@ class Decoder(srd.Decoder): def start(self): self.out_proto = self.register(srd.OUTPUT_PYTHON) + self.out_bin = self.register(srd.OUTPUT_BINARY) self.out_ann = self.register(srd.OUTPUT_ANN) def metadata(self, key, value): @@ -235,6 +245,9 @@ class Decoder(srd.Decoder): else: raise Exception('Invalid data format option: %s' % f) + self.putbin(rxtx, (rxtx, bytes([b]))) + self.putbin(rxtx, (2, bytes([b]))) + def get_parity_bit(self, rxtx, signal): # If no parity is used/configured, skip to the next state immediately. if self.options['parity_type'] == 'none': |