summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Steinhauser <jens.steinhauser@gmail.com>2014-10-19 20:39:38 +0200
committerJens Steinhauser <jens.steinhauser@gmail.com>2014-10-19 20:39:38 +0200
commit3cc4c4a96dba8390ec4eabbd62cc1d50d653640e (patch)
tree540322824474fd336c0067a6cad096f21938ba42
parent1c49e875623918f8893308307f487a1f551daec4 (diff)
downloadlibsigrokdecode-3cc4c4a96dba8390ec4eabbd62cc1d50d653640e.tar.gz
libsigrokdecode-3cc4c4a96dba8390ec4eabbd62cc1d50d653640e.zip
nrf24l01: Check for CS# pin and only throw exceptions once.
-rw-r--r--decoders/nrf24l01/pd.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/decoders/nrf24l01/pd.py b/decoders/nrf24l01/pd.py
index 99a7d6e..a40f454 100644
--- a/decoders/nrf24l01/pd.py
+++ b/decoders/nrf24l01/pd.py
@@ -86,6 +86,7 @@ class Decoder(srd.Decoder):
def __init__(self, **kwargs):
self.next()
+ self.requirements_met = True
def start(self):
self.out_ann = self.register(srd.OUTPUT_ANN)
@@ -264,9 +265,17 @@ class Decoder(srd.Decoder):
self.warn(pos, 'wrong data for "ACTIVATE" command')
def decode(self, ss, es, data):
+ if not self.requirements_met:
+ return
+
ptype, data1, data2 = data
if ptype == 'CS-CHANGE':
+ if data1 == -1:
+ if data2 == -1:
+ self.requirements_met = False
+ raise ChannelError('CS# pin required.')
+
if data1 == 0 and data2 == 1:
# Rising edge, the complete command is transmitted, process
# the bytes that were send after the command byte.
@@ -284,6 +293,7 @@ class Decoder(srd.Decoder):
pos = (ss, es)
if miso is None or mosi is None:
+ self.requirements_met = False
raise ChannelError('Both MISO and MOSI pins required.')
if self.first: