Unable to stop streaming using OpenBCI-python
in Software
Hi everyone!!
I wrote a code to acquire data using python and the OpenBCI-python API. To acquire it I'm using the functions that are showed in the sample scripts like stream_data_wifi.py as it follows:
connection.start_streaming(handle_streamed_data)
connection.loop()
connection.stop()
connection.disconnect()
My poblem is that I'm not able to stop the streaming (is never reaching the connection.stop even if I use some flag variable). Only if I include this code inside the handle_streamed_data() function stops streaming but the problem in this case is that is doing another iteration and I have an error because is not able to find the connection.
Does anyone knows how to deal with this? What I'm doing wrong?
Thanks in advance
Comments
I think there are two python API's: one old and one newer. Please share which OpenBCI repo you are using.
I'm using the old version.
Try the newer Python repo
https://github.com/OpenBCI/pyOpenBCI
The problem is that I'm using a Raspberry Pi to run this code and I've experienced a lot of problems in the past to install and be able to run the code on it so I don't want to change to pyOpenBCI. Finally I've solved the problem including the
connection.start_streaming(handle_streamed_data)inside a try/catch block.Thank you anyway.
Can you please share the result? It would be nice for others to know how to receive OpenBCI signals using a Raspberry Pi.
The code that I use is more or less the same that I found here: https://github.com/cmello418/OpenBCI_Python/blob/master/scripts/stream_data_wifi_high_speed_no_auto_connect.py
But the problem that I faced because of the raspberry pi was the usage of some libraries (LSL in particular https://github.com/OpenBCI/OpenBCI_Python/issues/122) that I solved commenting the line that includes the
OpenBCIWifiin_init.py_included in my working folder. Now everything (except obviously the wifi shield) is working. As soon as I finish the code that I'm writing I will upload it to Github.