lihas / NeuroPy

NeuroPy library written in python to connect, interact and get data from neurosky's MindWave EEG headset.
88 stars 54 forks source link

Multiple connection #3

Closed acseckin closed 7 years ago

acseckin commented 11 years ago

Hi i'm trying to connect multiple headset. Here i attached my code:

issue

How can i connect multiple device at the same time(for example "COM3" and "COM5" simultaneously). Also It stops when i update rawLabel. raw updates continuously but att not. its working fine with console but with pyqt it stops.

Sincerly.

from PyQt4.QtGui import from PyQt4.QtCore import from NeuroPy import NeuroPy

portlar=[] app = QApplication([]) window = QWidget() window.setWindowTitle('Neurosky Connect') attLabel = QLabel('Attention') rawLabel = QLabel('Raw Data') connectButton = QPushButton('Connect') disconnectButton = QPushButton('Disconnect') def disconnect(): connection1.stop() # NOT WORKING def connect(): connection1=NeuroPy("COM3",9600) connection1.setCallBack("attention",attWR) connection1.setCallBack("rawValue",rawWR) connection1.start() def attWR(att): attLabel.setText("Attention :"+ str(att)) print "Attention :",att return None def rawWR(raw): rawLabel.setText("Raw Data :"+ str(raw)) print "Raw :",raw return None

window.connect(connectButton, SIGNAL('pressed()'), connect ) window.connect(disconnectButton, SIGNAL('pressed()'), disconnect) dizayn1 = QVBoxLayout() dizayn1.addWidget(rawLabel) dizayn1.addWidget(attLabel) dizayn1.addWidget(connectButton) dizayn1.addWidget(disconnectButton) window.setLayout(dizayn1) window.show() app.exec_()

lihas commented 11 years ago

as of now it cannot be used for multiple devices. at most you can create two different objects. the rawValue is updated more frequently than other parameters as other parameters like alpha etc depend on the value of rawValue over a certain period of time.

On Mon, Jul 15, 2013 at 6:11 PM, Ahmet Çağdaş SEÇKİN < notifications@github.com> wrote:

Hi i'm trying to connect multiple headset. Here i attached my code:

[image: issue]https://f.cloud.github.com/assets/3118166/797482/34075c56-ed4a-11e2-83dc-a81bba85875a.png

How can i connect multiple device at the same time(for example "COM3" and "COM5" simultaneously). Also It stops when i update rawLabel. raw updates continuously but att not. its working fine with console but with pyqt it stops.

Sincerly.

from PyQt4.QtGui import from PyQt4.QtCore import from NeuroPy import NeuroPy

portlar=[] app = QApplication([]) window = QWidget() window.setWindowTitle('Neurosky Connect') attLabel = QLabel('Attention') rawLabel = QLabel('Raw Data') connectButton = QPushButton('Connect') disconnectButton = QPushButton('Disconnect') def disconnect(): connection1.stop() # NOT WORKING def connect(): connection1=NeuroPy("COM3",9600) connection1.setCallBack("attention",attWR) connection1.setCallBack("rawValue",rawWR) connection1.start() def attWR(att): attLabel.setText("Attention :"+ str(att)) print "Attention :",att return None def rawWR(raw): rawLabel.setText("Raw Data :"+ str(raw)) print "Raw :",raw return None

window.connect(connectButton, SIGNAL('pressed()'), connect ) window.connect(disconnectButton, SIGNAL('pressed()'), disconnect) dizayn1 = QVBoxLayout() dizayn1.addWidget(rawLabel) dizayn1.addWidget(attLabel) dizayn1.addWidget(connectButton) dizayn1.addWidget(disconnectButton) window.setLayout(dizayn1) window.show() app.exec_()

— Reply to this email directly or view it on GitHubhttps://github.com/lihas/NeuroPy/issues/3 .

acseckin commented 11 years ago

I'm trying to connect 2 headsets. Also in this code .stop() works fine. Here my code with two object but not working. it gives only second (COM5) ports data image image

acseckin commented 11 years ago

can ve handle the multiple connection with thread ?

acseckin commented 10 years ago

We can connect multiple device with threads like

def ns_connect(datatype, port,baud):
     print "Starting "+str(datatype)+ "with"+str(port)+ "/"+str(baud)
     object1=NeuroPy(port,baud)
     object1.setCallBack(datatype,wr)
     object1.start()

thread.start_new_thread(ns_connect, ("meditation","COM5", 9600))
thread.start_new_thread(ns_connect, ("meditation","COM3", 9600))
lihas commented 10 years ago

Thanks for pointing this out. I dont have the device with me, will test it when i get it back.

On Fri, Sep 27, 2013 at 3:02 AM, Ahmet Çağdaş SEÇKİN < notifications@github.com> wrote:

We can connect multiple device with threads like

def ns_connect(datatype, port,baud): print "Starting "+str(datatype)+ "with"+str(port)+ "/"+str(baud) object1=NeuroPy(port,baud) object1.setCallBack(datatype,wr) object1.start()

thread.start_new_thread(ns_connect, ("meditation","COM5", 9600)) thread.start_new_thread(ns_connect, ("meditation","COM3", 9600))

— Reply to this email directly or view it on GitHubhttps://github.com/lihas/NeuroPy/issues/3#issuecomment-25234818 .