]> sigrok.org Git - libsigrokdecode.git/commitdiff
All PDs: Drop unneeded exceptions.
authorUwe Hermann <redacted>
Tue, 8 Jul 2014 19:21:03 +0000 (21:21 +0200)
committerUwe Hermann <redacted>
Wed, 9 Jul 2014 15:50:05 +0000 (17:50 +0200)
In all current PDs it is not necessary to raise an exception upon
invalid states (of the PD's state machine), since we can guarantee that
no such invalid state can ever be reached in these PDs.

24 files changed:
decoders/can/pd.py
decoders/dcf77/pd.py
decoders/ds1307/pd.py
decoders/i2cfilter/pd.py
decoders/ir_nec/pd.py
decoders/ir_rc5/pd.py
decoders/jtag/pd.py
decoders/jtag_stm32/pd.py
decoders/lm75/pd.py
decoders/lpc/pd.py
decoders/maxim_ds28ea00/pd.py
decoders/midi/pd.py
decoders/mlx90614/pd.py
decoders/mxc6225xu/pd.py
decoders/nunchuk/pd.py
decoders/onewire_link/pd.py
decoders/onewire_network/pd.py
decoders/pan1321/pd.py
decoders/parallel/pd.py
decoders/rtc8564/pd.py
decoders/sdcard_spi/pd.py
decoders/uart/pd.py
decoders/usb_packet/pd.py
decoders/usb_signalling/pd.py

index bf38b7fb9d0e1d23f9a9b83dd76ba82349ed7a84..e425575433510c3edea2512d0b707404134af4d9 100644 (file)
@@ -376,6 +376,4 @@ class Decoder(srd.Decoder):
                 if not self.reached_bit(self.curbit):
                     continue
                 self.handle_bit(can_rx)
-            else:
-                raise Exception("Invalid state: %s" % self.state)
 
index fc97a1ddd1911e5fac5d3a0c07d13dd69eda1a1c..3f0ff50c54809cef8bc04a59e61f0ba5a683bcca 100644 (file)
@@ -310,8 +310,5 @@ class Decoder(srd.Decoder):
 
                 self.state = 'WAIT FOR RISING EDGE'
 
-            else:
-                raise Exception('Invalid state: %s' % self.state)
-
             self.oldval = val
 
index 68943d475e006c4f38f363006416b433f6ee591e..1a49f9a1b31baa77ea476949c4f525ccc5d57647 100644 (file)
@@ -164,6 +164,4 @@ class Decoder(srd.Decoder):
                 self.state = 'IDLE'
             else:
                 pass # TODO?
-        else:
-            raise Exception('Invalid state: %s' % self.state)
 
index f1ac6a40211c9f4a3e2ababc63737a4b6975e7f6..895cc179045333d83280a7031edf40933612bfb4 100644 (file)
@@ -39,7 +39,6 @@ class Decoder(srd.Decoder):
     )
 
     def __init__(self, **kwargs):
-        self.state = None
         self.curslave = -1
         self.curdirection = None
         self.packets = [] # Local cache of I²C packets
index 94e232f0b743b8cef8a21d1307ee084f0e46af16..d9091bede8bd16fbe3e5e30bfe7c1e3f2dd01635 100644 (file)
@@ -199,8 +199,6 @@ class Decoder(srd.Decoder):
                 self.putremote()
                 self.ss_bit = self.ss_start = self.samplenum
                 self.state = 'IDLE'
-            else:
-                raise Exception('Invalid state: %s' % self.state)
 
             self.old_ir = self.ir
 
index 38b479327eaab9c2d6f5e4793faf7ba0c71f9833..885b29d14450728406b7848f9cd7d36bdda0ebe6 100644 (file)
@@ -168,8 +168,6 @@ class Decoder(srd.Decoder):
                 if edge == 's':
                     self.state = 'MID0'
                 bit = 0 if edge == 's' else None
-            else:
-                raise Exception('Invalid state: %s' % self.state)
 
             self.edges.append(self.samplenum)
             if bit != None:
index 25f26342183ba14bebc181fbeffeb85d4616ee58..d7b35aae87f4defe3f409f0faa00dff20e29fd93 100644 (file)
@@ -139,9 +139,6 @@ class Decoder(srd.Decoder):
         elif self.state == 'UPDATE-IR':
             self.state = 'SELECT-DR-SCAN' if (tms) else 'RUN-TEST/IDLE'
 
