('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
def putbin(self, rxtx, data):
s, halfbit = self.startsample[rxtx], self.bit_width / 2.0
- self.put(s - floor(halfbit), self.samplenum + ceil(halfbit), self.out_bin, data)
+ 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]
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):
self.out_python = self.register(srd.OUTPUT_PYTHON)
- self.out_bin = self.register(srd.OUTPUT_BINARY)
+ self.out_binary = self.register(srd.OUTPUT_BINARY)
self.out_ann = self.register(srd.OUTPUT_ANN)
def metadata(self, key, value):
elif f == 'bin':
self.putx(rxtx, [rxtx, [bin(b)[2:].zfill(8)]])
- self.putbin(rxtx, (rxtx, bytes([b])))
- self.putbin(rxtx, (2, bytes([b])))
+ 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.
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':