Browse Source

modified: change trigger in receiveIr

Satoshi Yoneda 6 years ago
parent
commit
afc8319564
1 changed files with 15 additions and 6 deletions
  1. 15 6
      tree/usr/local/bin/registerIr.py

+ 15 - 6
tree/usr/local/bin/registerIr.py

@@ -112,23 +112,32 @@ class simpleLCD():
 		return y
 
 def receiveIr(timeout=120*1000):
-	with subprocess.Popen(MODE2CMD, stdout=subprocess.PIPE) as proc:
+	codes = []
+
+	with subprocess.Popen(MODE2CMD, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) as proc:
 		p = select.poll()
 		p.register(proc.stdout)
-		codes = []
 		i = 0
+		fstart = False
 		while True:
 			ret = p.poll(timeout)
 			if len(ret) == 0:	# timeout
 				proc.terminate()
 				return None
 			line = proc.stdout.readline().strip().decode()
-			if i > 2:
-				code = line.split(' ')[1]
+			type = line.split(' ')[0]
+			code = line.split(' ')[1]
+			if not fstart:
+				if type == 'pulse':
+					fstart = True
+			
+			if fstart:
 				codes.append(code)
-			i += 1
-			if i > 69:
+				i += 1
+			
+			if i >= 67:
 				break
+				
 		proc.terminate()
 	return codes