-        else:
-            raise Exception('Invalid state: %s' % self.state)
-
     def handle_rising_tck_edge(self, tdi, tdo, tck, tms):
         # Rising TCK edges always advance the state machine.
         self.advance_state_machine(tms)
index 5aac07f7a4e3dbba2be6e548a506864833d77da2..9113b4cc16cc4e49443ccbffc6feac81e055bd79 100644 (file)
@@ -218,6 +218,4 @@ class Decoder(srd.Decoder):
             handle_reg(cmd, val)
             if cmd == 'DR TDO': # TODO: Assumes 'DR TDI' comes before 'DR TDO'
                 self.state = 'IDLE'
-        else:
-            raise Exception('Invalid state: %s' % self.state)
 
index 89d6c61150c396530ca5fe75f9786f1db1c1a545..6655ef013eccf288bb9bc82773d2ea4c08d13c71 100644 (file)
@@ -181,6 +181,4 @@ class Decoder(srd.Decoder):
             else:
                 # self.putx([0, ['Ignoring: %s (data=%s)' % (cmd, databyte)]])
                 pass
-        else:
-            raise Exception('Invalid state: %s' % self.state)
 
index 6e0396696d6cf905e595953ce86840e8e44f3629..b626e0d338e67192103dcc63e6462a89ca85f9c5 100644 (file)
@@ -365,6 +365,4 @@ class Decoder(srd.Decoder):
                 self.handle_get_data(lad, lad_bits)
             elif self.state == 'GET TAR2':
                 self.handle_get_tar2(lad, lad_bits)
-            else:
-                raise Exception('Invalid state: %s' % self.state)
 
index 4693cd9aa2f7b3aa047362729fc513b05b1aa9e6..1e2c36a0a77ccfcd6e8999280b67a0907a17e913 100644 (file)
@@ -88,6 +88,4 @@ class Decoder(srd.Decoder):
                 self.putx([0, ['Temperature conversion status: 0x%02x' % val]])
             elif self.state in [s.upper() for s in command.values()]:
                 self.putx([0, ['TODO \'%s\': 0x%02x' % (self.state, val)]])
-            else:
-                raise Exception('Invalid state: %s' % self.state)
 
index b1f0053c912b86c44a374381ac183dedae82751c..0717dbc859e40829b39f968458bc53c0d96c4b98 100644 (file)
@@ -206,6 +206,4 @@ class Decoder(srd.Decoder):
             self.handle_syscommon_msg(pdata)
         elif self.state == 'HANDLE SYSREALTIME MSG':
             self.handle_sysrealtime_msg(pdata)
-        else:
-            raise Exception('Invalid state: %s' % self.state)
 
index edc770d4ccc4d96f63cc20c8e3e68639c5cf157d..eeb2743a794e45c0adb131c2d9bbab0bfe293f7a 100644 (file)
@@ -73,6 +73,4 @@ class Decoder(srd.Decoder):
                 self.putx([1, ['Temperature: %3.2f K' % kelvin]])
                 self.state = 'IGNORE START REPEAT'
                 self.data = []
-        else:
-            raise Exception('Invalid state: %s' % self.state)
 
index e0c857f30f62870772a225fc4098483321210f6b..c506fb6619040776e8d79c37ff8783467af8ca04 100644 (file)
@@ -213,6 +213,4 @@ class Decoder(srd.Decoder):
                 self.state = 'IDLE'
             else:
                 pass # TODO?
-        else:
-            raise Exception('Invalid state: %s' % self.state)
 
index 95d7bdbd690153cdca538f7943a8dbc954033bbb..8ed98e66e092447ca7705ad6c5ded3d23080b29d 100644 (file)
@@ -202,6 +202,4 @@ class Decoder(srd.Decoder):
             else:
                 # self.putx([14, ['Ignoring: %s (data=%s)' % (cmd, databyte)]])
                 pass
-        else:
-            raise Exception('Invalid state: %s' % self.state)
 
index 3641b9849bde1eb9c904be0f9d675e3caaa35bb7..9503d15b93fb7c80eca3144b1728652fb3db857c 100644 (file)
@@ -278,5 +278,3 @@ class Decoder(srd.Decoder):
 
                 # Wait for next slot.
                 self.state = 'WAIT FOR FALLING EDGE'
