OpenViBE forum

The OpenViBE community
It is currently Thu Dec 14, 2017 10:05 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Tue Jun 21, 2011 10:20 am 
Offline

Joined: Tue Jun 21, 2011 10:02 am
Posts: 5
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


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 22, 2011 7:04 am 
Offline

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

There's a topic on that here: http://openvibe.inria.fr/forum/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:
//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


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 22, 2011 9:40 am 
Offline

Joined: Tue Jun 21, 2011 10:02 am
Posts: 5
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


Top
 Profile  
Reply with quote  
PostPosted: Wed Jun 22, 2011 9:53 am 
Offline

Joined: Thu Aug 13, 2009 8:39 am
Posts: 160
Location: Ghent University
On http://www.thewired.be/blog/wp-content/uploads/Vrpn_OpenViBE.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


Top
 Profile  
Reply with quote  
PostPosted: Thu Jun 23, 2011 7:28 am 
Offline

Joined: Tue Jun 21, 2011 10:02 am
Posts: 5
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.


Top
 Profile  
Reply with quote  
PostPosted: Fri Jun 24, 2011 7:10 am 
Offline
Site Admin

Joined: Wed Oct 07, 2009 12:11 pm
Posts: 417
Hi Rajesh,

Quote:
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 !

Quote:
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 !


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Americanized by Maƫl Soucaze.