Page 1 of 2

appconnector question

Posted: 29 Apr 2011, 00:21
by axone.he
Dear all,
I want to use the appconnector to send the signal from BCI2000 to a application. The appconnector send the signal through UDP protocol. But we use flash cs4 professional with actionscript 3 language to write the application. And the actionscripts3 language does not support the UDP protocol, are there any idea to solve this problem? Could BCI2000 appconnector send the signal wiht TCP protocol?

Re: appconnector question

Posted: 29 Apr 2011, 07:24
by mellinger
Hi,

you can use the TCP protocol by making the following changes to the BCI2000 source code, and recompiling.

src/shared/modules/application/ConnectorFilters.cpp, line 195-197:
Disable these lines by writing two slashes // in front of them.
src/shared/modules/application/ConnectorFilters.h, line 84:
replace sending_udpsocket with server_tcpsocket

Thus, BCI2000 will act as a server on the specified port. However, you will need to re-connect to the server each time you press SetConfig in the Operator dialog.

Also, mind the following: With a TCP socket, BCI2000 will always wait until you read data on your side of the connection. So if you don't read data in a timely manner, you will introduce timing problems on the BCI2000 side. If possible, read data from a secondary thread in your application.

Regards,
Juergen

Re: appconnector question

Posted: 29 Apr 2011, 08:19
by axone.he
Thank you a lot.
You mean that I could replace the UPD protocal with TCP in the source code. But it will induce timing problem in the BCI2000 if our application has not read the data send by BCI2000 timely.
Your advice is we write a simple program to read the data send by BCI2000 in UDP protocal, and the simple program send the data to our application in TCP protocal, so it would not impact
the run of BCI2000, right?
Thank you

Re: appconnector question

Posted: 29 Apr 2011, 11:58
by mellinger
Your advice is we write a simple program to read the data send by BCI2000 in UDP protocal, and the simple program send the data to our application in TCP protocal, so it would not impact
the run of BCI2000, right?
Of course, this would be a very good solution to the problem. I didn't think of it when writing my answer.

Regards,
Juergen

Re: appconnector question

Posted: 30 Apr 2011, 01:54
by axone.he
OK,Thank you.
We would write a small program to see it whether work well.
And not only we want to the BCI2000 send the contral signal to our application, the application would send several signals to the BCI2000, so I want to ask whether the signals will appear in the .dat file saved by BCI2000 as marks? Thank you

Regards
He

Re: appconnector question

Posted: 02 May 2011, 05:31
by mellinger
Yes, if you send state values to BCI2000, these values will appear in the .dat file. Remember that you need to create appropriate states first, by using an operator OnConnect script that defines them:

Code: Select all

Insert State MyState 16 0
For more information about operator scripting, see
http://www.bci2000.org/wiki/index.php/U ... _Scripting
For information about how to specify operator scripts on the command line when starting the operator module, see
http://www.bci2000.org/wiki/index.php/U ... tor_Module

Regards,
Juergen

Re: appconnector question

Posted: 02 May 2011, 09:41
by axone.he
OK, thank you.
I will try it.

Rgards
He

Re: appconnector question

Posted: 04 May 2011, 10:06
by axone.he
I will try to set a new state in the operator OnConnect script.
-Insert State my1 16 0
and it appears in the .dat file.
But I whether I could set the state of only one external marker?
And I type the new state name 'my1' in the ConnectorInputFilter, the new state 'my1' will receive the incoming values but other state will not receive the values. For example, the incoming value is 1, and the state 'my1' will be set to 1, and other state e.g 'TargetCode' will not change, right?
Regards
He

Re: appconnector question

Posted: 04 May 2011, 12:51
by mellinger
Use multiple "Insert State" commands, as in

Code: Select all

-Insert State my1 16 0; Insert State my2 4 0
Juergen

Re: appconnector question

Posted: 04 May 2011, 21:38
by axone.he
Thank you.
If I want the input values change the new states my1, should I specify the state name in the ConnectorInputFilter as my1?
But when I sent the new values through a UDP socket, the BCI 2000 respond as system halted,
the ConnectorInputAddress I set is 'Localhost:8000', the ConnectorInputAddress I set my1 and the UPD address is set 'Localhost:8000 as well',is there any thing wrong?
Thank you
He

Re: appconnector question

Posted: 05 May 2011, 08:13
by mellinger
f I want the input values change the new states my1, should I specify the state name in the ConnectorInputFilter as my1?
Yes, but you may set it to "*" (without quotes) in order to allow all states to change.
But when I sent the new values through a UDP socket, the BCI 2000 respond as system halted,
the ConnectorInputAddress I set is 'Localhost:8000', the ConnectorInputAddress I set my1 and the UPD address is set 'Localhost:8000 as well',is there any thing wrong?
You should use different addresses for outgoing and ingoing connection. Also, make sure that each line is terminated with a newline character when sending values to BCI2000.

Juergen

Re: appconnector question

Posted: 05 May 2011, 11:47
by axone.he
Thank you.
If I set the * in the ConnectorInputFilter, all the state will change as the input value?

And I have used different address for outgoing and ingoing connection. Moreover, I have set the input address in BCI2000 blank now, for I want see whether the BCI2000 will receive the input value. And the address in the ConnectorInputAddress is 'Localhost:8000', the address in UDP socket to send is ''Localhost:8000', that's right?
Regards
He

Re: appconnector question

Posted: 06 May 2011, 09:05
by mellinger
If I set the * in the ConnectorInputFilter, all the state will change as the input value?
No, it just means that it is possible to set all states over the UDP connection. To set an individual state's value, you need to send the state's name first, then the value, and terminate the line with a newline character, as described on http://www.bci2000.org/wiki/index.php/T ... r#Protocol
And the address in the ConnectorInputAddress is 'Localhost:8000', the address in UDP socket to send is ''Localhost:8000', that's right?
Yes, that should be right.

Juergen

Re: appconnector question

Posted: 07 May 2011, 03:02
by axone.he
Thank you.
I'll try it.
And if I send and receive the value at the same time, there would not be a conflict in the BCI2000,the UDP protocal in BCI2000 is full duplex, right?
Regards
He

Re: appconnector question

Posted: 09 May 2011, 08:12
by mellinger
The ConnectorInput filter is placed first in the application module, the ConnectorOutput filter is placed last. When you set a state's value through the ConnectorInput, you will read that same value when reading through the ConnectorOutput.
There should not be a problem with reading and writing through the two UDP sockets at the same time.

Regards,
Juergen