summaryrefslogtreecommitdiff
path: root/decoders/dcf77
diff options
context:
space:
mode:
Diffstat (limited to 'decoders/dcf77')
-rw-r--r--decoders/dcf77/pd.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/decoders/dcf77/pd.py b/decoders/dcf77/pd.py
index a31c313..57cd448 100644
--- a/decoders/dcf77/pd.py
+++ b/decoders/dcf77/pd.py
@@ -65,6 +65,7 @@ class Decoder(srd.Decoder):
]
def __init__(self, **kwargs):
+ self.samplerate = None
self.state = 'WAIT FOR RISING EDGE'
self.oldpins = None
self.oldval = None
@@ -74,11 +75,14 @@ class Decoder(srd.Decoder):
self.bitcount = 0 # Counter for the DCF77 bits (0..58)
self.dcf77_bitnumber_is_known = 0
- def start(self, metadata):
- self.samplerate = metadata['samplerate']
+ def start(self):
# self.out_proto = self.add(srd.OUTPUT_PROTO, 'dcf77')
self.out_ann = self.add(srd.OUTPUT_ANN, 'dcf77')
+ def metadata(self, key, value):
+ if key == srd.SRD_CONF_SAMPLERATE:
+ self.samplerate = value
+
def report(self):
pass
@@ -244,6 +248,8 @@ class Decoder(srd.Decoder):
raise Exception('Invalid DCF77 bit: %d' % c)
def decode(self, ss, es, data):
+ if self.samplerate is None:
+ raise Exception("Cannot decode without samplerate.")
for (self.samplenum, pins) in data:
# Ignore identical samples early on (for performance reasons).