From: Uwe Hermann Date: Wed, 9 Jul 2014 15:31:32 +0000 (+0200) Subject: uart/i2cfilter: Don't check multiple-choice options. X-Git-Tag: libsigrokdecode-0.4.0~205 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=22fc7ace72f3165c98208a8f544156e04a709639;p=libsigrokdecode.git uart/i2cfilter: Don't check multiple-choice options. For options which only have a limited set of valid values, we don't need to check (in the PD) whether a valid value was supplied, since the backend can do that for us. --- diff --git a/decoders/i2cfilter/pd.py b/decoders/i2cfilter/pd.py index 895cc17..1a9f433 100644 --- a/decoders/i2cfilter/pd.py +++ b/decoders/i2cfilter/pd.py @@ -47,8 +47,6 @@ class Decoder(srd.Decoder): self.out_python = self.register(srd.OUTPUT_PYTHON, proto_id='i2c') if self.options['address'] not in range(0, 127 + 1): raise Exception('Invalid slave (must be 0..127).') - if self.options['direction'] not in ('both', 'read', 'write'): - raise Exception('Invalid direction (valid: read/write/both).') # Grab I²C packets into a local cache, until an I²C STOP condition # packet comes along. At some point before that STOP condition, there diff --git a/decoders/uart/pd.py b/decoders/uart/pd.py index da5e303..63ea50d 100644 --- a/decoders/uart/pd.py +++ b/decoders/uart/pd.py @@ -66,8 +66,6 @@ def parity_ok(parity_type, parity_bit, data, num_data_bits): return (ones % 2) == 1 elif parity_type == 'even': return (ones % 2) == 0 - else: - raise Exception('Invalid parity type: %d' % parity_type) class SamplerateError(Exception): pass @@ -242,12 +240,9 @@ class Decoder(srd.Decoder): self.databyte[rxtx] >>= 1 self.databyte[rxtx] |= \ (signal << (self.options['num_data_bits'] - 1)) - elif self.options['bit_order'] == 'msb-first': + else: self.databyte[rxtx] <<= 1 self.databyte[rxtx] |= (signal << 0) - else: - raise Exception('Invalid bit order value: %s', - self.options['bit_order']) self.putg([rxtx + 12, ['%d' % signal]]) @@ -277,8 +272,6 @@ class Decoder(srd.Decoder): self.putx(rxtx, [rxtx, [oct(b)[2:].zfill(3)]]) elif f == 'bin': self.putx(rxtx, [rxtx, [bin(b)[2:].zfill(8)]]) - else: - raise Exception('Invalid data format option: %s' % f) self.putbin(rxtx, (rxtx, bytes([b]))) self.putbin(rxtx, (2, bytes([b])))