Thank you for your reply Paul,
I have cheked my configuration on windows with the pololu transmitter and works fine.
But I still can’t read it in Linux. I dont know where is the mistake
Im sure that im using USB DUAL Port and using the ACM0 port, because i can write in it.
Im using this functions: rabbit.eng.miami.edu/info/functions/unixio.html
to open, close,read and write in the servo controller.
And this is the code to configure the port:
int config_port(int fd){
struct termios options;
/* Get the current options for the port... */
tcgetattr(fd, &options);
/* Set the baud rates to 115200... */
cfsetispeed(&options, B115200);
cfsetospeed(&options, B115200);
/* Enable the receiver and set local mode... */
options.c_cflag |= (CLOCAL | CREAD);
// No parity (8N1):
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;
// no Flow Control
//options.c_cflag &= ~CNEW_RTSCTS;
/* Set the new options for the port...*/
tcsetattr(fd, TCSANOW, &options);
fcntl(fd, F_SETFL, 0);
return 0;
}
This is the code to write (that it works fine)
int setTarget(int fd,int servo,int target){
unsigned char serialBytes[4];
int n,output;
target=target*4;
serialBytes[0]=132;
serialBytes[1]=servo;
serialBytes[2]=target&0x7F;
serialBytes[3]=(target>>7)&0x7F;
n = write(fd,serialBytes,sizeof(serialBytes));
if (n < 0)
{
printf("Error Setting the Target %i for servo %i\n",target,servo);
output=-1;
}
else
{
output=n;
}
return output;
}
and this is the code to read
int getErrors(int fd){
unsigned char serialBytes;
unsigned char value[2];
int n,output;
serialBytes=161;
n = write(fd,&serialBytes,1);
if (n < 0)
{
printf("WC n=%i. Error Getting the Errors Messages\n",n);
output= -1;
}
else
{
fcntl(fd, F_SETFL, O_NONBLOCK);
n=0;
while (n!=2){
usleep(5000);
fcntl(fd, F_SETFL, 0);
n=read(fd,value,2);}
if (n!=2)
{
printf("RR n=%i. Error Getting the Errors Messages\n",n);
output=-1;
}
else
{
output=atoi(value);
}
}
return(output);
}
and the result is the same: I can write, but I cant read.
Thank you So Much.
I hope you can help me.