diff options
author | Gerhard Sittig <gerhard.sittig@gmx.net> | 2018-04-16 21:15:13 +0200 |
---|---|---|
committer | Uwe Hermann <uwe@hermann-uwe.de> | 2018-04-24 21:28:59 +0200 |
commit | cb67584195ed543adf090c9299d28e9f7f89f861 (patch) | |
tree | 85bb8e09663ba9925a3398d6bd54ba2952d48cd8 /decoders | |
parent | 40935087ca8a2c63fb224228c3f7dcbe74d48d20 (diff) | |
download | libsigrokdecode-cb67584195ed543adf090c9299d28e9f7f89f861.tar.gz libsigrokdecode-cb67584195ed543adf090c9299d28e9f7f89f861.zip |
dcf77: annotate unexpected bit numbers and values, do not abort execution
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.
Diffstat (limited to 'decoders')
-rw-r--r-- | decoders/dcf77/pd.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/decoders/dcf77/pd.py b/decoders/dcf77/pd.py index 3a97d82..7b09ce6 100644 --- a/decoders/dcf77/pd.py +++ b/decoders/dcf77/pd.py @@ -249,7 +249,8 @@ class Decoder(srd.Decoder): 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: @@ -298,11 +299,12 @@ class Decoder(srd.Decoder): elif len_high_ms in range(161, 260 + 1): bit = 1 else: - bit = -1 # TODO: Error? + bit = -1 - # There's no bit 59, make sure none is decoded. - if bit in (0, 1) and self.bitcount in range(0, 58 + 1): + if bit in (0, 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' |