Page 1 of 1

An external application sending information to BCI2000

Posted: 22 Oct 2010, 19:09
by gongenhao
Hi
I am now working on sending data from an external application to BCI2000, running locally.
I have read 'Technical Reference:App Connector'
What I understand is I should use UDP socket to send data to certain address( local) and certain port. But I don't fully understand what should I send and how the BCI 2000 can interpret it.

For example, I want to send 2 variable value (float) X and Y. And I have alreadly created corresponding states in BCI2000 application.
What should I send if I want to set the value of X to 1?

Thanks a lot~

Enhao

Posted: 25 Oct 2010, 08:38
by mellinger
Enhao,

BCI2000 states hold only unsigned integers, so you cannot store float values in them.
To set the value of a state X to 1, send

Code: Select all

X 1\n
to the UDP socket, i.e. the name of the state followed with white space followed with the value and a newline character.

Best regards,
Juergen

Posted: 25 Oct 2010, 10:29
by gongenhao
thanks.
I will try on it~

Posted: 26 Oct 2010, 10:26
by gongenhao
When I send data through udp, it says
'Warning:ConnectorInput::Process: Ignoring value for non-existent'
in the system log.
Why?
The sended states exist and can be found from BCI2000 Viewer.

Thanks
mellinger wrote:Enhao,

BCI2000 states hold only unsigned integers, so you cannot store float values in them.
To set the value of a state X to 1, send

Code: Select all

X 1\n
to the UDP socket, i.e. the name of the state followed with white space followed with the value and a newline character.

Best regards,
Juergen

Posted: 28 Oct 2010, 10:19
by mellinger
I tested the connector input, and found that I can send state information via UDP. Could it be that you are sending a DOS line ending rather than a newline character at the end of each line?

Posted: 28 Oct 2010, 12:53
by gongenhao
I just write like:
sprintf(sendBuf,"X %d\n",_value);
sendto(_svr,sendBuf,strlen(sendBuf)+1,0,(sockaddr*)&_addrsvr,len);


Is "\n" the right newline character?
mellinger wrote:I tested the connector input, and found that I can send state information via UDP. Could it be that you are sending a DOS line ending rather than a newline character at the end of each line?

Posted: 29 Oct 2010, 09:17
by mellinger
You send one more character than there are characters in the string. This will result in an additional '\0' character being sent at the end of the string. Removing the "+1" from your code will probably make it work.

Posted: 02 Nov 2010, 11:26
by gongenhao
mellinger wrote:You send one more character than there are characters in the string. This will result in an additional '\0' character being sent at the end of the string. Removing the "+1" from your code will probably make it work.
Thanks a lot.
I have correct this mistake.
It works well to use'Running 0\n' to suspend the application.
I want to use external signal to control the cursor position in visualization module, what should I do?
I have tried in the Signal Generator application but did not make it. I set 'CursorPosX 1\n' but the Cursor does not change it position.

Enhao

Posted: 03 Nov 2010, 11:11
by mellinger
Enhao,

the cursor is not controlled via the CursorPos states. Rather, its horizontal and vertical speed are controlled by the signal: Signal(0,0) controls horizontal velocity, Signal(1,0) controls vertical velocity. Velocities are scaled by the application module, such that a control signal with zero mean and unit variance will move the cursor across the screen in the amount of time given by the FeedbackDuration parameter.

Regards,
Juergen

Posted: 04 Nov 2010, 11:45
by gongenhao
mellinger wrote:Enhao,

the cursor is not controlled via the CursorPos states. Rather, its horizontal and vertical speed are controlled by the signal: Signal(0,0) controls horizontal velocity, Signal(1,0) controls vertical velocity. Velocities are scaled by the application module, such that a control signal with zero mean and unit variance will move the cursor across the screen in the amount of time given by the FeedbackDuration parameter.

Regards,
Juergen
Thanks Juergen
So does it means that we have to modify the cursor application if we want to directly control the position of the cursor instead of velocity of movement.

I have just programmed a .cpp and .h as logger of the external input.
In the wiki, it says:
'Now, when we add the ThumbWheelLogger.cpp file to a source module, then the module will contain an object of our newly created class, and it will listen to the --LogThumbWheel=1 command line option.'
Should I just add the object into the g.USBamp source module? I haven't used Borland so I am a little confused

Thanks a lot

Posted: 05 Nov 2010, 07:21
by mellinger
Enhao,

if you want to use a logger, add its cpp file to the project that builds the source module you want to use. In the Borland IDE, this can be done by first activating the project in the projects view (double-clicking it), and then dragging the logger's cpp file onto the projects view.

Regards,
Juergen

Signal

Posted: 05 Nov 2010, 16:07
by gschalk
Hi,

What Juergen says is correct. Also, you do not need to modify the cursor task. You need to "inject" Signal (1,0), and not CursorPosX.

Gerv