raise Exception('Invalid DCF77 bit: %d' % c)
def decode(self, ss, es, data):
- for samplenum, (val) in data: # TODO: Handle optional PON.
-
- self.samplenum += 1 # FIXME. Use samplenum. Off-by-one?
+ for (self.samplenum, (val)) in data: # TODO: Handle optional PON.
if self.state == 'WAIT FOR RISING EDGE':
# Wait until the next rising edge occurs.
super(Decoder, self).put(self.startsample, self.samplenum, output_id, data)
def decode(self, ss, es, data):
- for samplenum, (scl, sda) in data:
- self.samplenum = samplenum
+ for (self.samplenum, (scl, sda)) in data:
# First sample: Save SCL/SDA value.
if self.oldscl == None:
def decode(self, ss, es, data):
# TODO: Either MISO or MOSI could be optional. CS# is optional.
- for (samplenum, (miso, mosi, sck, cs)) in data:
-
- self.samplenum += 1 # FIXME
+ for (self.samplenum, (miso, mosi, sck, cs)) in data:
# Ignore sample if the clock pin hasn't changed.
if sck == self.oldsck:
# If this is the first bit, save its sample number.
if self.bitcount == 0:
- self.start_sample = samplenum
+ self.start_sample = self.samplenum
active_low = (self.options['cs_polarity'] == 'active-low')
deasserted = cs if active_low else not cs
if deasserted:
def decode(self, ss, es, data):
# TODO: Either RX or TX could be omitted (optional probe).
- for (samplenum, (rx, tx)) in data:
-
- # TODO: Start counting at 0 or 1? Increase before or after?
- self.samplenum += 1
+ for (self.samplenum, (rx, tx)) in data:
# First sample: Save RX/TX value.
if self.oldbit[RX] == None:
# Initialise decoder state.
self.sym = 'J'
- self.scount = 0
+ self.samplenum = 0
self.packet = ''
def report(self):
pass
def decode(self, ss, es, data):
- for (samplenum, (dm, dp)) in data:
-
- self.scount += 1
+ for (self.samplenum, (dm, dp)) in data:
sym = syms[dp, dm]
if sym == self.sym:
continue
- if self.scount == 1:
+ if self.samplenum == 1:
# We ignore single sample width pulses.
# I sometimes get these with the OLS.
self.sym = sym
- self.scount = 0
+ self.samplenum = 0
continue
# How many bits since the last transition?
if self.packet != '' or self.sym != 'J':
- bitcount = int((self.scount - 1) * 12000000 / self.samplerate)
+ bitcount = int((self.samplenum - 1) * 12000000 / self.samplerate)
else:
bitcount = 0
else:
# Longer than EOP, assume reset.
self.put(0, 0, self.out_ann, [0, ['RESET']])
- self.scount = 0
+ self.samplenum = 0
self.sym = sym
self.packet = ''
continue
elif bitcount > 6:
self.put(0, 0, self.out_ann, [0, ['BIT STUFF ERROR']])
- self.scount = 0
+ self.samplenum = 0
self.sym = sym