]> sigrok.org Git - libsigrokdecode.git/commitdiff
parallel: Enforce that at least one pin must be provided.
authorUwe Hermann <redacted>
Mon, 11 Aug 2014 20:53:35 +0000 (22:53 +0200)
committerUwe Hermann <redacted>
Thu, 14 Aug 2014 15:44:20 +0000 (17:44 +0200)
decoders/parallel/pd.py

index a695ca6d403a45f2d2f81f8e1824cbf7d6f95a9d..cafaefc071b4904718c84ab5e589bb695d005ea5 100644 (file)
@@ -61,6 +61,9 @@ def channel_list(num_channels):
         l.append(d)
     return tuple(l)
 
+class ChannelError(Exception):
+    pass
+
 class Decoder(srd.Decoder):
     api_version = 2
     id = 'parallel'
@@ -180,6 +183,9 @@ class Decoder(srd.Decoder):
                 continue
             self.oldpins = pins
 
+            if sum(1 for p in pins if p in (0, 1)) == 0:
+                raise ChannelError('At least one channel has to be supplied.')
+
             if pins[0] not in (0, 1):
                 self.handle_bits(pins[1:])
             else: