]> sigrok.org Git - libsigrokdecode.git/commitdiff
spi: cope when a sample rate of 0 was configured
authorGerhard Sittig <redacted>
Sun, 28 Jan 2018 19:02:09 +0000 (20:02 +0100)
committerGerhard Sittig <redacted>
Sun, 28 Jan 2018 19:12:28 +0000 (20:12 +0100)
The explicit test for None was not good enough. Change test conditions
such that sample rates only get processed when they got specified _and_
were not zero.

This fixes bug #1118.

decoders/spi/pd.py

index 32fe8da40d71898a2853881085e3f0073754f328..9beb4e63b2642358b7447881e22a2fe0376208ed 100644 (file)
@@ -145,7 +145,7 @@ class Decoder(srd.Decoder):
         self.out_python = self.register(srd.OUTPUT_PYTHON)
         self.out_ann = self.register(srd.OUTPUT_ANN)
         self.out_binary = self.register(srd.OUTPUT_BINARY)
-        if self.samplerate is not None:
+        if self.samplerate:
             self.out_bitrate = self.register(srd.OUTPUT_META,
                     meta=(int, 'Bitrate', 'Bitrate during transfers'))
         self.bw = (self.options['wordsize'] + 7) // 8
@@ -253,7 +253,7 @@ class Decoder(srd.Decoder):
         self.putdata()
 
         # Meta bitrate.
-        if self.samplerate is not None:
+        if self.samplerate:
             elapsed = 1 / float(self.samplerate)
             elapsed *= (self.samplenum - self.ss_block + 1)
             bitrate = int(1 / elapsed * ws)