BrainStorm wrote:Firstly, i would like to thanks all the developers of this great and innovative project, that i just discovered and... yes, i felt in love.
I had the same feeling when I first saw the project. You can immediately see that it is made by experienced software developers. With not too much effort you can easily start to write your own plugins (
http://openvibe.inria.fr/documentation/ ... lugin.html this is a great place to start )
BrainStorm wrote:I was thinking... OpenViBE is great, but it lacks of a serial writer? Or it has one? I mean... a layer that can write conditional datas on a serial port, so prototyping would just be flawless...
When i say conditional data, i'm talking about some kind of "filtering"... something like "go to right" and "go to left" if a certain signal is acquired, then write it on a serial port, so there can be another software on a lower level that can command and drive any peripheric which support serial communication... is it possible?
To my knowledge there is no box to write commands to the serial port (for example a command based on the output of a classifier). However there are VRPN boxes (
http://openvibe.inria.fr/documentation/ ... erver.html ) which you can use for this purpose. The only thing you have to do is to write your own client program which connects to the VRPN server box that is initialized in OpenViBE. This way you can easily balance the load across different cores or even computers (because you have two separate applications).
In my experience, the problem with some communication protocols (to control some external device) is that you have to wait for an answer. In a real-time application such as OpenViBE you have to keep processing the signals and thus there is no time to wait for responses. So you can and are off course welcome to write a box for serial port communication, but it will probably need to be executed in a separate thread within OpenViBE then.
For the VRPN (the analog case) you will need code like that (was given to me by my student):
Code: Select all
#include <iostream>
#include <string.h>
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
#include "vrpn_Analog.h"
using namespace std;
//Callback handler
void VRPN_CALLBACK handle_analog(void *userdata, vrpn_ANALOGCB b);
int main(int argc, const char* argv[]){
vrpn_Analog_Remote *ana;
// initialize the analog
ana = new vrpn_Analog_Remote("openvibe-vrpn@localhost");
// Set up the analog callback handler
ana->register_change_handler(NULL, &handle_analog);
// main interactive loop
while ( 1 ){
// Let the analog device do its thing
ana->mainloop();
}
return 0;
}
void VRPN_CALLBACK handle_analog(void *userdata, vrpn_ANALOGCB b){
for (int i=0; i< b.num_channel; i++)
printf("Chan[%d] = %lf\n", i, b.channel[i]);
}
and for serial port communication
Code: Select all
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);
}
Best regards,
Dieter Devlaminck