From 5c52a17e865a8fc2a300da9769750ce2d3a14728 Mon Sep 17 00:00:00 2001 From: Andy Spencer Date: Mon, 10 Feb 2014 02:21:35 +0000 Subject: [PATCH] Use serial.isWaiting() function Also remove old debugging code --- vis/device.py | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/vis/device.py b/vis/device.py index 852b873..093f380 100644 --- a/vis/device.py +++ b/vis/device.py @@ -215,32 +215,15 @@ class Device: self._write_binary('B', bits) def process(self): - items = [] - count = 0 - limit = 1000 - if not self.running(): - return items - - while self.serial.readable(): - try: - byte = self.serial.read() - except Exception as ex: - # Not sure why this is excepting - # if it says it's readable - break - if len(byte) == 0: - break + return [] + items = [] + while self.serial.inWaiting(): + byte = self.serial.read() state = self.frame.parse(byte) if state: items.append(state) - if count > limit: - print('[ERROR] Exceeded Read Limit') - break - - count += 1 - return items -- 2.43.2