diff options
author | Bert Vermeulen <bert@biot.com> | 2013-10-30 22:25:45 +0100 |
---|---|---|
committer | Bert Vermeulen <bert@biot.com> | 2013-10-30 22:41:22 +0100 |
commit | f372d597739a30e0106aebc8225c1edebf6d93e3 (patch) | |
tree | f4fccac01ff2de612c1ee6163cfe19491c1cd2be /decoders/onewire_link | |
parent | ed41649709abc02362df526cbd725775000e8199 (diff) | |
download | libsigrokdecode-f372d597739a30e0106aebc8225c1edebf6d93e3.tar.gz libsigrokdecode-f372d597739a30e0106aebc8225c1edebf6d93e3.zip |
Receive samplerate via metadata(), not start()
Diffstat (limited to 'decoders/onewire_link')
-rw-r--r-- | decoders/onewire_link/pd.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/decoders/onewire_link/pd.py b/decoders/onewire_link/pd.py index a309cc3..4a826d1 100644 --- a/decoders/onewire_link/pd.py +++ b/decoders/onewire_link/pd.py @@ -80,6 +80,7 @@ class Decoder(srd.Decoder): self.put(self.rise, self.samplenum, self.out_ann, data) def __init__(self, **kwargs): + self.samplerate = None self.samplenum = 0 self.state = 'WAIT FOR FALLING EDGE' self.present = 0 @@ -90,11 +91,14 @@ class Decoder(srd.Decoder): self.fall = 0 self.rise = 0 - def start(self, metadata): + def start(self): self.out_proto = self.add(srd.OUTPUT_PROTO, 'onewire_link') self.out_ann = self.add(srd.OUTPUT_ANN, 'onewire_link') - self.samplerate = metadata['samplerate'] + def metadata(self, key, value): + if key != srd.SRD_CONF_SAMPLERATE: + return + self.samplerate = value # Check if samplerate is appropriate. if self.options['overdrive'] == 'yes': @@ -173,6 +177,8 @@ class Decoder(srd.Decoder): pass def decode(self, ss, es, data): + if self.samplerate is None: + raise Exception("Cannot decode without samplerate.") for (self.samplenum, (owr, pwr)) in data: # State machine. if self.state == 'WAIT FOR FALLING EDGE': |