alexandrebarachant / muse-lsl

Python script to stream EEG data from the muse 2016 headset
BSD 3-Clause "New" or "Revised" License
616 stars 182 forks source link

does muse-lsl work with the current bluez on linux? #119

Open segersj opened 4 years ago

segersj commented 4 years ago

I have been going around in circles trying to use muse-lsl on current manjaro linux (7 feb 2020) The upstream authors have deprecated and removed gatttool and several other pieces of the bluetooth toolchain. Manjaro linux has a special package that has the deprecated tools included. This appears to be required. I have spent at least 4 hours googling to try and figure this out. Here is what I have seen:

The GUI application (blueman I think) detects the unpaired muse and lets me pair and trust the muse but will not connect. The commandline tools will not see the muse following any instructions I can find on the web, but "$ sudo rfcomm connect 0 XX:XX:XX:XX:XX:XX" (the XX: stuff being the MAC address of the muse gotten from the GUI app.) creates /dev/rfcomm0 and connects the muse properly as proven by opening it with picocomm and sending s (start streaming) , h (halt streaming), and k (keep stream alive) commands. (It puts garbage on the screen at appropriate times.)

at this point I tried "$ muselsl stream -b bgapi -i /dev/rfcom0". This started the "searching for muses" output, disconnected /dev/rfcomm0, put the muse into bouncing lights mode (searching for a connection) then fails with "No Muses found."

at this point, I opened the example python script RecieveData.py and ran it. it froze with "looking for an EEG stream...". So I ran it again in a debugger single stepping and stepping in as appropriate. I sort of understood what was going on until it tried to call out to the c++ liblsl at which point spyder (my IDE) hung, so I don't know if this is a bluetooth problem, a liblsl problem, or a muse-lsl problem, but I really hope someone who reads this can help me because I would like to write a program.

running "muselsl stream" in one terminal caused the following output in a terminal running "hcidump -X" while the muse was in bouncing lights mode.

HCI Event: Command Complete (0x0e) plen 4 Write Scan Enable (0x03|0x001a) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 4 Reset (0x03|0x0003) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 12 Read Local Supported Features (0x04|0x0003) ncmd 1 status 0x00 Features: 0xff 0xfe 0x8f 0xfe 0xd8 0x3f 0x5b 0x87 HCI Event: Command Complete (0x0e) plen 12 Read Local Version Information (0x04|0x0001) ncmd 1 status 0x00 HCI Version: 4.1 (0x7) HCI Revision: 0x0 LMP Version: 4.1 (0x7) LMP Subversion: 0x25a Manufacturer: Qualcomm (29) HCI Event: Command Complete (0x0e) plen 10 Read BD ADDR (0x04|0x0009) ncmd 1 status 0x00 bdaddr C8:FF:28:31:68:94 HCI Event: Command Complete (0x0e) plen 11 Read Buffer Size (0x04|0x0005) ncmd 1 status 0x00 ACL MTU 1024:8 SCO MTU 50:8 HCI Event: Command Complete (0x0e) plen 7 Read Class of Device (0x03|0x0023) ncmd 1 status 0x00 class 0x000000 HCI Event: Command Complete (0x0e) plen 252 Read Local Name (0x03|0x0014) ncmd 1 status 0x00 name '' HCI Event: Command Complete (0x0e) plen 6 Read Voice Setting (0x03|0x0025) ncmd 1 status 0x00 voice setting 0x006c HCI Event: Command Complete (0x0e) plen 5 Read Number of Supported IAC (0x03|0x0038) ncmd 1 0000: 00 02 .. HCI Event: Command Complete (0x0e) plen 8 Read Current IAC LAP (0x03|0x0039) ncmd 1 IAC 0x9e8b33 (General Inquiry Access Code) HCI Event: Command Complete (0x0e) plen 4 Set Event Filter (0x03|0x0005) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 4 Write Connection Accept Timeout (0x03|0x0016) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 7 LE Read Buffer Size (0x08|0x0002) ncmd 1 status 0x00 pktlen 0x0040 maxpkt 0x10 HCI Event: Command Complete (0x0e) plen 12 LE Read Local Supported Features (0x08|0x0003) ncmd 1 status 0x00 features 0x1f00000000000000 (Link Layer supports LE Encryption) HCI Event: Command Complete (0x0e) plen 12 LE Read Supported States (0x08|0x001c) ncmd 1 0000: 00 ff ff ff ff ff 03 00 00 ......... HCI Event: Command Complete (0x0e) plen 68 Read Local Supported Commands (0x04|0x0002) ncmd 1 status 0x00 Commands: ffffff03ceffefffffffff7ff20fe8fe3ff783ff1c00000061ffffff7f8620f5 fff0f907 HCI Event: Command Complete (0x0e) plen 4 Write Simple Pairing Mode (0x03|0x0056) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 4 Write Inquiry Mode (0x03|0x0045) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 5 Read Inquiry Response Transmit Power Level (0x03|0x0058) ncmd 1 status 0x00 level 6 HCI Event: Command Complete (0x0e) plen 14 Read Local Extended Features (0x04|0x0004) ncmd 1 status 0x00 page 1 max 2 Features: 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 HCI Event: Command Complete (0x0e) plen 4 Set Event Mask (0x03|0x0001) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 8 Read Stored Link Key (0x03|0x000d) ncmd 1 status 0x00 max 8 num 0 HCI Event: Command Complete (0x0e) plen 4 Write Default Link Policy Settings (0x02|0x000f) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 8 Read Page Scan Activity (0x03|0x001b) ncmd 1 status 0x00 interval 2048 window 18 HCI Event: Command Complete (0x0e) plen 5 Read Page Scan Type (0x03|0x0046) ncmd 1 0000: 00 00 .. HCI Event: Command Complete (0x0e) plen 4 LE Set Event Mask (0x08|0x0001) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 5 LE Read Advertising Channel Tx Power (0x08|0x0007) ncmd 1 status 0x00 level 0x2 (dBm) HCI Event: Command Complete (0x0e) plen 5 LE Read White List Size (0x08|0x000f) ncmd 1 0000: 00 80 .. HCI Event: Command Complete (0x0e) plen 4 LE Clear White List (0x08|0x0010) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 5 Unknown (0x08|0x002a) ncmd 1 0000: 00 20 . HCI Event: Command Complete (0x0e) plen 4 Unknown (0x08|0x0029) ncmd 1 0000: 00 . HCI Event: Command Complete (0x0e) plen 4 Write LE Host Supported (0x03|0x006d) ncmd 1 0000: 00 . HCI Event: Command Complete (0x0e) plen 14 Read Local Extended Features (0x04|0x0004) ncmd 1 status 0x00 page 2 max 2 Features: 0x45 0x03 0x00 0x00 0x00 0x00 0x00 0x00 HCI Event: Command Complete (0x0e) plen 6 Delete Stored Link Key (0x03|0x0012) ncmd 1 status 0x00 deleted 0 HCI Event: Command Complete (0x0e) plen 11 Unknown (0x03|0x0077) ncmd 1 0000: 00 80 00 00 80 00 00 00 ........ HCI Event: Command Complete (0x0e) plen 4 Unknown (0x03|0x007a) ncmd 1 0000: 00 . HCI Event: Command Complete (0x0e) plen 4 LE Set Advertising Data (0x08|0x0008) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 4 LE Set Scan Response Data (0x08|0x0009) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 4 Write Scan Enable (0x03|0x001a) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 4 Write Class of Device (0x03|0x0024) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 4 Write Local Name (0x03|0x0013) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 4 Write Extended Inquiry Response (0x03|0x0052) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 4 LE Set Scan Parameters (0x08|0x000b) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 4 LE Set Scan Enable (0x08|0x000c) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 4 Write Local Name (0x03|0x0013) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 4 Write Extended Inquiry Response (0x03|0x0052) ncmd 1 status 0x00 HCI Event: Command Complete (0x0e) plen 4 LE Set Scan Enable (0x08|0x000c) ncmd 1 status 0x00

ErikBjare commented 4 years ago

I'm on Arch Linux and all I had to do to get it working was to install bluez-utils-compat from the AUR (to get gatttool). After that, sudo muselsl stream and muselsl record seems to work fine.

I didn't use any bluetooth manager to connect or anything else special. Once I had installed bluez-utils-compat everything just worked. I'm using the Muse S and some cheap Bluetooth adapter (lsusb identifies it as: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode))