by pandolio » Wed Jul 05, 2006 8:40 am
by pandolio
Wed Jul 05, 2006 8:40 am
Hi for all.
I'm working in a C program to control my KHR-1 robot on linux.
Now, i only send a "Play Motion" function to my Khr1, and sometimes he plays the motions, but no always. I know that it isn´t a problem, because i have to wait for a reponse for the khr1, and then i know if he is playing the motion.
The problem is that he never response. I think that the configuration of the port it´s right (sometimes he plays the motions) but on linux, there is more parameter that on windows for the configuration of the serial port, like the canonical comunication...
Someone know something about this and what it´s the problem?
Some code example:
for write on the port:
/*Funcion que escribe en el puerto serie*/
int escribir(int IDpuerto, struct TX *accion)
{
int res;
printf("voy a escribir...");
res = write(IDpuerto,accion,sizeof(struct TX) );
if ( res > 0 ) //Todo ha ido bien
{
printf("HE ESCRITO EN EL PUERTO %d bytes\n",res);
return TRUE;
}
else
{
return FALSE;
}
}
for read for the port:
/* Funcion que lee del puerto serie
* Devuelve 1 si ha leido bien y en la variable lectura devuelve lo que ha leido*/
int leer(int IDpuerto, struct RX *lectura)
{
int res;
printf("Voy a leer...\n");
res = read(IDpuerto,lectura,sizeof(struct TX));
printf("Leidos %d bytes del puerto\n", res);
if ( res > 0 ) //Todo ha ido bien
{
printf("LEIDO EN RX %d bytes y son esto: %s\n",res,lectura);
return TRUE;
}
else
{
return FALSE;
}
}
for configure the port:
int puerto;
struct termios newtio;
/* Obtenemos la configuracion del puerto serial */
puerto = open(SERIALPORT, O_RDWR | O_NOCTTY );
tcgetattr(puerto,&oldtio);
/* inicializamos el struct de la nueva configuracion del puerto*/
bzero(&newtio, sizeof(newtio));
newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
newtio.c_iflag = IGNPAR | ICRNL;
newtio.c_oflag = 0;
newtio.c_lflag = ICANON;
/* now clean the modem line and activate the settings for the port */
tcflush(puerto, TCIFLUSH);
/* se actualiza la configuracion del puerto */
tcsetattr(puerto,TCSANOW,&newtio)
return puerto;
thank you.
¡Hasta otra! (that is spanish)
I´m from spain and my english is bad, i´m sorry.

Hi for all.
I'm working in a C program to control my KHR-1 robot on linux.
Now, i only send a "Play Motion" function to my Khr1, and sometimes he plays the motions, but no always. I know that it isn´t a problem, because i have to wait for a reponse for the khr1, and then i know if he is playing the motion.
The problem is that he never response. I think that the configuration of the port it´s right (sometimes he plays the motions) but on linux, there is more parameter that on windows for the configuration of the serial port, like the canonical comunication...
Someone know something about this and what it´s the problem?
Some code example:
for write on the port:
/*Funcion que escribe en el puerto serie*/
int escribir(int IDpuerto, struct TX *accion)
{
int res;
printf("voy a escribir...");
res = write(IDpuerto,accion,sizeof(struct TX) );
if ( res > 0 ) //Todo ha ido bien
{
printf("HE ESCRITO EN EL PUERTO %d bytes\n",res);
return TRUE;
}
else
{
return FALSE;
}
}
for read for the port:
/* Funcion que lee del puerto serie
* Devuelve 1 si ha leido bien y en la variable lectura devuelve lo que ha leido*/
int leer(int IDpuerto, struct RX *lectura)
{
int res;
printf("Voy a leer...\n");
res = read(IDpuerto,lectura,sizeof(struct TX));
printf("Leidos %d bytes del puerto\n", res);
if ( res > 0 ) //Todo ha ido bien
{
printf("LEIDO EN RX %d bytes y son esto: %s\n",res,lectura);
return TRUE;
}
else
{
return FALSE;
}
}
for configure the port:
int puerto;
struct termios newtio;
/* Obtenemos la configuracion del puerto serial */
puerto = open(SERIALPORT, O_RDWR | O_NOCTTY );
tcgetattr(puerto,&oldtio);
/* inicializamos el struct de la nueva configuracion del puerto*/
bzero(&newtio, sizeof(newtio));
newtio.c_cflag = BAUDRATE | CRTSCTS | CS8 | CLOCAL | CREAD;
newtio.c_iflag = IGNPAR | ICRNL;
newtio.c_oflag = 0;
newtio.c_lflag = ICANON;
/* now clean the modem line and activate the settings for the port */
tcflush(puerto, TCIFLUSH);
/* se actualiza la configuracion del puerto */
tcsetattr(puerto,TCSANOW,&newtio)
return puerto;
thank you.
¡Hasta otra! (that is spanish)
I´m from spain and my english is bad, i´m sorry.
