robintibor / python-mindwave-mobile

Scripts to read data out of the Neurosky Mindwave Mobile unter Ubuntu
MIT License
116 stars 74 forks source link

the program just stopped working #11

Open bbbbear opened 7 years ago

bbbbear commented 7 years ago

As I use the api you provided, the program is stopped working after running for a while(15-20 mins.). I still have no idea how to fix it. As I tried to track the code it shows that it was stopped on this line. receivedBytes += self.mindwaveMobileSocket.recv(missingBytes) in _readBytesFromMindwaveMobile of MindwaveMobileRawReader.py I am using rasberry pi 3 B, the bluetooth is already embeded on the board.

Thank you

robintibor commented 7 years ago

Hmm can you somehow get the error message?

bbbbear commented 7 years ago

There is no error message, the program is not crashing but it seems can not receive or waiting for the bytes from the mindwave. As I tried to set the timed out for receiving, the time out is raised instead. I don't sure if it was the hardware problem or software problem but I've already tried 2 mindwave, the results still the same. I have not try to change the raspberry pi yet.

robintibor commented 7 years ago

Hm in that case I also don't know what to do besides setting timeout and maybe then reconnecting or sth if timeout error is raised.... but no idea if that would help :/

bbbbear commented 7 years ago

I've already tried to disconnect and re-connect when timed out. After reconnect, it'll be timed out again in less than a minute. So I'm thinking if it was a hardware problem. Which version of RaspberryPi do you use, and did you use an external bluetooth receiver?

robintibor commented 7 years ago

I did not use any RasperryPi, I used my normal laptop with a usb bluetooth dongle/adapter.

macheteluc commented 7 years ago

@robintibor Thanks for your code so much, it helps a lot. @bbbbear We are using RaspberryPi to connect the mindwave mobile, also via the embedded bluetooth. Our previous engineer had a similar disconnecting problem, but he coded with C# with official API and used the usb dongle to connect a desktop. In my memory, he said it's an event loop monitoring, one can add a piece of blocking code or something to keep it stay in.

Before we using Raspberry, we used a STM32 board and a HC05 bluetooth model to connect mindwave mobile, which coded in C, looks like this: image And it worked well.

Currently, we can connect the mindwave mobile by using raspberry pi 3, but the attention and meditation data are all zero. I think we might face the disconnecting problem in the future. So, @bbbbear have you ever had this problem about zero attention and meditation?

bbbbear commented 7 years ago

@macheteluc No, I had never face the problem about the zero attention and meditation problem It works well as it should except the timed out problem.

AdairValdivia commented 6 years ago

@bbbbear hi men can you giveme a hand? im trying to conect the mindwave mobile mw003 to my raspberry pi 3b but i have an error that says Could not connect:  (52, 'Invalid exchange') ; Retrying in 5s... Could not connect:  (77, 'File descriptor in bad state') ; Retrying in 5s... Could not connect:  (77, 'File descriptor in bad state') ; Retrying in 5s...

And when i try to do in terminal pi@raspberrypi:~ $ sudo rfcomm connect rfcomm0 20:68:9D:91:DA:9D Can't connect RFCOMM socket: Invalid Exchange

Pls help that i have trying for long time and dont foun the error

bbbbear commented 6 years ago

@AdairValdivia Umm, it's already long time ago that I can't remember and I don't have raspberry pi now. Did you try to connect by UI? As I remember, I can't connect the bluetooth via PyBluez and terminal on UI when it works. But I can't connect on UI when the terminal and PyBluez works. There might me some conflict that I might accidentally fixed. I think that I'm familiar with bluetoothctl command when I try to make it works.

gabe-sr commented 5 years ago

@bbbbear Did you solve the problem? I am facing it right now. I was using the same config. as you (mindwave mobile + raspberry pi 3 B). After a while, the console does not refresh as if no data is being streamed. After reconnecting the issue rises in less than a minute (approx. 30 seconds).

bbbbear commented 5 years ago

@gabe-sr I did roughly solve the problem by modifying the receiving code in MindwaveMobileRawReader.py.