]> sigrok.org Git - libsigrokdecode.git/commitdiff
spi/nrf24l01/uart: Use ChannelError exception.
authorUwe Hermann <redacted>
Sun, 10 Aug 2014 07:22:29 +0000 (09:22 +0200)
committerUwe Hermann <redacted>
Thu, 14 Aug 2014 15:44:20 +0000 (17:44 +0200)
Rename the old MissingDataError to the clearer ChannelError. Also, add
ChannelError in the UART decoder.

decoders/nrf24l01/pd.py
decoders/nrf24l01/test/test.conf
decoders/spi/pd.py
decoders/spi/test/test.conf
decoders/uart/pd.py

index 410a84704923bd28928e23b2e81e5595201b9fec..99a7d6e3f11d52de4d765870ca5e71c14f920e2e 100644 (file)
@@ -20,7 +20,7 @@
 
 import sigrokdecode as srd
 
 
 import sigrokdecode as srd
 
-class MissingDataError(Exception):
+class ChannelError(Exception):
     pass
 
 regs = {
     pass
 
 regs = {
@@ -284,7 +284,7 @@ class Decoder(srd.Decoder):
             pos = (ss, es)
 
             if miso is None or mosi is None:
             pos = (ss, es)
 
             if miso is None or mosi is None:
-                raise MissingDataError('Both MISO and MOSI pins required.')
+                raise ChannelError('Both MISO and MOSI pins required.')
 
             if self.first:
                 self.first = False
 
             if self.first:
                 self.first = False
index 8b6d77bee3ba542ae35b097f883f81e8a173e401..986d30d95fdb262ad8e0d65c642b3fe684837dba 100644 (file)
@@ -56,14 +56,14 @@ test no-mosi
        protocol-decoder nrf24l01
        stack spi nrf24l01
        input spi/nrf24l01/nrf24l01-test-no-command.sr
        protocol-decoder nrf24l01
        stack spi nrf24l01
        input spi/nrf24l01/nrf24l01-test-no-command.sr
-       output nrf24l01 exception match MissingDataError
+       output nrf24l01 exception match ChannelError
 
 test no-miso
        protocol-decoder spi channel cs=0 channel clk=1 channel mosi=2
        protocol-decoder nrf24l01
        stack spi nrf24l01
        input spi/nrf24l01/nrf24l01-test-no-command.sr
 
 test no-miso
        protocol-decoder spi channel cs=0 channel clk=1 channel mosi=2
        protocol-decoder nrf24l01
        stack spi nrf24l01
        input spi/nrf24l01/nrf24l01-test-no-command.sr
-       output nrf24l01 exception match MissingDataError
+       output nrf24l01 exception match ChannelError
 
 test unknown-command
        protocol-decoder spi channel cs=0 channel clk=1 channel mosi=2 channel miso=3
 
 test unknown-command
        protocol-decoder spi channel cs=0 channel clk=1 channel mosi=2 channel miso=3
index 374d22be3703fec4d0b2f038e2e9dfe9d4063a5f..97d5571c066a3d8ec6664de9ef04cc766b4d756b 100644 (file)
@@ -63,7 +63,7 @@ spi_mode = {
 class SamplerateError(Exception):
     pass
 
 class SamplerateError(Exception):
     pass
 
-class MissingDataError(Exception):
+class ChannelError(Exception):
     pass
 
 class Decoder(srd.Decoder):
     pass
 
 class Decoder(srd.Decoder):
@@ -279,6 +279,6 @@ class Decoder(srd.Decoder):
 
             # Either MISO or MOSI (but not both) can be omitted.
             if not (self.have_miso or self.have_mosi):
 
             # Either MISO or MOSI (but not both) can be omitted.
             if not (self.have_miso or self.have_mosi):
-                raise MissingDataError('Either MISO or MOSI (or both) pins required.')
+                raise ChannelError('Either MISO or MOSI (or both) pins required.')
 
             self.find_clk_edge(miso, mosi, clk, cs)
 
             self.find_clk_edge(miso, mosi, clk, cs)
index 53edfeb4c5979e88a36dea1570d96b4797b3401a..a74611d7b703363b1b19f2293ccf2d6767003805 100644 (file)
@@ -36,8 +36,8 @@ test exception_samplerate
        input misc/no-samplerate.sr
        output spi exception match SamplerateError
 
        input misc/no-samplerate.sr
        output spi exception match SamplerateError
 
-test exception_missing_datapins
+test exception_channel
        protocol-decoder spi channel cs=1 channel clk=0
        input spi/spi-count-msb.sr
        protocol-decoder spi channel cs=1 channel clk=0
        input spi/spi-count-msb.sr
-       output spi exception match MissingDataError
+       output spi exception match ChannelError
 
 
index fef3aa525fe3b0f32893a8a915cd6cd1b4e24bcd..d13a11958b70c508e2860e681d542ec089cdd466 100644 (file)
@@ -70,6 +70,9 @@ def parity_ok(parity_type, parity_bit, data, num_data_bits):
 class SamplerateError(Exception):
     pass
 
 class SamplerateError(Exception):
     pass
 
+class ChannelError(Exception):
+    pass
+
 class Decoder(srd.Decoder):
     api_version = 2
     id = 'uart'
 class Decoder(srd.Decoder):
     api_version = 2
     id = 'uart'
@@ -336,7 +339,7 @@ class Decoder(srd.Decoder):
             # Either RX or TX (but not both) can be omitted.
             has_pin = [rx in (0, 1), tx in (0, 1)]
             if has_pin == [False, False]:
             # Either RX or TX (but not both) can be omitted.
             has_pin = [rx in (0, 1), tx in (0, 1)]
             if has_pin == [False, False]:
-                raise Exception('Either TX or RX (or both) pins required.')
+                raise ChannelError('Either TX or RX (or both) pins required.')
 
             # State machine.
             for rxtx in (RX, TX):
 
             # State machine.
             for rxtx in (RX, TX):