X-Git-Url: https://sigrok.org/gitweb/?p=libsigrokdecode.git;a=blobdiff_plain;f=decoders%2Fuart.py;h=9243bbc3e33741e38ec09e033dd88258aa5bb3a3;hp=e2f33d7ce49360237a0b4c995744a466464d8ae0;hb=9a12a6e7af3d7091d8e35dd1c731402cb80a01b0;hpb=61132abd40fb2a69beb1873fa079f1a93a4d6534 diff --git a/decoders/uart.py b/decoders/uart.py index e2f33d7..9243bbc 100644 --- a/decoders/uart.py +++ b/decoders/uart.py @@ -125,7 +125,7 @@ # [T_PARITY_ERROR, (0, 1)] # -import sigrokdecode +import sigrokdecode as srd # States WAIT_FOR_START_BIT = 0 @@ -190,7 +190,7 @@ def parity_ok(parity_type, parity_bit, data, num_data_bits): else: raise Exception('Invalid parity type: %d' % parity_type) -class Decoder(sigrokdecode.Decoder): +class Decoder(srd.Decoder): id = 'uart' name = 'UART' longname = 'Universal Asynchronous Receiver/Transmitter (UART)' @@ -217,23 +217,20 @@ class Decoder(sigrokdecode.Decoder): # TODO: Options to invert the signal(s). # ... } - annotation = [ + annotations = [ # ANN_ASCII - ["ASCII", "TODO: description"], + ['ASCII', 'TODO: description'], # ANN_DEC - ["Decimal", "TODO: description"], + ['Decimal', 'TODO: description'], # ANN_HEX - ["Hex", "TODO: description"], + ['Hex', 'TODO: description'], # ANN_OCT - ["Octal", "TODO: description"], + ['Octal', 'TODO: description'], # ANN_BITS - ["Bits", "TODO: description"], + ['Bits', 'TODO: description'], ] def __init__(self, **kwargs): - self.out_proto = None - self.out_ann = None - # Set defaults, can be overridden in 'start'. self.baudrate = 115200 self.num_data_bits = 8 @@ -258,8 +255,8 @@ class Decoder(sigrokdecode.Decoder): def start(self, metadata): self.samplerate = metadata['samplerate'] - self.out_proto = self.output_new(sigrokdecode.SRD_OUTPUT_PROTOCOL, 'uart') - self.out_ann = self.output_new(sigrokdecode.SRD_OUTPUT_ANNOTATION, 'uart') + self.out_proto = self.add(srd.OUTPUT_PROTO, 'uart') + self.out_ann = self.add(srd.OUTPUT_ANN, 'uart') # TODO ### self.baudrate = metadata['baudrate']