From: Andy Spencer Date: Mon, 10 Feb 2014 02:21:35 +0000 (+0000) Subject: Use serial.isWaiting() function X-Git-Url: http://pileus.org/git/?p=~andy%2Fcsm213a-hw;a=commitdiff_plain;h=5c52a17e865a8fc2a300da9769750ce2d3a14728 Use serial.isWaiting() function Also remove old debugging code --- 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