From 445780438f1d5165f03d8bfda5c067146cb687cc Mon Sep 17 00:00:00 2001 From: Rodrigo Ceballos Date: Mon, 27 Jul 2015 13:51:23 -0400 Subject: [PATCH] Updated tests --- open_bci_v3.py | 10 +++++++++- scripts/simple_serial.py | 16 ++++++++++++++++ scripts/test.py | 6 ++++-- 3 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 scripts/simple_serial.py diff --git a/open_bci_v3.py b/open_bci_v3.py index 74135e0..07261f2 100644 --- a/open_bci_v3.py +++ b/open_bci_v3.py @@ -25,6 +25,7 @@ def handle_sample(sample): import logging import threading import sys +import pdb SAMPLE_RATE = 250.0 # Hz START_BYTE = 0xA0 # start of data packet @@ -73,13 +74,17 @@ def __init__(self, port=None, baud=115200, filter_data=True, print("Connecting to %s" %(port)) self.ser = serial.Serial(port= port, baudrate = baud, timeout=timeout) + print("Serial established...") + time.sleep(2) #Initialize 32-bit board, doesn't affect 8bit board self.ser.write('v'); + #wait for device to be ready time.sleep(1) + print("Incoming:") self.print_incoming_text() self.streaming = False @@ -305,7 +310,8 @@ def print_incoming_text(self): """ line = '' #Wait for device to send data - time.sleep(0.5) + time.sleep(1) + if self.ser.inWaiting(): line = '' c = '' @@ -314,6 +320,8 @@ def print_incoming_text(self): c = self.ser.read() line += c print(line); + else: + self.warn("No Message") def print_register_settings(self): self.ser.write('?') diff --git a/scripts/simple_serial.py b/scripts/simple_serial.py new file mode 100644 index 0000000..314cb4b --- /dev/null +++ b/scripts/simple_serial.py @@ -0,0 +1,16 @@ +import serial +import struct +import numpy as np +import time +import timeit +import atexit +import logging +import threading +import sys +import pdb + +port = '/dev/tty.OpenBCI-DN008VTF' +#port = '/dev/tty.OpenBCI-DN0096XA' +baud = 115200 +ser = serial.Serial(port= port, baudrate = baud, timeout = None) +pdb.set_trace() \ No newline at end of file diff --git a/scripts/test.py b/scripts/test.py index a8cdc76..230a2ff 100644 --- a/scripts/test.py +++ b/scripts/test.py @@ -15,12 +15,14 @@ def printData(sample): if __name__ == '__main__': - port = '/dev/tty.usbserial-DN0096XA' + port = '/dev/tty.OpenBCI-DN008VTF' + #port = '/dev/tty.OpenBCI-DN0096XA' baud = 115200 logging.basicConfig(filename="test.log",format='%(asctime)s - %(levelname)s : %(message)s',level=logging.DEBUG) logging.info('---------LOG START-------------') board = bci.OpenBCIBoard(port=port, scaled_output=False, log=True) + print("Board Instantiated") board.ser.write('v') - time.sleep(0.100) + time.sleep(10) #board.start_streaming(printData) board.print_bytes_in()