summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--decoders/can/pd.py7
-rw-r--r--decoders/dcf77/pd.py7
-rw-r--r--decoders/guess_bitrate/pd.py7
-rw-r--r--decoders/i2c/pd.py2
-rw-r--r--decoders/i2s/pd.py7
-rw-r--r--decoders/ir_nec/pd.py7
-rw-r--r--decoders/ir_rc5/pd.py7
-rw-r--r--decoders/onewire_link/pd.py7
-rw-r--r--decoders/spi/pd.py2
-rw-r--r--decoders/uart/pd.py7
-rw-r--r--decoders/usb_signalling/pd.py7
11 files changed, 47 insertions, 20 deletions
diff --git a/decoders/can/pd.py b/decoders/can/pd.py
index e425575..f80ebc6 100644
--- a/decoders/can/pd.py
+++ b/decoders/can/pd.py
@@ -20,6 +20,9 @@
import sigrokdecode as srd
+class SamplerateError(Exception):
+ pass
+
class Decoder(srd.Decoder):
api_version = 2
id = 'can'
@@ -358,8 +361,8 @@ class Decoder(srd.Decoder):
self.curbit += 1
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, pins) in data:
(can_rx,) = pins
diff --git a/decoders/dcf77/pd.py b/decoders/dcf77/pd.py
index 3f0ff50..14d8637 100644
--- a/decoders/dcf77/pd.py
+++ b/decoders/dcf77/pd.py
@@ -25,6 +25,9 @@ import calendar
def bcd2int(b):
return (b & 0x0f) + ((b >> 4) * 10)
+class SamplerateError(Exception):
+ pass
+
class Decoder(srd.Decoder):
api_version = 2
id = 'dcf77'
@@ -245,8 +248,8 @@ class Decoder(srd.Decoder):
raise Exception('Invalid DCF77 bit: %d' % c)
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, pins) in data:
# Ignore identical samples early on (for performance reasons).
diff --git a/decoders/guess_bitrate/pd.py b/decoders/guess_bitrate/pd.py
index e86316f..1d7434b 100644
--- a/decoders/guess_bitrate/pd.py
+++ b/decoders/guess_bitrate/pd.py
@@ -20,6 +20,9 @@
import sigrokdecode as srd
+class SamplerateError(Exception):
+ pass
+
class Decoder(srd.Decoder):
api_version = 2
id = 'guess_bitrate'
@@ -53,8 +56,8 @@ class Decoder(srd.Decoder):
self.samplerate = value;
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, pins) in data:
data = pins[0]
diff --git a/decoders/i2c/pd.py b/decoders/i2c/pd.py
index ced58cd..b46fd1d 100644
--- a/decoders/i2c/pd.py
+++ b/decoders/i2c/pd.py
@@ -269,7 +269,7 @@ class Decoder(srd.Decoder):
def decode(self, ss, es, data):
if not self.samplerate:
- raise SamplerateError("Cannot decode without samplerate.")
+ raise SamplerateError('Cannot decode without samplerate.')
for (self.samplenum, pins) in data:
# Ignore identical samples early on (for performance reasons).
diff --git a/decoders/i2s/pd.py b/decoders/i2s/pd.py
index 989a5a5..dc42a4e 100644
--- a/decoders/i2s/pd.py
+++ b/decoders/i2s/pd.py
@@ -33,6 +33,9 @@ Packet:
<value>: integer
'''
+class SamplerateError(Exception):
+ pass
+
class Decoder(srd.Decoder):
api_version = 2
id = 'i2s'
@@ -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.
diff --git a/decoders/ir_nec/pd.py b/decoders/ir_nec/pd.py
index d9091be..ce2e9f2 100644
--- a/decoders/ir_nec/pd.py
+++ b/decoders/ir_nec/pd.py
@@ -21,6 +21,9 @@
import sigrokdecode as srd
from .lists import *
+class SamplerateError(Exception):
+ pass
+
class Decoder(srd.Decoder):
api_version = 2
id = 'ir_nec'
@@ -148,8 +151,8 @@ class Decoder(srd.Decoder):
return ret == 0
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, pins) in data:
self.ir = pins[0]
diff --git a/decoders/ir_rc5/pd.py b/decoders/ir_rc5/pd.py
index 885b29d..bd99826 100644
--- a/decoders/ir_rc5/pd.py
+++ b/decoders/ir_rc5/pd.py
@@ -21,6 +21,9 @@
import sigrokdecode as srd
from .lists import *
+class SamplerateError(Exception):
+ pass
+
class Decoder(srd.Decoder):
api_version = 2
id = 'ir_rc5'
@@ -133,8 +136,8 @@ class Decoder(srd.Decoder):
self.state = 'IDLE'
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, pins) in data:
self.ir = pins[0]
diff --git a/decoders/onewire_link/pd.py b/decoders/onewire_link/pd.py
index 9503d15..93cd51a 100644
--- a/decoders/onewire_link/pd.py
+++ b/decoders/onewire_link/pd.py
@@ -20,6 +20,9 @@
import sigrokdecode as srd
+class SamplerateError(Exception):
+ pass
+
class Decoder(srd.Decoder):
api_version = 2
id = 'onewire_link'
@@ -185,8 +188,8 @@ class Decoder(srd.Decoder):
% (time_min*1000000, time_max*1000000)]])
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, (owr, pwr)) in data:
# State machine.
if self.state == 'WAIT FOR FALLING EDGE':
diff --git a/decoders/spi/pd.py b/decoders/spi/pd.py
index 5c7df19..96c0689 100644
--- a/decoders/spi/pd.py
+++ b/decoders/spi/pd.py
@@ -265,7 +265,7 @@ class Decoder(srd.Decoder):
def decode(self, ss, es, data):
if not self.samplerate:
- raise SamplerateError("Cannot decode without samplerate.")
+ raise SamplerateError('Cannot decode without samplerate.')
# Either MISO or MOSI can be omitted (but not both). CS# is optional.
for (self.samplenum, pins) in data:
diff --git a/decoders/uart/pd.py b/decoders/uart/pd.py
index ff8a516..da5e303 100644
--- a/decoders/uart/pd.py
+++ b/decoders/uart/pd.py
@@ -69,6 +69,9 @@ def parity_ok(parity_type, parity_bit, data, num_data_bits):
else:
raise Exception('Invalid parity type: %d' % parity_type)
+class SamplerateError(Exception):
+ pass
+
class Decoder(srd.Decoder):
api_version = 2
id = 'uart'
@@ -327,8 +330,8 @@ class Decoder(srd.Decoder):
self.putg([rxtx + 4, ['Stop bit', 'Stop', 'T']])
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, pins) in data:
# Note: Ignoring identical samples here for performance reasons
diff --git a/decoders/usb_signalling/pd.py b/decoders/usb_signalling/pd.py
index a21fe8d..59db0d4 100644
--- a/decoders/usb_signalling/pd.py
+++ b/decoders/usb_signalling/pd.py
@@ -73,6 +73,9 @@ sym_idx = {
'SE1': 3,
}
+class SamplerateError(Exception):
+ pass
+
class Decoder(srd.Decoder):
api_version = 2
id = 'usb_signalling'
@@ -217,8 +220,8 @@ class Decoder(srd.Decoder):
self.oldsym = sym
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, pins) in data:
# State machine.
if self.state == 'IDLE':