]> sigrok.org Git - libsigrokdecode.git/commitdiff
decoders: Rephrase condition-less .wait() calls (self documentation)
authorGerhard Sittig <redacted>
Sun, 18 Jun 2017 17:27:47 +0000 (19:27 +0200)
committerUwe Hermann <redacted>
Wed, 21 Jun 2017 15:45:15 +0000 (17:45 +0200)
Telling .wait() to "skip one sample" slightly obfuscates the intent of
getting the next samples while no condition applies. Explicitly pass no
condition arguments instead, to better reflect the purpose. Coincidently
these .wait() calls will execute in slightly less expensive code paths
in the common code.

decoders/dali/pd.py
decoders/dmx512/pd.py
decoders/dsi/pd.py
decoders/em4100/pd.py
decoders/ir_rc5/pd.py
decoders/lpc/pd.py
decoders/qi/pd.py
decoders/rgb_led_ws281x/pd.py
decoders/usb_signalling/pd.py
decoders/wiegand/pd.py
decoders/z80/pd.py

index bdb3fe65bacd447d634575f853976084d05d3a55..904adc7fbdc72ad628be5187bc07d3736090a72c 100644 (file)
@@ -202,7 +202,7 @@ class Decoder(srd.Decoder):
         bit = 0
         while True:
             # TODO: Come up with more appropriate self.wait() conditions.
-            (dali,) = self.wait({'skip': 1})
+            (dali,) = self.wait()
             if self.options['polarity'] == 'active-high':
                 dali ^= 1 # Invert.
 
index 4da7076f10be36aa959de33a81ebcdc35e85e160..f250a3b49f77f78f7c8dbbc9a646a3e8f0060938 100644 (file)
@@ -101,7 +101,7 @@ class Decoder(srd.Decoder):
             # Mark and read a single transmitted byte
             # (start bit, 8 data bits, 2 stop bits).
             elif self.state == 'READ BYTE':
-                (dmx,) = self.wait({'skip': 1})
+                (dmx,) = self.wait()
                 self.next_sample = self.run_start + (self.bit + 1) * self.skip_per_bit
                 self.aggreg += dmx
                 if self.samplenum != self.next_sample:
index 35a122542f532dc6f1dc15347dedd8fab68a1bb4..5b473be2b34bd374800b392f543374a15ebca657 100644 (file)
@@ -108,7 +108,7 @@ class Decoder(srd.Decoder):
             raise SamplerateError('Cannot decode without samplerate.')
         bit = 0
         while True:
-            (self.dsi,) = self.wait({'skip': 1})
+            (self.dsi,) = self.wait()
             if self.options['polarity'] == 'active-high':
                 self.dsi ^= 1 # Invert.
 
index 8c8a72bfb0092620293e96043243e1da516083b9..711c0fa20dab7fbc372806c9117b856b3efb4f16 100644 (file)
@@ -212,7 +212,7 @@ class Decoder(srd.Decoder):
             raise SamplerateError('Cannot decode without samplerate.')
 
         # Initialize internal state from the very first sample.
-        (pin,) = self.wait({'skip': 1})
+        (pin,) = self.wait()
         self.oldpin = pin
         self.last_samplenum = self.samplenum
         self.lastlast_samplenum = self.samplenum
index 0b39e709698f935610fa30d475b35c42b8ee0ff4..ae29f1028fd2418541e5c4d331fc85164629cfd4 100644 (file)
@@ -139,7 +139,7 @@ class Decoder(srd.Decoder):
             raise SamplerateError('Cannot decode without samplerate.')
         while True:
 
-            (self.ir,) = self.wait({'skip': 1})
+            (self.ir,) = self.wait()
 
             # Wait for any edge (rising or falling).
             if self.old_ir == self.ir:
index 5e838cf0e336febbcb52afa1f68baaf08dcba4e1..cdd1db8f4e6d25f696887adbe0893794453809b8 100644 (file)
@@ -315,7 +315,7 @@ class Decoder(srd.Decoder):
     def decode(self):
         while True:
             # TODO: Come up with more appropriate self.wait() conditions.
-            pins = self.wait({'skip': 1})
+            pins = self.wait()
 
             # If none of the pins changed, there's nothing to do.
             if self.oldpins == pins:
index 0c880dd217ae60028655a16560a09aa31491a2d8..779cafa796c277c69a2e83cfa10d152833f3d900 100644 (file)
@@ -232,7 +232,7 @@ class Decoder(srd.Decoder):
         if not self.samplerate:
             raise SamplerateError('Cannot decode without samplerate.')
 
-        (qi,) = self.wait({'skip': 1})
+        (qi,) = self.wait()
         self.handle_transition(self.samplenum, qi == 0)
         while True:
             prev = self.samplenum
index ca352838bbb92ab13662f1ca48142b696adf380c..5cf21245df91603ea53fcc0d0fcce6f0feb5f112 100644 (file)
@@ -76,7 +76,7 @@ class Decoder(srd.Decoder):
 
         while True:
             # TODO: Come up with more appropriate self.wait() conditions.
-            (pin,) = self.wait({'skip': 1})
+            (pin,) = self.wait()
 
             if self.oldpin is None:
                 self.oldpin = pin
index ae0f651a5de5a2ed384585a58a36b9b8992b65a7..7a885c05293a1820f0af0cb1509fdddad3add67e 100644 (file)
@@ -302,7 +302,7 @@ class Decoder(srd.Decoder):
             raise SamplerateError('Cannot decode without samplerate.')
 
         # Seed internal state from the very first sample.
-        pins = self.wait({'skip': 1})
+        pins = self.wait()
         sym = symbols[self.options['signalling']][pins]
         self.handle_idle(sym)
 
@@ -330,7 +330,7 @@ class Decoder(srd.Decoder):
                     self.get_eop(sym)
             elif self.state == 'WAIT IDLE':
                 # Skip "all-low" input. Wait for high level on either DP or DM.
-                pins = self.wait({'skip': 1})
+                pins = self.wait()
                 while not pins[0] and not pins[1]:
                     pins = self.wait([{0: 'h'}, {1: 'h'}])
                 if self.samplenum - self.samplenum_lastedge > 1:
index 42e63b9f573e3ed5e0d3407ccefd4fd4232830a1..3edefc5b00494d548c547e85bea481c5c3cec1d1 100644 (file)
@@ -105,7 +105,7 @@ class Decoder(srd.Decoder):
     def decode(self):
         while True:
             # TODO: Come up with more appropriate self.wait() conditions.
-            (d0, d1) = self.wait({'skip': 1})
+            (d0, d1) = self.wait()
 
             if d0 == self._d0_prev and d1 == self._d1_prev:
                 if self.es_bit and self.samplenum >= self.es_bit:
index bd2ec575a95aa4e6ca35b303a925426e014c5df3..76e1858ff98b6e1748499180915a206bc80a1caa 100644 (file)
@@ -132,7 +132,7 @@ class Decoder(srd.Decoder):
     def decode(self):
         while True:
             # TODO: Come up with more appropriate self.wait() conditions.
-            pins = self.wait({'skip': 1})
+            pins = self.wait()
             cycle = Cycle.NONE
             if pins[Pin.MREQ] != 1: # default to asserted
                 if pins[Pin.RD] == 0: