diff --git a/libmushu/driver/emotiv.py b/libmushu/driver/emotiv.py index fcf0bac..4fdd7e6 100644 --- a/libmushu/driver/emotiv.py +++ b/libmushu/driver/emotiv.py @@ -27,8 +27,8 @@ from libmushu.amplifier import Amplifier -VENDOR_ID = 0x1234 -PRODUCT_ID = 0xed02 +VENDOR_ID = 0x21a1 +PRODUCT_ID = 0x0001 ENDPOINT_IN = usb.util.ENDPOINT_IN | 2 # second endpoint @@ -39,7 +39,11 @@ def __init__(self): # find amplifier self.dev = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID) if self.dev is None: - raise RuntimeError('Emotiv device is not connected.') + VENDOR_ID = 0x1234 + PRODUCT_ID = 0xed01 + self.dev = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID) + if self.dev is None: + raise RuntimeError('Emotiv device is not connected.') # pyusb docs say you *have* to call set_configuration, but it does not # work unless i *don't* call it. #dev.set_configuration() @@ -58,6 +62,8 @@ def __init__(self): # is not sent with every frame. self._battery = 0 self._quality = [0 for i in range(14)] + #sampling frequency + self.fs = 128 # channel info self.channel = ['Counter', 'Battery', 'F3', 'FC5', 'AF3', 'F7', 'T7', 'P7', 'O1', @@ -71,14 +77,20 @@ def __init__(self): def get_data(self): try: - raw = self.dev.read(ENDPOINT_IN, 32, 1, timeout=1000) + raw = self.dev.read(ENDPOINT_IN, 32, 1, timeout=10000) raw = self.decrypt(raw) data = self.parse_raw(raw) data = np.array(data) except Exception as e: print e data = np.array() - return data.reshape(1, -1) + return data.reshape(1, -1),[] + + def get_sampling_frequency(self): + return self.fs + + def get_channels(self): + return self.channel @staticmethod def is_available(): @@ -86,7 +98,7 @@ def is_available(): return False else: return True - + def generate_key(self, sn, research=True): """Generate the encryption key.