Skip to content

Commit 443f9f2

Browse files
committed
ganglion: better handling incoming ascii
1 parent a0e91dd commit 443f9f2

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

open_bci_ganglion.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ def start_streaming(self, callback, lapse=-1):
248248
# should the board get disconnected and we could not wait for notification anymore, a reco should be attempted through timeout mechanism
249249
try:
250250
# at most we will get one sample per packet
251-
self.gang.waitForNotifications(1./self.getSampleRate())
251+
self.waitForNotifications(1./self.getSampleRate())
252252
except Exception as e:
253253
print("Something went wrong while waiting for a new sample: " + str(e))
254254
# retrieve current samples on the stack
@@ -268,6 +268,9 @@ def start_streaming(self, callback, lapse=-1):
268268
# Checking connection -- timeout and packets dropped
269269
self.check_connection()
270270

271+
def waitForNotifications(self, delay):
272+
""" Allow some time for the board to receive new data. """
273+
self.gang.waitForNotifications(delay)
271274

272275
"""
273276

user.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ def cleanUp():
264264
line = ''
265265
elif board.getBoardType() == "ganglion":
266266
while board.ser_inWaiting():
267-
time.sleep(0.001)
267+
board.waitForNotifications(0.001)
268268

269269
if not flush:
270270
print(line)

0 commit comments

Comments
 (0)