Improve robustness of the DCF77 decoder. Cope with "neiter 0 nor 1" bit
values (glitches can break the detection of pulse widths), as well as
unexpected bit numbers (more than 59 pulses per minute, can be a
follow-up error after e.g. glitches break one long pulse into two short
pulses). Do not process this invalid data, do emit error annotations.
self.putx([16, ['Date parity: %s' % s, 'DP: %s' % s]])
self.datebits = []
else:
self.putx([16, ['Date parity: %s' % s, 'DP: %s' % s]])
self.datebits = []
else:
- raise Exception('Invalid DCF77 bit: %d' % c)
+ self.putx([19, ['Invalid DCF77 bit: %d' % c,
+ 'Invalid bit: %d' % c, 'Inv: %d' % c]])
def decode(self):
if not self.samplerate:
def decode(self):
if not self.samplerate:
elif len_high_ms in range(161, 260 + 1):
bit = 1
else:
elif len_high_ms in range(161, 260 + 1):
bit = 1
else:
- bit = -1 # TODO: Error?
- # There's no bit 59, make sure none is decoded.
- if bit in (0, 1) and self.bitcount in range(0, 58 + 1):
self.handle_dcf77_bit(bit)
self.bitcount += 1
self.handle_dcf77_bit(bit)
self.bitcount += 1
+ else:
+ self.putx([19, ['Invalid bit timing', 'Inv timing', 'Inv']])
self.state = 'WAIT FOR RISING EDGE'
self.state = 'WAIT FOR RISING EDGE'