X-Git-Url: http://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoders%2Fuart%2Fpd.py;h=c3d1b62dbc5849f16fc4c5cf91f322cf8dfd36f9;hp=d71fc23115760c06fd9e2eef56ab64ba1dc47770;hb=0bb7bcf316b528acbe0ef82f4c1e310e756074bc;hpb=e54f222c4edf55a379e5b3ad892cf671ace83e48 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 +## Copyright (C) 2011-2014 Uwe Hermann ## ## 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':