Question about using app connector

Forum for discussion on different user applications
Post Reply
xtwang
Posts: 7
Joined: 15 Jul 2015, 07:53

Question about using app connector

Post by xtwang » 16 Sep 2015, 07:37

Dear all

Our group is trying to send control signal information from BCI2000 to Arduino. I have verified that the app connector stream has been sent by BCI2000 by using both the SimpleExample and MATLAB script. The information sent is as follows:
=======================================
Running 1
Recording 1
SourceTime 58636
StimulusTime 58143
TargetCode 0
ResultCode 0
Feedback 0
PauseApplication 0
Signal (0,0) -0.372138
Signal (1,0) 8.01336
========================================
However, the only information I do want to send is the control signal. All the other states are not required to be sent in this project. How should I manipulate this?

Besides, can anyone give me some hint on how to do coding on the receiving end (Arduino) in terms of reading from the port? If the sent info is in the form of 'Signal (1,0) 8.01336', how should the receive end do the coding to read it?

Thanks in advance!

xtwang

pbrunner
Posts: 344
Joined: 17 Sep 2010, 12:43

Re: Question about using app connector

Post by pbrunner » 16 Sep 2015, 11:23

Xtwang,

you can use a regular expression [1] to extract the control signal value from the AppConnector stream. The additional state variables are just ignored with this regular expression.

If this is not an option for you you can also implement your own BCI2000 filter that, placed at the end of the filter chain, transmits just the control signal over a UDP or TCP socket. For that purpose you can use the sockstream class in BCI2000. You find example of the use of this class throughout the BCI2000 project.

Regards, Peter

[1] http://www.cplusplus.com/reference/regex/

xtwang
Posts: 7
Joined: 15 Jul 2015, 07:53

Re: Question about using app connector

Post by xtwang » 23 Sep 2015, 04:52

Dear Peter,

Thanks for your help, I have achieved the extraction of control signal using regex. However, I'm having another problem.

In BCI2000 configuration, I set the "ConnectorOutputAddress" as localhost: 20321, then modified the example code from
http://www.bci2000.org/wiki/index.php/T ... _Connector to let it read from localhost: 20321. After that, I applied the regular expression and extract the control signal only, then try to write it to an Arduino chip board, whose ip is 192.168.0.123. I used the line const char* address2 = "192.168.0.123:8888" to specify the port that I want to send the control signal, but it doesn't work - Arduino side cannot receive it.

Before posting, I have tested the following things:
1. Send the extracted control signal to localhost: 5000, it works. I checked with another appconnector example.
2. In BCI2000 configuration, set "ConnectorOutputAddress" as 192.168.0.123:8888, Arduino board can receive all the states and control signals. But this means my extraction algorithm is not used.

Thus, my best guess is that I didn't specify the address in the correct way in my code. Can you help me with this?

Sincerely,

xtwang

pbrunner
Posts: 344
Joined: 17 Sep 2010, 12:43

Re: Question about using app connector

Post by pbrunner » 23 Sep 2015, 09:53

xtwang,

if the default port works then this limits the possible causes and resolutions to:

a) the port is already in use -> try a different port
b) you do something wrong in setting up the new connection -> do you regex on the Arduino side

I would recommend going with (b) and just implement the regex processing there.

Regards, Peter

xtwang
Posts: 7
Joined: 15 Jul 2015, 07:53

Re: Question about using app connector

Post by xtwang » 28 Sep 2015, 10:53

Dear Peter,

Thank you very much for your help. We have successfully connected BCI2000 with Arduino.

xtwang

Post Reply

Who is online

Users browsing this forum: No registered users and 26 guests