X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=decoders%2Fuart%2Fpd.py;h=151cae424fefefde3774dd2cdf4c00f314ef3679;hb=c1fc50b1256dba3bfad7e769691f11b729601b28;hp=d42a5d42a4c9a89537e4b78b773dcc1cf24db3fb;hpb=2f37032807e19bc93b7f3223e1568db46318790c;p=libsigrokdecode.git diff --git a/decoders/uart/pd.py b/decoders/uart/pd.py index d42a5d4..151cae4 100644 --- a/decoders/uart/pd.py +++ b/decoders/uart/pd.py @@ -138,6 +138,7 @@ class Decoder(srd.Decoder): ('tx', 'TX dump'), ('rxtx', 'RX/TX dump'), ) + idle_state = ['WAIT FOR START BIT', 'WAIT FOR START BIT'] def putx(self, rxtx, data): s, halfbit = self.startsample[rxtx], self.bit_width / 2.0 @@ -159,7 +160,7 @@ class Decoder(srd.Decoder): s, halfbit = self.startsample[rxtx], self.bit_width / 2.0 self.put(s - floor(halfbit), self.samplenum + ceil(halfbit), self.out_binary, data) - def __init__(self, **kwargs): + def __init__(self): self.samplerate = None self.samplenum = 0 self.frame_start = [-1, -1] @@ -171,7 +172,7 @@ class Decoder(srd.Decoder): self.startsample = [-1, -1] self.state = ['WAIT FOR START BIT', 'WAIT FOR START BIT'] self.oldbit = [1, 1] - self.oldpins = [1, 1] + self.oldpins = [-1, -1] self.databits = [[], []] def start(self): @@ -287,7 +288,7 @@ class Decoder(srd.Decoder): self.putbin(rxtx, [rxtx, bytes([b])]) self.putbin(rxtx, [2, bytes([b])]) - self.databits = [[], []] + self.databits[rxtx] = [] def get_parity_bit(self, rxtx, signal): # If no parity is used/configured, skip to the next state immediately. @@ -338,10 +339,12 @@ class Decoder(srd.Decoder): raise SamplerateError('Cannot decode without samplerate.') for (self.samplenum, pins) in data: - # Note: Ignoring identical samples here for performance reasons - # is not possible for this PD, at least not in the current state. - # if self.oldpins == pins: - # continue + # We want to skip identical samples for performance reasons but, + # for now, we can only do that when we are in the idle state + # (meaning both channels are waiting for the start bit). + if self.state == self.idle_state and self.oldpins == pins: + continue + self.oldpins, (rx, tx) = pins, pins if self.options['invert_rx'] == 'yes':