Hi everyone,
I use serial cable to connect two QNX computers. I want to set up serial port communication between two machines.
Part of my code is:
int open_port()
{
struct termios options;
int fd = open("/dev/ser1",O_RDRW | O_NOCTTY);
fcntl(fd,F_SETFL,0);
tcgetattr(fd,&options);
cfsetispeed(&options,B115200);
cfsetospeed(&options,B115200);
options.c_cflag |= (CLOCAL | CREAD);
options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;
tcsetattr(fd,TSCANOW,&options);
return fd;
}
void write_port()
{
char *data;
int len = strlen(data);
write(fd,data,len);
}
void read_port()
{
char buffer [1024];
int numbytes_read = read(fd,buffer,1024);
data[numbytes_read] = 0x00;
}
When I send characters, the other machine can not receive these characters.
Please help me to resolve this problem. I also need some example codes.
Thank you!