diff options
author | Gerhard Sittig <gerhard.sittig@gmx.net> | 2018-01-28 20:49:48 +0100 |
---|---|---|
committer | Gerhard Sittig <gerhard.sittig@gmx.net> | 2018-01-28 20:49:48 +0100 |
commit | 15a8a05595c72d328abdea8e3b23f1b558cc46bf (patch) | |
tree | df65ff2c6163724aa5f49275086963fa3660b6a5 /decoders/usb_request | |
parent | 956721de58552b05776c8613449f2907196e61e9 (diff) | |
download | libsigrokdecode-15a8a05595c72d328abdea8e3b23f1b558cc46bf.tar.gz libsigrokdecode-15a8a05595c72d328abdea8e3b23f1b558cc46bf.zip |
graycode, morse, pwm, usb_request, wiegand: cope with absent sample rate
Improve robustness of some more protocol decoders. Few of them never
checked for the availability of a sample rate in the first place, others
checked for the presence of a spec but would not cope with a value of 0.
Some checked the value only after processing it, which could result in
runtime errors.
This change is motivated by bug #1118.
Diffstat (limited to 'decoders/usb_request')
-rw-r--r-- | decoders/usb_request/pd.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/decoders/usb_request/pd.py b/decoders/usb_request/pd.py index a480284..e77debc 100644 --- a/decoders/usb_request/pd.py +++ b/decoders/usb_request/pd.py @@ -171,7 +171,8 @@ class Decoder(srd.Decoder): def metadata(self, key, value): if key == srd.SRD_CONF_SAMPLERATE: self.samplerate = value - self.secs_per_sample = float(1) / float(self.samplerate) + if self.samplerate: + self.secs_per_sample = float(1) / float(self.samplerate) def start(self): self.out_binary = self.register(srd.OUTPUT_BINARY) |