From a573d3944c410d90adb5130323e0f3792d9ae201 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Mon, 11 Aug 2014 22:53:35 +0200 Subject: parallel: Enforce that at least one pin must be provided. --- decoders/parallel/pd.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'decoders/parallel/pd.py') diff --git a/decoders/parallel/pd.py b/decoders/parallel/pd.py index a695ca6..cafaefc 100644 --- a/decoders/parallel/pd.py +++ b/decoders/parallel/pd.py @@ -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: -- cgit v1.2.3-70-g09d2