]> sigrok.org Git - libsigrokdecode.git/blobdiff - decoders/i2s/pd.py
uart/i2cfilter: Don't check multiple-choice options.
[libsigrokdecode.git] / decoders / i2s / pd.py
index eb6a56050115b3c34e078a6302401b4dffdcd365..dc42a4e5d1900a84d892554ed655006fd8b56781 100644 (file)
@@ -33,8 +33,11 @@ Packet:
 <value>: integer
 '''
 
+class SamplerateError(Exception):
+    pass
+
 class Decoder(srd.Decoder):
-    api_version = 1
+    api_version = 2
     id = 'i2s'
     name = 'I²S'
     longname = 'Integrated Interchip Sound'
@@ -128,8 +131,8 @@ class Decoder(srd.Decoder):
         return bytes([lo, hi])
 
     def decode(self, ss, es, data):
-        if self.samplerate is None:
-            raise Exception("Cannot decode without samplerate.")
+        if not self.samplerate:
+            raise SamplerateError('Cannot decode without samplerate.')
         for self.samplenum, (sck, ws, sd) in data:
 
             # Ignore sample if the bit clock hasn't changed.