summaryrefslogtreecommitdiff
path: root/decoders/spi
diff options
context:
space:
mode:
authorJosef Gajdusek <atx@atx.name>2018-08-17 16:35:50 +0200
committerUwe Hermann <uwe@hermann-uwe.de>2018-08-30 11:49:32 +0200
commitf04db50ab7bbc59b7668396500b92ae2d3418f0e (patch)
tree7be92f53650ba16edfb59032b5a69b91fdb7ff12 /decoders/spi
parenta27981c145cd9a3709673339dc455f3a0d5c3745 (diff)
downloadlibsigrokdecode-f04db50ab7bbc59b7668396500b92ae2d3418f0e.tar.gz
libsigrokdecode-f04db50ab7bbc59b7668396500b92ae2d3418f0e.zip
spi: Create the out_bitrate annotation unconditionally
The start() method is called before the metadata() method, which results in the the out_bitrate instance variable never getting created and ending up as an AttributeError when decoding. (observed with sigrok-cli and VCD file as the input)
Diffstat (limited to 'decoders/spi')
-rw-r--r--decoders/spi/pd.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/decoders/spi/pd.py b/decoders/spi/pd.py
index 9beb4e6..85bb1cb 100644
--- a/decoders/spi/pd.py
+++ b/decoders/spi/pd.py
@@ -137,19 +137,18 @@ class Decoder(srd.Decoder):
self.cs_was_deasserted = False
self.have_cs = self.have_miso = self.have_mosi = None
- def metadata(self, key, value):
- if key == srd.SRD_CONF_SAMPLERATE:
- self.samplerate = value
-
def start(self):
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:
- self.out_bitrate = self.register(srd.OUTPUT_META,
- meta=(int, 'Bitrate', 'Bitrate during transfers'))
+ self.out_bitrate = self.register(srd.OUTPUT_META,
+ meta=(int, 'Bitrate', 'Bitrate during transfers'))
self.bw = (self.options['wordsize'] + 7) // 8
+ def metadata(self, key, value):
+ if key == srd.SRD_CONF_SAMPLERATE:
+ self.samplerate = value
+
def putw(self, data):
self.put(self.ss_block, self.samplenum, self.out_ann, data)