summaryrefslogtreecommitdiff
path: root/decoders/dcf77
diff options
context:
space:
mode:
authorBert Vermeulen <bert@biot.com>2013-10-30 22:25:45 +0100
committerBert Vermeulen <bert@biot.com>2013-10-30 22:41:22 +0100
commitf372d597739a30e0106aebc8225c1edebf6d93e3 (patch)
treef4fccac01ff2de612c1ee6163cfe19491c1cd2be /decoders/dcf77
parented41649709abc02362df526cbd725775000e8199 (diff)
downloadlibsigrokdecode-f372d597739a30e0106aebc8225c1edebf6d93e3.tar.gz
libsigrokdecode-f372d597739a30e0106aebc8225c1edebf6d93e3.zip
Receive samplerate via metadata(), not start()
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).