-            else:
-                raise Exception('Invalid state: %s' % self.state)
index 23402a63ebae8dc86147b0f9a458cfebc8439478..5c836c2db845b545750c3336bc3467ebcaabfa6d 100644 (file)
@@ -126,8 +126,6 @@ class Decoder(srd.Decoder):
             if self.onewire_collect(8, val, ss, es) == 0:
                 return
             self.putx([0, ['ROM error data: 0x%02x' % self.data]])
-        else:
-            raise Exception('Invalid state: %s' % self.state)
 
     # Data collector.
     def onewire_collect(self, length, val, ss, es):
index d173e1c71de5e52b0bb2d4e903e85c894e9c62ef..7edd1c893b07a091ab4a9477a190dd4b480ebaad 100644 (file)
@@ -154,8 +154,6 @@ class Decoder(srd.Decoder):
             self.handle_device_reply(rxtx, self.cmd[rxtx][:-2])
         elif rxtx == TX:
             self.handle_host_command(rxtx, self.cmd[rxtx][:-2])
-        else:
-            raise Exception('Invalid rxtx value: %d' % rxtx)
 
         self.cmd[rxtx] = ''
 
index 03b5e2fb03da6dec2ecb366f9fa06c179337d061..0b512c8d80a1e6496aa25e064e8bdbb3ff423950 100644 (file)
@@ -92,7 +92,6 @@ class Decoder(srd.Decoder):
         self.oldpins = None
         self.ss_item = self.es_item = None
         self.first = True
-        self.state = 'IDLE'
 
     def start(self):
         self.out_python = self.register(srd.OUTPUT_PYTHON)
@@ -181,12 +180,8 @@ class Decoder(srd.Decoder):
                 continue
             self.oldpins = pins
 
-            # State machine.
-            if self.state == 'IDLE':
-                if pins[0] not in (0, 1):
-                    self.handle_bits(pins[1:])
-                else:
-                    self.find_clk_edge(pins[0], pins[1:])
+            if pins[0] not in (0, 1):
+                self.handle_bits(pins[1:])
             else:
-                raise Exception('Invalid state: %s' % self.state)
+                self.find_clk_edge(pins[0], pins[1:])
 
index f13af364fe14dd731c639667ac7419989dc0c339..5f031e2ea735ac68a5a90c5dd85b3021b6023296 100644 (file)
@@ -252,6 +252,4 @@ class Decoder(srd.Decoder):
                 self.state = 'IDLE'
             else:
                 pass # TODO?
-        else:
-            raise Exception('Invalid state: %s' % self.state)
 
index be20ee3b356a1c907865e65dfc6e269eedcf7e10..6bd0be7e1d2d0a1edc4cdb185b90eeb7427033ee 100644 (file)
@@ -439,6 +439,4 @@ class Decoder(srd.Decoder):
             handle_response(miso)
 
             self.state = 'IDLE'
-        else:
-            raise Exception('Invalid state: %s' % self.state)
 
index ae99874c8f48762cfb10396d22e96bc03dcf09d4..ff8a5163a40a844a57a69b3d4485cc680b50324f 100644 (file)
@@ -360,8 +360,6 @@ class Decoder(srd.Decoder):
                     self.get_parity_bit(rxtx, signal)
                 elif self.state[rxtx] == 'GET STOP BITS':
                     self.get_stop_bits(rxtx, signal)
-                else:
-                    raise Exception('Invalid state: %s' % self.state[rxtx])
 
                 # Save current RX/TX values for the next round.
                 self.oldbit[rxtx] = signal
index 8f86cc72aed0f604499a25d78e36937441f3a541..4716dd7109edece530a042c71fea32d3c4096612 100644 (file)
@@ -338,6 +338,4 @@ class Decoder(srd.Decoder):
                 self.bits, self.state = [], 'WAIT FOR SOP'
             else:
                 pass # TODO: Error
-        else:
-            raise Exception('Invalid state: %s' % self.state)
 
index 8c6a9c30dc1043da64d9ae19788996992e657ab6..a21fe8da2e2ea2ad1805f5b77c1b6dfd64f67961 100644 (file)
@@ -237,6 +237,4 @@ class Decoder(srd.Decoder):
                     self.get_bit(sym)
                 elif self.state == 'GET EOP':
                     self.get_eop(sym)
-            else:
-                raise Exception('Invalid state: %s' % self.state)