Communicating with VRPN server

Making & changing box plugins and external apps
Post Reply
rajeshkarivellur
Posts: 5
Joined: Tue Jun 21, 2011 10:02 am

Communicating with VRPN server

Post by rajeshkarivellur »

Sir,
I want to do a simple project.
For this currently i am taking the example demo handball vr-demo.
here i need to get the the data from VRPN server for further process.
This data i want to send to my serial port.For this what i should do?
If i add a VRPN client in the demo can receive the data?

i tried with hyper terminal but only version number and an additional character is displaying.So please reply me any suggestion for continuing my project.
Rajesh

ddvlamin
Posts: 160
Joined: Thu Aug 13, 2009 8:39 am
Location: Ghent University
Contact:

Re: Communicating with VRPN server

Post by ddvlamin »

Hi,

There's a topic on that here: viewtopic.php?f=6&t=280

You will first have to write the client code that receives the VRPN data as explained in the above topic (it's not that difficult). In the client code, you then need to setup code for the serial port. This would look like where you change the variable "l_ttyname" to the name of you com port. You can also change the settings of the com port to suit your needs by updating the dcb structure.

Code: Select all

//initialize COM port
FD_TYPE i32FileDescriptor;
initTty(&i32FileDescriptor);

//to write something to serial port do something like this (beware of the //correct parsing when you write to serial port:
DWORD lpNumberOfBytesWritten;
l_bWriteSuccess = WriteFile(i32FileDescriptor, sCmdWord.c_str(), (DWORD)sCmdWord.size(), &lpNumberOfBytesWritten, NULL);

boolean initTty(FD_TYPE * m_i32FileDescriptor)
{
char * l_ttyname = "\\\\.\\COM1";

DCB dcb = {0};
*m_i32FileDescriptor = CreateFile((LPCSTR) l_ttyname, GENERIC_WRITE | GENERIC_READ,
0,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);

if (*m_i32FileDescriptor == INVALID_HANDLE_VALUE)
{
printf("Could not open Communication Port %s.\n",(char *) l_ttyname);
return false;
}

if (!GetCommState(*m_i32FileDescriptor, &dcb)) // get current DCB settings
{
return false;
}

// update DCB rate, byte size, parity, and stop bits size
dcb.DCBlength = sizeof(dcb);
dcb.BaudRate = CBR_115200; //TERM_SPEED;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
dcb.EvtChar = '\0';

// update flow control settings
dcb.fDtrControl = DTR_CONTROL_ENABLE;
dcb.fRtsControl = RTS_CONTROL_ENABLE;
dcb.fOutxCtsFlow = FALSE; //must be FALSE, robot arm does not send back a clear-to-send signal
dcb.fOutxDsrFlow = FALSE;
dcb.fDsrSensitivity = FALSE;;
dcb.fOutX = FALSE;
dcb.fInX = FALSE;
dcb.fTXContinueOnXoff = FALSE;
dcb.XonChar = 0;
dcb.XoffChar = 0;
dcb.XonLim = 0;
dcb.XoffLim = 0;
dcb.fParity = FALSE;
dcb.EvtChar = '.';

SetCommState(*m_i32FileDescriptor, &dcb);
SetupComm(*m_i32FileDescriptor, 1024, 1024);
EscapeCommFunction(*m_i32FileDescriptor, SETDTR);
SetCommMask (*m_i32FileDescriptor, EV_RXCHAR | EV_CTS | EV_DSR | EV_RLSD | EV_RING);

return true;
}

void closeTty(FD_TYPE m_i32FileDescriptor)
{
CloseHandle(m_i32FileDescriptor);
}
hope this helps,

Dieter

rajeshkarivellur
Posts: 5
Joined: Tue Jun 21, 2011 10:02 am

Re: Communicating with VRPN server

Post by rajeshkarivellur »

Sir,
Thank you for giving the valuable information.I have got vrpn client.exe from internet and i have received the datas from my vrpn server using client program. but its source code is not available.
So please provide the vrpn client code (c or cpp) and the header files.i want to test the VRPN client program from linux/windows(Visual studio 6.0) side.

Thanks and regards
Rajesh

ddvlamin
Posts: 160
Joined: Thu Aug 13, 2009 8:39 am
Location: Ghent University
Contact:

Re: Communicating with VRPN server

Post by ddvlamin »

On http://www.thewired.be/blog/wp-content/ ... enViBE.zip you can find a sample Analog VRPN project. The code you're interested in is in Openvibe.cpp

You will have to modify it to suit your own needs. The code for the serial port connection should also be added.

Best regards,
Dieter

rajeshkarivellur
Posts: 5
Joined: Tue Jun 21, 2011 10:02 am

Re: Communicating with VRPN server

Post by rajeshkarivellur »

Sir,
Thank you for valuable succession and for immediate reply.Now i could able to read data from my vrpn client program.
I have tested my vrpn client program with hanball example and i have received all the data successfully.
now i want to test my program with real EEG data taken from EEG machine.And currently i have taken some EEG datas and which i have saved in my PC.
My doubt is the files which i obtained from EEG machine does not have any file extension.So how to read these files.Which file reader i should chose from the openvibe?

Thanks and regards
Rajesh M.

lbonnet
Site Admin
Posts: 417
Joined: Wed Oct 07, 2009 12:11 pm

Re: Communicating with VRPN server

Post by lbonnet »

Hi Rajesh,
I have tested my vrpn client program with hanball example and i have received all the data successfully.
Congrats ! As you could see, VRPN is quiet easy to use (34 lines of code!)
And btw, thanks Dieter for this useful piece of code !
My doubt is the files which i obtained from EEG machine does not have any file extension.So how to read these files.Which file reader i should chose from the openvibe?
Well... If you don't know the file format, I 'm afraid we won't know either. And unfortunately openvibe does not come with a magic file reader box :)
Anyway... you can try to use every file reader boxes (connected to a signal display) and see what happens.

Cheers

Laurent
Follow us on twitter >> openvibebci

Checkout my (old) blog for some OpenViBE tips & tricks : here !

Post Reply