summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
authorGerhard Sittig <gerhard.sittig@gmx.net>2020-07-25 17:51:07 +0200
committerGerhard Sittig <gerhard.sittig@gmx.net>2020-07-25 23:16:01 +0200
commitb3f83fda31bfeef63b0ed5610c7b2986ad80dcc5 (patch)
tree1a492564fb1476bd1ecfb23709022ad78af48878 /decoders
parent34ed4b3fb179f4ff7972879534a7395c90fe8d84 (diff)
downloadlibsigrokdecode-b3f83fda31bfeef63b0ed5610c7b2986ad80dcc5.tar.gz
libsigrokdecode-b3f83fda31bfeef63b0ed5610c7b2986ad80dcc5.zip
ir_nec: only use the samplerate after receiving the value
The metadata() method unconditionally referenced the samplerate even though the value is only available conditionally. Move the references to a location after the samplerate presence check.
Diffstat (limited to 'decoders')
-rw-r--r--decoders/ir_nec/pd.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/decoders/ir_nec/pd.py b/decoders/ir_nec/pd.py
index 2e547d5..07323a7 100644
--- a/decoders/ir_nec/pd.py
+++ b/decoders/ir_nec/pd.py
@@ -133,6 +133,8 @@ class Decoder(srd.Decoder):
def metadata(self, key, value):
if key == srd.SRD_CONF_SAMPLERATE:
self.samplerate = value
+
+ def calc_rate(self):
self.tolerance = 0.05 # +/-5%
self.lc = int(self.samplerate * 0.0135) - 1 # 13.5ms
self.rc = int(self.samplerate * 0.01125) - 1 # 11.25ms
@@ -177,6 +179,7 @@ class Decoder(srd.Decoder):
def decode(self):
if not self.samplerate:
raise SamplerateError('Cannot decode without samplerate.')
+ self.calc_rate()
cd_count = None
if self.options['cd_freq']: