Skip to content

Commit

Permalink
fix for serial buffer being only processed 1 line at a time
Browse files Browse the repository at this point in the history
  • Loading branch information
elcojacobs committed Dec 1, 2016
1 parent 08a8a5a commit 7711c14
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions backgroundserial.py
Expand Up @@ -91,9 +91,13 @@ def __listenThread(self):

if new_data:
self.buffer = self.buffer + new_data
line = self.__get_line_from_buffer()
if line:
self.queue.put(line)
while True:
line = self.__get_line_from_buffer()
if line:
self.queue.put(line)
else:
break


if self.error:
try:
Expand Down Expand Up @@ -121,7 +125,7 @@ def __get_line_from_buffer(self):
self.buffer = stripped_buffer
continue
lines = self.buffer.partition('\n') # returns 3-tuple with line, separator, rest
if(lines[1] == ''):
if not lines[1]:
# '\n' not found, first element is incomplete line
self.buffer = lines[0]
return None
Expand Down

0 comments on commit 7711c14

Please sign in to comment.