An external application sending information to BCI2000

Forum for software developers to discuss BCI2000 software development
Locked
gongenhao
Posts: 6
Joined: 22 Oct 2010, 19:01

An external application sending information to BCI2000

Post by gongenhao » 22 Oct 2010, 19:09

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

mellinger
Posts: 1065
Joined: 12 Feb 2003, 11:06

Post by mellinger » 25 Oct 2010, 08:38

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

gongenhao
Posts: 6
Joined: 22 Oct 2010, 19:01

Post by gongenhao » 25 Oct 2010, 10:29

thanks.
I will try on it~

gongenhao
Posts: 6
Joined: 22 Oct 2010, 19:01

Post by gongenhao » 26 Oct 2010, 10:26

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

mellinger
Posts: 1065
Joined: 12 Feb 2003, 11:06

Post by mellinger » 28 Oct 2010, 10:19

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?

gongenhao
Posts: 6
Joined: 22 Oct 2010, 19:01

Post by gongenhao » 28 Oct 2010, 12:53

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?

mellinger
Posts: 1065
Joined: 12 Feb 2003, 11:06

Post by mellinger » 29 Oct 2010, 09:17

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.

gongenhao
Posts: 6
Joined: 22 Oct 2010, 19:01

Post by gongenhao » 02 Nov 2010, 11:26

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

mellinger
Posts: 1065
Joined: 12 Feb 2003, 11:06

Post by mellinger » 03 Nov 2010, 11:11

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

gongenhao
Posts: 6
Joined: 22 Oct 2010, 19:01

Post by gongenhao » 04 Nov 2010, 11:45

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

mellinger
Posts: 1065
Joined: 12 Feb 2003, 11:06

Post by mellinger » 05 Nov 2010, 07:21

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

gschalk
Posts: 615
Joined: 28 Jan 2003, 12:37

Signal

Post by gschalk » 05 Nov 2010, 16:07

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

Locked

Who is online

Users browsing this forum: No registered users and 1 guest