From 732d1f942598614900e07fa32befa5079e50480c Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 23 Jul 2018 15:53:14 -0700 Subject: [PATCH 1/2] Make sure to check every pulse length immediately. --- adafruit_irremote.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/adafruit_irremote.py b/adafruit_irremote.py index ef5b94f..77073ca 100644 --- a/adafruit_irremote.py +++ b/adafruit_irremote.py @@ -74,6 +74,9 @@ import array +__version__ = "0.0.0-auto.0" +__repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_IRRemote.git" + class IRDecodeException(Exception): """Generic decode exception""" pass @@ -198,11 +201,12 @@ def read_pulses(self, input_pulses, max_pulse=10000, blocking=True): If False, will return None if no pulses. Defaults to True for backwards compatibility """ + if len(input_pulses) == 0 and not blocking: + return None received = [] while True: - while len(input_pulses) < 8: # not too big (slower) or too small (underruns)! - if not blocking: - return None + while len(input_pulses) == 0: + pass while input_pulses: pulse = input_pulses.popleft() if pulse > max_pulse: From 525cbfa7e6b65d25dec35b4fbcbf53595f58d520 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 23 Jul 2018 16:07:08 -0700 Subject: [PATCH 2/2] Implicit length check for pylint. --- adafruit_irremote.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adafruit_irremote.py b/adafruit_irremote.py index 77073ca..d5fc6d8 100644 --- a/adafruit_irremote.py +++ b/adafruit_irremote.py @@ -201,11 +201,11 @@ def read_pulses(self, input_pulses, max_pulse=10000, blocking=True): If False, will return None if no pulses. Defaults to True for backwards compatibility """ - if len(input_pulses) == 0 and not blocking: + if not input_pulses and not blocking: return None received = [] while True: - while len(input_pulses) == 0: + while not input_pulses: pass while input_pulses: pulse = input_pulses.popleft()