]> sigrok.org Git - libsigrokdecode.git/commitdiff
nrf24l01: Don't decode incomplete commands.
authorJens Steinhauser <redacted>
Sun, 19 Oct 2014 19:29:07 +0000 (21:29 +0200)
committerUwe Hermann <redacted>
Sun, 19 Oct 2014 21:01:26 +0000 (23:01 +0200)
Wait for the CS# line to be inactive before decoding the commands.

decoders/nrf24l01/pd.py

index a40f454b40f04270c6c4bf364558e7ff3fb28677..38e5ac6b09e093d90bc6bfc52a1b6d00c7fc1a99 100644 (file)
@@ -87,6 +87,7 @@ class Decoder(srd.Decoder):
     def __init__(self, **kwargs):
         self.next()
         self.requirements_met = True
+        self.cs_was_released = False
 
     def start(self):
         self.out_ann = self.register(srd.OUTPUT_ANN)
@@ -275,6 +276,8 @@ class Decoder(srd.Decoder):
                 if data2 == -1:
                     self.requirements_met = False
                     raise ChannelError('CS# pin required.')
+                elif data2 == 1:
+                    self.cs_was_released = True
 
             if data1 == 0 and data2 == 1:
                 # Rising edge, the complete command is transmitted, process
@@ -288,7 +291,8 @@ class Decoder(srd.Decoder):
                         self.finish_command((self.mb_s, self.mb_e))
 
                 self.next()
-        elif ptype == 'DATA':
+                self.cs_was_released = True
+        elif ptype == 'DATA' and self.cs_was_released:
             mosi, miso = data1, data2
             pos = (ss, es)